Skip to content

Instantly share code, notes, and snippets.

View sjl's full-sized avatar

Steve Losh sjl

View GitHub Profile
@sjl
sjl / which is best? .py
Created November 16, 2009 20:16 — forked from inky/which is best? .py
They're completely different.
>>> x = '0123456789'
>>> a, b = [{} for _ in x], [{}] * len(x)
>>> a[0]['test'], b[0]['test'] = 1, 1
>>> p(a)
[{'test': 1}, {}, {}, {}, {}, {}, {}, {}, {}, {}]
>>> p(b)
# Discard local changes
git checkout -f (git co -f)
# This will change the current parent revision if you're not at a branch tip.
# The fact that it discards local changes is just a side effect.
hg update --clean (hg co -C)
# What you really want is the command *designed* to throw away changes: revert.
hg revert --all [--no-backup] (hg rev -a)
@sjl
sjl / .cdg.sh
Created April 29, 2010 16:57 — forked from bobthecow/cdg.bash
A function to cd to the root of the current Mercurial repository.
#!/usr/bin/env bash
# cd to the root of the current Mercurial repo
#
# usage:
# Add the following function to your `.bashrc` or `.bash_profile` file,
# or save it somewhere (i.e. `~/.cdg.sh`) and source it in `.bashrc`
cdh () {
hg root >/dev/null && cd "`hg root`"
#!/bin/bash
# Plant rope vim's plugin
# This is a script to install or update 'ropevim'
# Copyright Alexander Artemenko, 2008
# Contact me at svetlyak.40wt at gmail com
function create_dirs
{
mkdir -p src
@sjl
sjl / jquerytest.cljs
Created July 21, 2011 14:05 — forked from ryancrum/jquerytest.cljs
How to use jQuery from ClojureScript
(ns jquerytest.core)
(def jquery (js* "$"))
; Can you not use the short form?
(jquery
(fn []
(-> (jquery "div.meat")
(.html "This is a test.")
(.append "<div>Look here!</div>"))))
@sjl
sjl / gist:1296686
Created October 18, 2011 20:50 — forked from aduston/gist:1296656
unisubs.streamer.StreamBox.prototype.transcriptScrolled_ = function(e) {
if (this.videoScrolling_) {
this.videoScrolling_ = false;
} else {
this.showResyncButton_(true);
this.ignoreVideoScrolling_ = true;
}
};
unisubs.streamer.StreamBox.prototype.scrollIntoView_ = function(streamSub) {
@sjl
sjl / ui.cljs
Created February 7, 2012 15:27 — forked from srid/ui.cljs
ClojureScript - prependChild implementation using Google Closure
(defn ^:export prependChild
[parent node]
(dom/insertChildAt parent node 0))
@sjl
sjl / fib.js
Created May 4, 2012 00:25 — forked from ry/fib.js
(fixed) a proper fibonacci server in node. it will light up all your cores.
var http = require('http')
var fork = require('child_process').fork;
function fib(n) {
if (n < 2) {
return 1;
} else {
return fib(n - 2) + fib(n - 1);
}
}
@sjl
sjl / defrec.clj
Created September 19, 2012 16:20 — forked from cemerick/gist:3750288
defrec, rhymes with vec, because you can nth it
(defmacro defrec [name args & body]
(let [indexed-args (interleave (iterate inc 0) args)]
`(defrecord ~name ~args
clojure.lang.Indexed
(nth [_# i#]
(case i#
~@indexed-args
(throw (IndexOutOfBoundsException.))))
(nth [_# i# default#]
(case i#
ehazlett sjl: hey have a sec?
sjl ehazlett: sure
ehazlett sjl: i'm trying to migrate the old testdata instance to the latest production
sjl ok
ehazlett sjl: when i try to migrate i'm getting the "ghost migrations" error
sjl fun
ehazlett sjl: http://d.pr/i/k7N
ehazlett sjl: sorry for the terrible formatting
sjl ehazlett: what exactly are you trying to do again?
sjl the production branch doesn't have team migrations 16+