Skip to content

Instantly share code, notes, and snippets.

@grejppi
grejppi / 99b.jl
Last active December 19, 2015 17:38
"99 Bottles of Beer" in Julia
bottles(n) = "$n bottle" * "s"^(n != 1 ? 1 : 0) * " of beer"
song(n) = "
$(bottles(n)) on the wall,
$(bottles(n)),
" * (n > 0 ? "Take one down, pass it around,
$(bottles(n-1)) on the wall.
$(song(n-1))" : "Go to the store and buy some more,
$(bottles(99)) on the wall.
")
println(song(99))
@grejppi
grejppi / 99b2.jl
Last active December 19, 2015 17:48
Another "99 Bottles of Beer" in Julia
a(s)="$(uppercase(s[1]))$(s[2:])";b(n)=["one","two","three","four","five","six","seven","eight","nine","ten"][n];c(n)=["","Twen","Thir","For","Fif","Six","Seven","Eigh","Nine"][n]*((n!=1)?"ty":"");d(n)=["Eleven","Twelve","Thir","Four","Fif","Six","Seven","Eigh","Nine"][n]*((n>2)?"teen":"");e(n)=(0<n<11)?a(b(n)):((n==0)?"No more":((n>19)?"$(c(floor(n/10)))"*((%(n,10)==0)?"":"-$(b(%(n,10)))"):("$(d(n-10))")));f(n)="$(e(n)) bottle"*"s"^(n!=1?1:0)*" of beer";g(n)="\n$(f(n)) on the wall,\n$(f(n)),\n"*(n>0?"Take one down, pass it around,\n$(f(n-1)) on the wall.\n$(g(n-1))":"Go to the store and buy some more,\n$(f(99)) on the wall.\n");println(g(99))
@grejppi
grejppi / glitch.sh
Last active December 20, 2015 02:09
Some sort of glitch effect. Sounds good on vocals especially. Requires sox.
play "$1" pitch -1200 speed 2 pitch 2400 speed 0.25 speed 4 pitch -2400
#!/usr/bin/env python3
import cherrypy
import random
class Root(object):
def index(self):
cherrypy.response.headers['Content-Type'] = 'text/plain'
def noise():
while True:
# Check out <https://github.com/grejppi/wmcv> for a newer version!
from __future__ import (division, print_function)
import sys
# yeah...
if int(sys.version[0]) >= 3:
import os
os.system('python2 {0}'.format(__file__))
sys.exit()
#!/bin/sh
svn checkout http://lv2plug.in/repo/trunk lv2-svn
cd lv2-svn
./waf configure
./waf
sudo ./waf install
cd ..
svn co http://svn.drobilla.net/lad/trunk drobilla-lad
LOWPASS:
cutoff = 2.1 + (4000.0 * wub * wub)
resonance = 0.3 * wub
HIGHPASS:
cutoff = 0.1 + 2000.0 - (1000.0 * wub)
resonance = 0.5 * wub * wub
@grejppi
grejppi / 99b.py
Last active January 4, 2016 01:09
99 Bottles of Beer oneliner
print('\n'.join(((lambda i:(lambda v:v[0].capitalize()+v[1:])(', {1}\n{0}, {2} '.join(('on the wall',)*2).join(('{1} ','.\n')).format('Take one down, pass it around' if i!=0 else 'Go to the store and buy some more',*('{0} bottle{1} of beer'.format((str.replace if s in range(11,20) else lambda a,b,c:a)(*('}{'.join((str(w) for w in l)).join(('{','}')) for l in ((0,1,2,3,),)*2+((3,1),))).format((('',)*2+('twen','thir','for','fif','six','seven','eigh','nine'))[(s-(s%10))//10],'' if s<13 else 't'+('y' if s>19 else 'een'),'ten' if s==10 else ('-' if s%10!=0 and s>10 else ''),('','one' if s!=11 else 'eleven','tw'+('o' if s!=12 else 'elve'),'th'+('ree' if s!=13 else 'ir'),'four','fi'+('ve' if s!=15 else 'f'),'six','seven','eigh'+('t' if s!=18 else ''),'nine')[s%10] if s!=0 else 'zero'),'s' if s!=1 else '') for s in (i%100,(i-1)%100)))))(i) for i in reversed(range(100)))))
@grejppi
grejppi / 99b2.py
Created January 28, 2014 16:28
Yet another 99 Bottles of Beer
print((lambda a,b,c:'\n'.join([a('\n'.join([' on the wall, '.join([b(0)]*2),'{0}, {1} on the wall.\n']).format('Take one down and pass it around' if n else 'Go to the store and buy some more', b(2).format()).format(*sum([[c(nn%100),'s' if nn!=1 else ''] for nn in (n,n-1)],[]))) for n in reversed(range(100))]))(lambda s: s[0].upper()+s[1:], lambda n:'{{n}} bottle{{s}} of beer'.replace('n',str(n)).replace('s',str(n+1)),lambda n:('-'.join if not False in (n%10, n>19) else lambda no:no[0 if n>19 else 1])([(lambda e,nn:['ten' if n==10 else 'no more','one' if n!=11 else 'eleven','tw'+('o' if n!=12 and e else ('e'+('lve' if n==12 else 'n'))),'th'+('ree' if n!=13 and e else 'ir'),'fo'+('u' if e else '')+'r','fi'+('ve' if n!=15 and e else 'f'),'six','seven','eigh'+('t' if n!=18 and e else ''),'nine'][nn]+(('ty' if n>19 else '') if not e else ('teen' if 20>n>12 else '')))(*e) for e in enumerate(((n-(n%10))//10,n%10))])))
@grejppi
grejppi / kb.py
Last active January 4, 2016 20:29
Implementation for the new programming language 'Keybash'
#!/usr/bin/env python3
import argparse
import os
import keybash
ap = argparse.ArgumentParser(description='Brainfuck/Keybash translator')
ap.add_argument('file')