Skip to content

Instantly share code, notes, and snippets.

@nicolevanderhoeven
nicolevanderhoeven / updateDate.js
Created May 8, 2023 15:42
Gist for automatically adding a link to today's daily note to an Dataview inline field in an Obsidian note. For use with the QuickAdd Obsidian plugin.
module.exports = async function updateDate(params) {
/*
This function does the following things:
1. Gets the current date.
2. Reads the contents of the current file.
3. When a line that contains `date::` is found, adds the current date as a note to the end of the line.
*/
let currDate = moment().format('YYYY-MM-DD');
const currentFile = params.app.workspace.getActiveFile();
const fileContents = await params.app.vault.read(currentFile);
@schriker
schriker / OTPInput.tsx
Created September 4, 2022 06:54
Simple React Native One Time Password Input
import React, { useRef } from 'react'
import { NativeSyntheticEvent, TextInput, TextInputKeyPressEventData, View } from 'react-native'
import { useStyles } from 'lib/hooks'
import { createStyles } from 'lib/styles'
import { Nullable } from 'lib/types'
type OTPInputProps = {
length: number,
value: Array<string>,
disabled: boolean,
@AndrewFarley
AndrewFarley / generate-random-1gb-csv.py
Last active April 24, 2024 16:42
This simple Python file generates a random massive CSV file efficiently taking almost no RAM while doing so streaming data into your CSV file. I've pre-done the calculation of the rows/columns to the file-size, so you can easily add or remove zeroes from "rows" variable to increase or decrease the size of the file generated
import csv
import random
# 1000000 and 52 == roughly 1GB (WARNING TAKES a while, 30s+)
rows = 1000000
columns = 52
print_after_rows = 100000
def generate_random_row(col):
a = []
@ChristophShyper
ChristophShyper / check_ip_and_cidr.ipynb
Last active April 24, 2024 16:41
Google Colab notebook getting external IP plus CIDR and network name from Whois. Great for figuring out CIDR blocks to whitelist for databases access by Colab.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@peschee
peschee / git_ssl_self_signed.md
Last active April 24, 2024 16:41
Disable SSL verification in git repositories with self-signed certificates

Sometimes, we have to access git repositories over SSL and the server only provides a self-signed certificate 🙈. Although there are ways to increase the trust level for the self-signed certificate (https://confluence.atlassian.com/fishkb/unable-to-clone-git-repository-due-to-self-signed-certificate-376838977.html, https://confluence.atlassian.com/bitbucketserverkb/resolving-ssl-self-signed-certificate-errors-806029899.html), my recommendation is to just ignore SSL verification alltogether.

Prepend GIT_SSL_NO_VERIFY=true before every git command run to skip SSL verification. This is particularly useful if you haven't checked out the repository yet.

Run git config http.sslVerify false to disable SSL verification if you're working with a checked out repository already.

@nerodono
nerodono / Comb.py
Last active April 24, 2024 16:34
Another thing that I did on my phone (omg this was fucking suffering)
from functools import reduce as foldl
import string
import pprint
import builtins
class ParseFail(Exception):
...
def group_fails(message, *fails):
return ParseFail(f"{message}: {fails!r}")
@ih2502mk
ih2502mk / list.md
Last active April 24, 2024 16:34
Quantopian Lectures Saved
go mod edit -module {NEW_MODULE_NAME}
-- rename all imported module
find . -type f -name '*.go' \
-exec sed -i -e 's,{OLD_MODULE},{NEW_MODULE},g' {} \;
@jboner
jboner / latency.txt
Last active April 24, 2024 16:33
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@3dln
3dln / CameraOrbit.cs
Last active April 24, 2024 16:32
A simple Unity C# script for orbital movement around a target gameobject
// A simple Unity C# script for orbital movement around a target gameobject
// Author: Ashkan Ashtiani
// Gist on Github: https://gist.github.com/3dln/c16d000b174f7ccf6df9a1cb0cef7f80
using System;
using UnityEngine;
namespace TDLN.CameraControllers
{
public class CameraOrbit : MonoBehaviour