Skip to content

Instantly share code, notes, and snippets.

View andreis's full-sized avatar

andreis

View GitHub Profile
@andreis
andreis / my-etc-hosts
Created February 8, 2014 16:48
My /etc/hosts for Getting Shit Done
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
#!/usr/bin/env python3
# https://www.hackerrank.com/challenges/insertion-sort
'''
0 1 2 3 .. n-1
n = 6
3 1 2 5 1 2 array
4 0 1 2 0 0 DP array
#!/usr/bin/env python3
# https://www.hackerrank.com/challenges/insertion-sort
count = 0
def mergesort(L, l, r):
if l+1 >= r: return
mid = int((l+r+1)//2)
mergesort(L, l, mid)
#!/usr/bin/env python3
# https://www.hackerrank.com/challenges/angry-children
import sys
def solve(L, k):
# stuff
n = int(input())
k = int(input())
Usage: new [options] args
Options:
-h --help
display this message
-i --install
install templates from a repository
-s --silent -f --force
supress output; silent fail, all answers Yes
-t --template
Consider using 'dppx' units instead of 'dpi', as in CSS 'dpi' means dots-per-CSS-inch, not dots-per-physical-inch, so does not correspond to the actual 'dpi' of a screen. In media query expression: (min-resolution: 144dpi), (-webkit-min-device-pixel-ratio: 1.5)
event.returnValue is deprecated. Please use the standard event.preventDefault() instead.
WebGL: INVALID_OPERATION: drawArrays: attribs not setup correctly dir/Interlaken,+Switzerland/Zurich,+Switzerland/@47.240032,8.616212,11z/dat…1m1!1s0x47900b9749bea219:0xe66e8df1e71fdc03!2m2!1d8.5391825!2d47.3686498:1
WebGL: INVALID_VALUE: texImage2D: width or height out of range dir/47.2308094,8.6342368/Nice,+France/@45.5564777,6.0122439,7z/data=!3m1!4b…m1!1s0x12cdd0106a852d31:0x40819a5fd979a70!2m2!1d7.265592!2d43.696036!3e0:1
254
WebGL: INVALID_VALUE: texSubImage2D: dimensions out of range dir/47.2308094,8.6342368/Nice,+France/@45.5564777,6.0122439,7z/data=!3m1!4b…m1!1s0x12cdd0106a852d31:0x40819a5fd979a70!2m2!1d7.265592!2d43.696036!3e0:1
WebGL: too many errors, n
func Tokenize(s string) []string {
out := []string{}
for l, r := 0, 0; r < len(s); {
for l = r; isSep(s[l]); l++ {
}
for r = l; r < len(s) && !isSep(s[r]); r++ {
}
out = append(out, s[l:r])
}
return out
@andreis
andreis / tree-ser-deser.go
Last active August 29, 2015 13:57
A somewhat obvious solution is to emulate a heap and replace the missing nodes with "x" markers, but this performs badly on path trees (only left links). An improvement would be to replace consecutive "x"-es by "x<number>", where number==how many x-es are replaced. The solution in this gist does a depth-first traversal and prints the tree recurs…
package main
import (
"fmt"
"math/rand"
"strconv"
"strings"
"time"
)
Process: Google Music [13389]
Path: /opt/homebrew-cask/*/Google Music.app/Contents/MacOS/Google Music
Identifier: com.sajidanwar.Google-Music
Version: 1.1.1 (0)
Code Type: X86-64 (Native)
Parent Process: launchd [241]
Responsible: Google Music [13389]
User ID: 501
Date/Time: 2014-03-26 14:38:26.746 +0000
s1 = []
s2 = []
def enq(val):
global s1, s2
if len(s1) == 0:
s1.append(val)
else:
s2.append(val)
while len(s1) > 0: