Skip to content

Instantly share code, notes, and snippets.

#!/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
@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:

@dvdbng
dvdbng / download.js
Last active November 27, 2018 13:13
Download page DOM with CSS and images
/*
Note: Due to CORS, this only works in chromium with disabled web security.
Start chrome like this: chromium-browser --disable-web-security --user-data-dir=/tmp/chrometmp
Load the page you want and paste the script in the web console.
This will save a snapshoot of the DOM and inline all CSS and images so that usually the page will
look exactly the same, but there is no javascript in the page.
Note that the generated file can be large in size, because the same URL might be inlined more than once.
*/
var CSS_IMPORT = /@import\s*["']([^"']+)["']/g
@dvdbng
dvdbng / main.py
Created July 13, 2018 15:18
Coinbase pro DCA with limit orders
import requests
import os
import time
import base64
import hmac
import hashlib
from decimal import Decimal, getcontext
API_URL = 'https://api.pro.coinbase.com'
@dvdbng
dvdbng / vim-heroku.sh
Last active April 22, 2024 22:42
Run vim in heroku updated 2017
mkdir ~/vim
cd ~/vim
# Staically linked vim version compiled from https://github.com/ericpruitt/static-vim
# Compiled on Jul 20 2017
curl 'https://s3.amazonaws.com/bengoa/vim-static.tar.gz' | tar -xz
export VIMRUNTIME="$HOME/vim/runtime"
export PATH="$HOME/vim:$PATH"
cd -
@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 / 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 / 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 / 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 / zsh_to_fish.py
Created December 21, 2016 18:02
Migrate zsh history to fish
import os
import re
def zsh_to_fish(cmd):
return (cmd.replace('&&', '; and ')
.replace('||', '; or '))
def is_valid_fish(cmd):