Skip to content

Instantly share code, notes, and snippets.

Zack Dever zackdever

Block or report user

Report or block zackdever

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@zackdever
zackdever / gist:dce4edd205ea12db89124a411859f329
Created Sep 12, 2016
racey results from clojure.core.memoize
View gist:dce4edd205ea12db89124a411859f329
(require '[clojure.core.memoize :as memo])
(defn calc [x] x)
(def memo-calc (memo/ttl calc {} :ttl/threshold 13))
(filter #(not= "ok" %)
(for [x (range 100000)]
(if (nil? (memo-calc "abc"))
(println "Result was nil!")
@zackdever
zackdever / unmsgpack.py
Last active Aug 29, 2015
unpack msgpack from stdin and print until stopped
View unmsgpack.py
#!/usr/bin/env python
import msgpack
import sys
try:
while True:
line = sys.stdin.readline().strip('\n')
try:
print msgpack.unpackb(line)
@zackdever
zackdever / gist:8701478
Created Jan 30, 2014
arc diff off another diff
View gist:8701478
taken directly from https://sites.google.com/a/khanacademy.org/forge/for-developers/code-review-policy/using-phabricator
Advanced topic: Dependent Phabricator reviews
Say you have an upstream called master, and a feature branch F1, and a second change that depends on F1, (call it F2).
git checkout master
git checkout -b F1
# work work
git commit -a
arc diff
View d3-paths.js
function r() {
return Math.random() * 100;
}
var lineData = function() {
return [
[0, r()],
[20, r()],
[40, r()],
[60, r()],
@zackdever
zackdever / html2csv.js
Created Apr 26, 2013
converts an html table to a csv string, and makes it available as a file download
View html2csv.js
function convertTableToCsv(tableSelector) {
return _.map($(tableSelector + ' tr'), function(row) {
return _.map($(row).find('th, td'), function(datum) {
return datum.textContent.replace(/,/g, '');
}).join(',');
}).join('\n');
}
// to download
var data = convertTableToCsv('#mytable');
View debug_dict.py
def debug_dict(self, debug_message, data_dict):
import logging
info = '%s\n' % debug_message
for k, v in sorted(data_dict.iteritems()):
info += '%s: %s\n' % (k, v)
logging.debug(info)
@zackdever
zackdever / gist:5051462
Created Feb 27, 2013
make room for large numbers in nvd3.js charts
View gist:5051462
// http://stackoverflow.com/a/13472375/962091
// may also need to make room on the chart itself, maybe something like:
// chart.margin({left: 10});
d3.select('.nv-y.nv-axis > g').selectAll('g');
@zackdever
zackdever / alias
Created Feb 21, 2013
when creating an arc paste (http://www.phabricator.com/docs/phabricator/article/Arcanist_User_Guide.html), automatically copy the address to the cilpboard on os x
View alias
alias arcpaste='arc paste | copyarcpaste'
@zackdever
zackdever / imageFader.js
Created Oct 18, 2012
simple JavaScript image fader
View imageFader.js
var bgImgs = [
'/images/foo.png'
, '/images/bar.png'
, '/images/foobar.png'
];
$(function () {
if (bgImgs.length > 1) {
var bgImage = $('#bgImage')
, index = 0
You can’t perform that action at this time.