This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# rake db:migrate tries to connect to dump local postgres using pg_dump but | |
# you are using a docker instance? try saving this script as pg_dump somewhere | |
# in your PATH with higher priority | |
orig_params="$@" | |
volmount="" | |
while [[ $# -gt 1 ]] | |
do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fast_list_keys(bucket, prefix="", ignore_dirs=()): | |
""" | |
Like boto.s3.bucket.list but skip over directories named in ignore_dirs | |
""" | |
marker = "" | |
more_results = True | |
ignore_dirs = set(ignore_dirs) | |
keys = [] | |
while more_results: | |
rs = bucket.get_all_keys(prefix=prefix, marker=marker) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name PR Notifications | |
// @namespace ghnotifications | |
// @description Show notifications when the status of a PR changes | |
// @include https://github.com/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
(function(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import Counter | |
import heapq | |
class SummaryDict(Counter): | |
""" | |
A counting dict that aggregates uncommon values in a "Others" key. | |
The full set of keys is kept in a separate counter, in case they need to | |
be added back to the main counter. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scrapy | |
from scrapy.crawler import CrawlerRunner | |
from scrapy.settings import Settings | |
from scrapy.http import TextResponse | |
from twisted.internet import defer | |
from splash.browser_tab import BrowserTab | |
from splash.render_options import RenderOptions | |
from splash import defaults | |
import random |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Levenshtein distance between two arrays or strings | |
*/ | |
function arrDistance(a, b) { | |
if(a.length === 0) { return b.length; } | |
if(b.length === 0) { return a.length; } | |
var matrix = []; | |
// increment along the first column of each row |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Download every episode of How It's Made from Youtube | |
# Needs: youtube-dl | |
urlencode() { | |
python -c "import sys, urllib; print urllib.quote_plus(sys.stdin.read())" | |
} | |
dl(){ | |
q=`echo How its made $2 $3 $4 | urlencode` | |
youtube-dl --max-downloads=1 -o "HowItsMade_${1}_%(title)s_%(format)s.%(ext)s" "https://www.youtube.com/results?search_query=$q" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function queryXPath(expr, ctx, type){ | |
ctx = ctx || document; | |
type = type || XPathResult.ANY_TYPE; | |
var doc = ctx.nodeType === Node.DOCUMENT_NODE ? ctx : ctx.ownerDocument; | |
var nsResolver = doc.createNSResolver(doc.documentElement); | |
var arr = [], i = null; | |
try { | |
expr = ("" + expr).replace(/\bhasClass\(["'](\w+)["']\)/, function(expr, className){ | |
return "contains(concat(' ', normalize-space(@class), ' '), ' " + className + " ')"; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- x-FOO-bAr -> X-Foo-Bar | |
function normalize_header(name) | |
name = upper(sub(name, 1, 1)) .. lower(sub(name, 2)) | |
while true do | |
local start,fin = find(name, '-[a-z]') | |
if start ~= nil then | |
name = sub(name, 1, start) .. upper(sub(name, fin, fin)) .. sub(name, fin+1) | |
else | |
break | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function(){ | |
function makeStorage(){ | |
var keys = []; | |
var storage = Object.create(Object, { | |
getItem: {value: function(k) { | |
if(this.hasOwnProperty(k)) { | |
return this[k]; | |
} | |
}}, |