Skip to content

Instantly share code, notes, and snippets.

@wting
wting / nyan.sh
Last active March 5, 2024 00:45
Nyan cat in bash shell.
#!/usr/bin/env bash
NYAN=('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbmbbbbbbbbbbbbbbbbbbbbbbbbbbb'
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbmbmbbbbbbbbbbbbbbbbbbbbbbbbbb'
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbmbbbbbbbbbbbbbbbbbbbbbbbbbbb'
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbmb'
@wting
wting / dreamhost_python_setup.sh
Created May 31, 2012 00:16
Dreamhost Python Setup script
#!/usr/bin/env bash
# Written by William Ting for the following blog post:
# http://williamting.com/posts/2012/04/18/set-up-python-and-django-on-dreamhost/
rcfile="${HOME}/.bashrc"
version="2.7.3"
setuptools_version="2.7"
tmp_dir="${HOME}/tmp-${RANDOM}"
if [[ ${#} == 0 ]]; then
@wting
wting / haskell.md
Last active April 1, 2020 10:50
Installing ghc, haskell-platform, cabal-install on Ubuntu 12.04.

Choices

  1. Install ghc 7.6.3 and Haskell Platform
  2. Install ghc 7.8.4 and Cabal

Option GHC 7.6.3 + Haskell Platform

GHC 7.6.3

Install Ubuntu 12.04 depencies:

@wting
wting / pfd.zsh
Created October 3, 2018 02:58
Open up all definitions of a Python class or function as vim tabs.
#!/usr/bin/env zsh
local args name num
if git rev-parse --git-dir &>/dev/null; then
git grep -En "(def|class) ${@}[[:space:]]*[(:]" \
| uniq \
| while read line; do
name=$(echo "${line}" | awk 'BEGIN { FS=":" }; { print $1 }')
num=$(echo "${line}" | awk 'BEGIN { FS=":" }; { print $2 }')
@wting
wting / punk.py
Last active April 12, 2017 21:01 — forked from briandeheus/punk.py
Don't be a punk, punk
import binascii
import struct
class Punk(object):
"""Full blog post about hiding data within PNG files here:
http://blog.brian.jp/python/png/2016/07/07/file-fun-with-pyhon.html
Example use case:
@wting
wting / die_hard.py
Last active April 7, 2017 00:16 — forked from nathants/die-hard.py
from hypothesis import given, settings
from hypothesis.strategies import lists, sampled_from
def new_state():
return {'big': 0, 'small': 0}
def invariants(state):
return (0 <= state['small'] <= 3 and
0 <= state['big'] <= 5)
@wting
wting / disassembled.md
Last active November 17, 2016 12:21
Test Python intersection speeds.
In [4]: dis.dis(try0)
 19           0 LOAD_GLOBAL              0 (set)
              3 LOAD_FAST                0 (x)
              6 LOAD_ATTR                1 (keys)
              9 CALL_FUNCTION            0
             12 CALL_FUNCTION            1
             15 LOAD_ATTR                2 (intersection)
             18 LOAD_FAST                1 (y)
             21 LOAD_ATTR                1 (keys)
@wting
wting / tail_call_optimization.py
Last active October 1, 2016 02:38
Tail call optimization decorator, from https://code.activestate.com/recipes/474088/
#!/usr/bin/env python2
# This program shows off a python decorator(
# which implements tail call optimization. It
# does this by throwing an exception if it is
# it's own grandparent, and catching such
# exceptions to recall the stack.
import sys
class TailRecurseException:

Keybase proof

I hereby claim:

  • I am wting on github.
  • I am wting (https://keybase.io/wting) on keybase.
  • I have a public key whose fingerprint is 677D 5827 5462 6086 8DC8 7AEC 6391 002C 8D7D FCE5

To claim this, I am signing this object:

@wting
wting / taps.sh
Created January 4, 2014 22:44
Play Taps using PC speaker.
G4='-f 392.00'
C5='-f 523.25'
E5='-f 659.26'
G5='-f 783.99'
whole='-l 2048'
dottedhalf='-l 1536'
half='-l 1024'
dottedquarter='-l 768'
quarter='-l 512'