Skip to content

Instantly share code, notes, and snippets.

@dvdbng
dvdbng / github_pr_notifications.user.js
Last active August 18, 2016 14:34
An userscript that shows a desktop notification when the status of a github PR changes
// ==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(){
@dvdbng
dvdbng / list_bucket.py
Created August 22, 2016 09:48
List bucket skipping over some directories
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)
@dvdbng
dvdbng / open_pr_link.user.js
Created December 23, 2016 00:49
Github user script: Show a open PR link when an issue has label "3 - code review"
@dvdbng
dvdbng / deep_intersection.js
Created January 12, 2017 01:38
CoffeeScript deep object intersection
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)
@dvdbng
dvdbng / deep_intersection.coffee
Created January 12, 2017 01:39
CoffeeScript deep object intersection
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)
@dvdbng
dvdbng / scrapy_spider.py
Created April 20, 2016 07:53
Use scrapy and splash in the same process
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
@dvdbng
dvdbng / bench_pg_array.py
Created February 9, 2017 22:11 — forked from xflr6/bench_pg_array.py
Benchmark PostgreSQL array vs. join performance
# 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()"
@dvdbng
dvdbng / pg_dump
Created December 6, 2016 21:56
rails rake db:migrate pg_dump docker
#!/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
@dvdbng
dvdbng / keybase.md
Created September 25, 2018 15:00
keybase.md

Keybase proof

I hereby claim:

  • I am dvdbng on github.
  • I am bengoa (https://keybase.io/bengoa) on keybase.
  • I have a public key whose fingerprint is 96A5 554D 451B 813E 0642 F48B 8C88 3382 7C5F 60F4

To claim this, I am signing this object:

#!/usr/bin/env python3
"""
Usage: subscene-dl <subscene url> > file.srt
Example:
subscene-dl https://subscene.com/subtitles/mr-mercedes-second-season/english/1864622 > Mr.Mercedes.S02E09.WEBRip.x264-ION10.srt
"""
from lxml import html
import requests