Skip to content

Instantly share code, notes, and snippets.

@redraw
redraw / osc-cli.py
Created February 20, 2016 07:37
pyOSC wrapper to send OSC messages from the terminal
#!/usr/bin/env python
from OSC import OSCClient, OSCMessage
import argparse
class Client:
"""pyOSC Client Wrapper"""
def __init__(self, host=None, port=None):
@redraw
redraw / jsonloads.sh
Created July 13, 2016 22:53
pipe json string from stdin into ipython
function jsonloads {
python -c 'import json,sys,IPython; stdin=sys.stdin.read(); sys.stdin=open("/dev/tty"); data=json.loads(stdin); IPython.embed(header="JSON loaded in \"data\" object.")'
}
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab
colorscheme elflord

Keybase proof

I hereby claim:

  • I am redraw on github.
  • I am redraw (https://keybase.io/redraw) on keybase.
  • I have a public key ASADoWlD0YrjxIDz9UlS7xsACs6-dkYD7Xo5RRleA6VonQo

To claim this, I am signing this object:

@redraw
redraw / sqlf.py
Last active September 24, 2019 17:52
Custom IPython magic to format SQL
""" ~/.ipython/profile_default/startup/00-sqlf.py
Requires sqlparse (`pip install sqlparse`)
Example:
In [1]: %sqlf Site.objects.all().query
SELECT `django_site`.`id`,
`django_site`.`domain`,
`django_site`.`name`
FROM `django_site`
ORDER BY `django_site`.`domain` ASC
getCurrentPosition(opts) {
return new Promise(function (resolve, reject) {
if ("geolocation" in navigator) {
navigator.geolocation.getCurrentPosition(resolve, reject, opts);
} else {
reject("Browser not supported")
}
});
}
crunch 10 10 -t 004%%%%%%% -s 0042000000 -e 0048000000
crunch 10 10 -t 014%%%%%%% -s 0142000000 -e 0148000000
@redraw
redraw / .bashrc
Last active August 25, 2018 16:36
# ...
if (which fortune && which cowsay) &>/dev/null; then
fortune -s | cowsay -f "$(ls /usr/share/cowsay/cows | shuf | head -n1 | cut -d. -f1)"
fi
@redraw
redraw / ffmpeg-overlay.sh
Created August 25, 2018 16:34
ffmpeg command to overlay a video (centered) over a background image
ffmpeg -i bg.jpg -i video.mp4 -filter_complex "[1]scale=-1:300[vid]; [0]scale=1200:720[img]; [img][vid] overlay=(W-w)/2:(H-h)/2" -acodec copy -preset ultrafast test.mp4
@redraw
redraw / cjdns.sh
Last active September 15, 2018 16:58
cjdns debian-based distributions installer - https://bit.ly/cjdns-debian-install
#!/bin/bash
function log { echo -e "\e[1;34m> ${1}\e[0m"; }
[[ -d ~/cjdns ]] && log 'already installed!' && exit 0
log 'installing inside ~/cjdns'
git clone https://github.com/cjdelisle/cjdns.git ~/cjdns
cd ~/cjdns/
log 'compiling...'