Skip to content

Instantly share code, notes, and snippets.

@dvdbng
dvdbng / vim-heroku.sh
Last active October 16, 2024 17:15
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 / 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 / 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 / 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
@dvdbng
dvdbng / vlc-speed-sub.py
Created October 20, 2018 22:18
VLC: Set a different playback speed for dialog and not-dialog scenes (using subtitles)
#!/usr/bin/env python3
# This changes the playback speed to a different speed when there is and when there isn't subtitles.
# You need to activate the Lua HTTP interface in VLC and
# configure the password here, then run the script with a .srt as first argument.
# Ended up not being very nice because VLC janks for a few milliseconds when the playback speed changes
import requests
import pysrt
import sys
@dvdbng
dvdbng / merge_subtitles.py
Created November 15, 2019 18:31
Merge two or more subtitles
#!/usr/bin/python3
"""
LPT: If your original subtitles are not .srt, convert them using ffmpeg
"""
import sys
import pysrt
def merge_subtitles(srts):
@dvdbng
dvdbng / pinyin-subtitles.py
Created November 15, 2019 18:56
Convert chinese subtitle to chinese + pinyin (Output is like this: 最zùi高gāo法fǎ院yuàn在zài今jīn天tiān早zǎo上shàng)
#!/usr/bin/python3
import sys
import re
import pysrt
import pinyin
def to_pinyin(text):
pinyins = pinyin.get(text, delimiter=" ").split(' ')
#!/bin/bash
cat /etc/dictionaries-common/words | grep -P '^[a-z]{1,10}$' | shuf -n 4 | tr '\n' '-' | sed 's/-$/\n/'
#!/bin/bash
# Usage: ./btc-balance address
satoshis="$(curl https://insight.bitpay.com/api/addr/"$1"/balance)"
btc="$(echo "$satoshis/100000000" | bc -l)"
echo $btc