Skip to content

Instantly share code, notes, and snippets.

// user lands
mixpanel.track('<event name>', {})
// user registers
mixpanel.alias('<user email>')
mixpanel.people.set({
// ...
})
mixpanel.identify('<user email>') // flush to mixpanel
@bmcorser
bmcorser / gist:c1cf4d30cc51c604baba
Created December 2, 2014 17:11
`set` vs `dict`
from operator import itemgetter
data = [
{'id': 1},
{'id': 2},
{'id': 3},
{'id': 4},
]
@bmcorser
bmcorser / throttle.js
Last active August 29, 2015 14:08
Throttle $.ajax calls
define(['jquery'], function ($) {
var THROTTLE = 200; // ms
var previousCalls = {}; // for namespaces
var throttle = function (name, ajaxOpts) {
var now = new Date();
previousCalls[name] = now;
from wheel.install import WheelFile
dist_path = '/path/to/mypackage.whl'
whl = WheelFile(dist_path)
whl.parsed_wheel_info.items()
# [('Wheel-Version', '1.0'), ('Generator', 'bdist_wheel (0.21.0)'), ('Root-Is-Purelib', 'false'), ('Tag', 'cp27-none-macosx_10_9_x86_64')]

The genomebrowser API does not deal with foreign key associations at all.

A request requires enough information to get to a chromosome id (either directly a chromosome id, or combination of genome/chromsome filters) and a target region (start and end). This information should be provided in a JSON-encoded JavaScript object transmitted in the request body. Detailed spec:

{
from collections import defaultdict
phonebook = [('betty', '555-2938'),
('betty', '342-2492'),
('bonnie', '452-2928'),
('patsy', '493-2928'),
('patsy', '943-2929'),
('patsy', '827-9162'),
('lucille', '205-2928'),
:set +m
import qualified Data.Map
let phoneBook = [("betty","555-2938")
,("betty","342-2492")
,("bonnie","452-2928")
,("patsy","493-2928")
,("patsy","943-2929")
import qualified Data.Map
import qualified Data.Maybe
listInsert :: Ord k => (k, v) -> Data.Map.Map k [v] -> Data.Map.Map k [v]
listInsert (k,v) acc = if Data.Maybe.isNothing kv then Data.Map.insert k [v] acc else Data.Map.insert k (v:Data.Maybe.fromJust kv) acc
where kv = Data.Map.lookup k acc
fromListToMapList :: Ord k => [(k, a)] -> Data.Map.Map k [a]
fromListToMapList = foldr listInsert Data.Map.empty
@bmcorser
bmcorser / addresses.sls
Created July 10, 2014 08:08
pip install state
install_addresses:
pip.install:
- pkgs:
- /opt/addresses/
- bin_env: {{ paths.virtualenv_shared }}
- force_reinstall: True
- require:
- file: addresses_setup
@bmcorser
bmcorser / gist:6e76fb36a36971714229
Last active August 29, 2015 14:03
salt dot-dot
# /database/init.sls
include:
- ..install
# /database/install.sls
my_database:
pkg:
- installed