Skip to content

Instantly share code, notes, and snippets.

@simon-weber
simon-weber / example.js
Created November 22, 2016 22:39
lovefield query/index/order bug example
document.write = function (s) {
// jsfiddle doesn't allow document.write.
document.body.insertAdjacentHTML("beforeend", s);
}
const schemaBuilder = lf.schema.create('schema', 1);
schemaBuilder.createTable('Item').
addColumn('id', lf.Type.INTEGER).
addColumn('num', lf.Type.STRING).
addPrimaryKey(['id']).
#!/usr/bin/env bash
# executables prefix
_prefix="/usr/bin"
# git executable
_git="$_prefix/git"
# branch from which to generate site
_origbranch="source"
# branch holding the generated site
@simon-weber
simon-weber / checkout-dates.sh
Created April 27, 2013 22:19
Checks out my entire sample source tree (for https://github.com/simon-weber/Predicting-Code-Popularity) to a certain date, in parallel. The argument to -P is the number of processes to use.
find /localdisk/winter-snapshot/code/ -mindepth 2 -maxdepth 2 | xargs -P 32 -n 1 -I {} bash -c 'cd $1; git checkout -q $(git rev-list -n 1 --before="2012-11-30" $(git rev-parse --abbrev-ref HEAD)) -- || pwd' -s {} 2>&1 | tee outputfile
@simon-weber
simon-weber / proboscis_after_class_bug.py
Created February 28, 2013 04:21
Reproduce a bug in proboscis.after_class.
from proboscis import test, after_class, TestProgram
@test
class Test(object):
@after_class
def will_skip_but_should_not(self):
pass
@test
@simon-weber
simon-weber / muspy2gcal.py
Created February 16, 2013 19:37
A dirty little script that will make Google Calendar events for muspy releases. Fill in 'XXXXX' with the relevant values.
import os.path
import requests
#Google client api imports
import gflags
import httplib2
from apiclient.discovery import build
from oauth2client.file import Storage
from oauth2client.client import OAuth2WebServerFlow
@simon-weber
simon-weber / gist:4960475
Created February 15, 2013 13:47
old gmusicapi code to do a generic metadata copy between audio files
import logging
import mutagen
log = logging.getLogger(__name__)
def copy_md_tags(from_fname, to_fname):
"""Copy all metadata from *from_fname* to *to_fname* and write.
@simon-weber
simon-weber / makefile
Last active October 11, 2015 17:37
makefile for a sparse parallel kernel source tree
KERNEL_MAKE_ARGS =
KERNEL_DIR = ../linux-2.6.26.5
# this isn't actually a list
DO_NOT_COPY = makefile
all: rm_moved_files src_copy
.FORCE:
@simon-weber
simon-weber / gist:1361260
Created November 12, 2011 23:02
Rails: for 'a belongs_to b', a.b.id != a.b_id
irb(main):010:0> t = Tag.new(:rfid => 999, :item_id => 1)
=> #<Tag id: nil, rfid: 999, created_at: nil, updated_at: nil, item_id: 1>
irb(main):011:0> t.item
=> #<Item id: 1, description: "burger", price: #<BigDecimal:b6f6f46c,'0.5E1',4(8)>, created_at: "2011-11-12 03:16:19", updated_at: "2011-11-12 03:16:19">
irb(main):012:0> t.item_id = 2
=> 2
irb(main):013:0> t.save
@simon-weber
simon-weber / pre-commit.sh
Created July 29, 2015 19:47
venmo linting pre-commit
#!/bin/sh
GITROOT=`git rev-parse --show-toplevel`
EXIT_STATUS=0
# Lint all the files in the index, excluding deletions and directories.
git diff-index -z --cached --name-only --diff-filter='ACMRTUXB' HEAD | xargs -0 ls -dp | grep -v '/$' | xargs "$GITROOT/lint"
if [ "$?" != "0" ]; then
@simon-weber
simon-weber / lint.sh
Created July 29, 2015 15:25
toplevel venmo linting script
#!/usr/bin/env bash
# Usage:
#
# lint [file1] [file2]...
#
# With no arguments, lint any tracked files with modifications.
# Get venmolint.py into the path so that git-lint detects it.