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
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
// ==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
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
#!/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
import os | |
import re | |
def zsh_to_fish(cmd): | |
return (cmd.replace('&&', '; and ') | |
.replace('||', '; or ')) | |
def is_valid_fish(cmd): |
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 Open PR Link | |
// @namespace ghprlink | |
// @description Show a open PR link when an issue has label "3 - code review" | |
// @include https://github.com/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
function addOpenPRLinks(){ |
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
intersection = (lst) -> | |
types = lst.map((x)-> typeof x) | |
if types.some((t) -> t != types[0]) | |
return null | |
switch types[0] | |
when "object" | |
res = {} | |
Object.keys(lst[0]).forEach (k) -> | |
if lst.every((o) -> k of o) |
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
intersection = (lst) -> | |
types = lst.map((x)-> typeof x) | |
if types.some((t) -> t != types[0]) | |
return null | |
switch types[0] | |
when "object" | |
res = {} | |
Object.keys(lst[0]).forEach (k) -> | |
if lst.every((o) -> k of o) |
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
# bench_pg_array.py - benchmark postgresql array vs. join performance | |
""" | |
Replicate http://shon.github.io/2015/12/21/postgres_array_performance.html | |
with proper join table indexes (uniqueness constraints) using sqlalchemy. | |
$ python -i bench_pg_array.py | |
>>> setup() | |
$ python -m timeit -s "import bench_pg_array" "bench_pg_array.test_join()" |