Skip to content

Instantly share code, notes, and snippets.

View sjl's full-sized avatar

Steve Losh sjl

View GitHub Profile
@sjl
sjl / gist:5339563
Created April 8, 2013 19:10
things git checkout can do
* update your working directory's parent to a given branch (and update the files)
* create a new branch (and switch to it)
* update the contents of files to reflect their contents at a given cset
* update the contents of files to reflect their contents in the index
* resolve merge conflicts with `--ours` and `--theirs`
var empty_list = function(selector) {
return selector(undefined, undefined, true);
};
var prepend = function(el, list) {
return function(selector) {
return selector(el, list, false);
};
};
var head = function(list) {
@sjl
sjl / gist:5083042
Last active December 14, 2015 11:59
hmm ok maybe I should bisect this bug
let's see if this has always happened
$ git checkout some-old-rev
nope it used to be good ok let's bisect
$ git bisect good
already bisecting
@sjl
sjl / gist:5032048
Last active December 14, 2015 04:59

OK, so here's the deal. We need to:

  1. Re-run the tern migrations with the updated Babelsubs to perform the migrations with all the latest bugs fixed.

  2. Provide partners with a stable staging server to test the DMR on.

  3. Provide ourselves with a place to deploy changesets before they get to the stable staging server.

We use to stick into the SubtitleVersion.note strings such as "Rollback from version#" or "Uploaded" automatically. This was handy, because when looking at the review list, you could see that info. Helps debugging but also teams / users to grok what's going on.

However, it does have it's problems: no i18n / hard to customize messages, etc. For rollbacks,it's easy: since we already store the rollback_from_version_number, we can just check that and display that info.

I see the following alternatives: a) Stick it back into the SubtitleVersion.note field, with the issues raised above

b) Create a boolean ("from_upload") Keeps notes clean, easily 18n and customizable. However... (see bellow)

@sjl
sjl / 1.markdown
Last active December 12, 2015 12:19

The problem:

email as username

If there's a "username" field in the HTML form, it's probably the username.

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+

When there's an error in the ns form I get just a bare filename from lein compile:

[1] ><((ˣ> lein compile dram.core
Compiling dram.core
Exception in thread "main" java.lang.IllegalAccessError: cats does not exist, compiling:(core.clj:1)

When the ns form is okay but there's an error in the file, I get the path from the src folder:

[1] ><((ˣ> lein compile dram.core

Compiling dram.core

(defmacro multi-update
[m & update-forms]
`(-> ~m ~@(map #(cons 'update-in %) update-forms)))
(multi-update {:a 10 :b 20 :c 30}
([:a] + 1)
([:b] + 1 1)
([:c] + 1 2))
; {:a 11 :b 22 :c 33}
; Integers and Longs are equal.
(= (Integer. 1) (Long. 1))
true
; Even negative ones.
(= (Integer. -1) (Long. -1))
true
; When you use them as keys in maps, the maps are still equal.
(= {(Integer. 1) :foo} {(Long. 1) :foo})