Skip to content

Instantly share code, notes, and snippets.

View snahor's full-sized avatar

Hans Roman snahor

  • Wakanda
View GitHub Profile
const sleep = async (n) => await (new Promise(r => setTimeout(r, n)));
export default sleep;
const tableFactory = () => {
const columns = [];
const compositeUniqueColumns = [];
const dataTypes = [
'uuid',
'string',
'timestamp',
'float',
'integer',
# posix
sudo echo "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" > /etc/apt/sources.list.d/virtualbox.list
# fish
# sudo echo "deb http://download.virtualbox.org/virtualbox/debian (lsb_release -cs) contrib" > /etc/apt/sources.list.d/virtualbox.list
sudo apt-get update
sudo apt-get install virtualbox-5.0 -y
hgrep() {
history | grep -v grep | grep $1 | awk '{f=$1;$1="";print $0}' | awk '{$1=$1}1' | sort | uniq
}
@snahor
snahor / gist:36da9cbc701b758fd998
Last active August 29, 2015 14:17
Useful commands I always forget
# clear text file
cat /dev/null > {path to file}
cp /dev/null {path to file}
> {path to file} # works if you're not using fish
# clipboard to file
xsel -o > {path to file}
@snahor
snahor / topological_sort.py
Created February 24, 2015 21:48
Topological ordering
def topological_sort(graph):
"""
:param graph: an adjacency list representing an acyclic digraph
:type graph: dict
:return: a list of vertices in order of decreasing finish times
:rtype: list
>>> G = {'w': ['t'], 's': ['v', 'w'], 'v': ['t'], 't': []}
>>> order = topological_sort(G)
>>> order in (['s', 'w', 'v', 't'], ['s', 'v', 'w', 't'])
@snahor
snahor / readme.md
Last active August 29, 2015 14:15 — forked from ukd1/readme.md

Given an array of positive integers, write a function which returns all the unique pairs which add (equal) up to 100.

Example data:

sample_data = [0, 1, 100, 99, 0, 10, 90, 30, 55, 33, 55, 75, 50, 51, 49, 50, 51, 49, 51]
sample_output = [[1,99], [0,100], [10,90], [51,49], [50,50]]
def better_pascal(n):
def row(n):
row = [1]
for i in range(n):
row.append(row[i] * (n - i) // (i + 1))
return row
return [row(i) for i in range(n)]
import hashlib
import base64
import hmac
import time
def _decrypt_cookie(name, value, cookie_secret, include_name=True):
def _cookie_signature(*parts):
hash = hmac.new(cookie_secret,
digestmod=hashlib.sha1)
@snahor
snahor / freetds.conf
Last active January 2, 2016 08:39
SQLA + pyodbc
[db_name]
host = 1.1.1.1
port = 1433
tds version = 8.0
client charset = UTF-8