Skip to content

Instantly share code, notes, and snippets.

@dalejung
dalejung / json.sh
Created August 7, 2016 18:59
json.sh
function tempjson() {
temp_file=$(mktemp)
while read -r LINE; do
echo $LINE >> "$temp_file"
done
export _temp_json=$temp_file
}
alias jcli="tempjson && ipython -i -c \"import json, os; f = open(os.environ['_temp_json']); data = json.load(f); f.close()\""
@dalejung
dalejung / init.lua
Created May 26, 2016 14:34
ma hammerspoon
local hyper = {"cmd", "shift",}
function handles_focus(win)
local app = win:application()
local app_name = app:title()
if app_name ~= 'iTerm2' then
return false
end
if string.match(win:title(), "(tmux)") then
@dalejung
dalejung / select_pane.sh
Last active May 23, 2016 17:26
select pane that doesn't wrap.
#!/usr/bin/env bash
pane_at_edge() {
direction=$1
case "$direction" in
"U")
coord='top'
op='<='
;;
@dalejung
dalejung / Untitled1.ipynb
Last active July 2, 2023 03:09
Untitled1.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dalejung
dalejung / runs.py
Created January 25, 2016 01:33
old runs code
import pandas as pd
import numpy as np
def _run_starts_ends(bools):
"""
Returns a start and end bool array that marks the endpoints of
each contigious group of Trues
Parameters
----------
@dalejung
dalejung / runs.py
Created January 25, 2016 01:25
old thing from 2013
import pandas as pd
import numpy as np
def _run_starts_ends(bools):
"""
Returns a start and end bool array that marks the endpoints of
each contigious group of Trues
Parameters
----------
@pattern
def multi_return(x):
meta[match: x]
~ float [when: x > 1] | type(x), x, x
~ int [when: x > 100 and x < 150] | x, 'Between 100 and 150'
~ int [when: x > 10]| 'INT OVER 10'
~ int | type(x), x
@dalejung
dalejung / empty.txt
Created July 21, 2015 04:09
nbx created gist
empty file created by nbx
@dalejung
dalejung / empty.txt
Created July 21, 2015 04:09
nbx created gist
empty file created by nbx
import ast
graph = {'A': set(['B', 'C']),
'B': set(['A', 'D', 'E']),
'C': set(['A', 'F']),
'D': set(['B']),
'E': set(['B', 'F']),
'F': set(['C', 'E'])}
def dfs(graph, start):