Skip to content

Instantly share code, notes, and snippets.

View mwicat's full-sized avatar

Marek Wiewiorski mwicat

View GitHub Profile
#!/bin/bash
gen_diffs.py ~/work $1 ~/patche
#!/usr/bin/env python
import sqlparse
import sys
s = sys.stdin.read()
print sqlparse.format(s, reindent=True, keyword_case='upper')
#!/bin/bash
dbhost=localhost
dbname=stats
while getopts h:d: name; do
case "$name" in
h) dbhost="$OPTARG";;
esac
done
for d in */; do
d="${d%%/}"
cat > $d/.project <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>$d</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
import time
import midi
import midi.sequencer as sequencer
def play(seq, notes):
for event in notes:
buf = seq.event_write(event, tick=True)
if buf is not None and buf < 1000:
time.sleep(.5)
#!/bin/bash
python -c "import sys, json; print json.dumps(json.load(sys.stdin), indent=4)" < "$1" | sponge "$1"
#!/usr/bin/env python
import pickle, sys
x = sys.stdin.read().strip()
print pickle.loads(x)
from pyparsing import *
import music21 as m21
import string
name = Word(string.printable.replace(':', ''))
control_name = oneOf('o d b')
control_value = Word(nums).setParseAction(lambda x: int(x[0]))
control_pair = Group(control_name + Suppress('=') + control_value + Suppress(Optional(',')))
control_section = OneOrMore(control_pair)
@mwicat
mwicat / flask_sse.py
Last active January 2, 2016 16:48
Flask push Sever Sent Events
import redis
import flask
app = flask.Flask(__name__)
@app.route('/stream')
def stream():
red = redis.Redis()
pubsub = red.pubsub()
pubsub.subscribe('chat')
import alsaseq
import alsamidi
alsaseq.client( 'marek', 0, 1, True )
alsaseq.connectto( 0, 129, 0 )
alsaseq.start()
alsaseq.output(alsamidi.noteonevent(0, 60, 64))