Skip to content

Instantly share code, notes, and snippets.

View skyl's full-sized avatar

Skylar Saveland skyl

View GitHub Profile
@skyl
skyl / timing_beat.py
Created May 6, 2012 23:50
bl timingarp branch review
import random
import operator
from itertools import permutations
from bl.scheduler import clock, Tempo # , Meter
from bl.arp import RandomArp, OrderedArp, ScheduleArp # , ArpSwitcher
from bl.orchestra.midi import Player
from tutor.complib import drums_f
@skyl
skyl / ta.py
Created April 30, 2012 02:34
Simple Timing arp idea
from itertools import cycle
from bl.arp import RandomArp, OrderedArp, ArpSwitcher
from bl.orchestra.midi import Player, ChordPlayer
from bl.utils import getClock
from tutor.complib import piano_f
piano = piano_f()
@skyl
skyl / defaultdikt.py
Created April 27, 2012 13:29
defaultdict musical score scratchpad idea
"""
1 2 3 4
tekaTa Ta Ka tktkTA
16 16 8 4 4 32 32 32 32 8
0 6 12 24 48 72 75 78 81 84
"""
@skyl
skyl / isSubSet.js
Created April 26, 2012 18:58
Javascript array, is Sub Set
isSubSet = function(ar1, ar2) {
// Test if ar1 is a subset of ar2
ar1 = _.uniq(ar1);
ar2 = _.uniq(ar2);
if (ar1.length > ar2.length) {
return false;
}
_.each(ar1, function(el){
if (ar2.indexOf(el) === -1){
return false;
@skyl
skyl / gist:1961812
Created March 2, 2012 22:17
Which is actually cleaner? (django templates)
{% exec %}
try:
f = durs[duration]
f.field.widget.attrs['placeholder'] = duration
print f
except KeyError:
pass
{% endexec %}
OR
@skyl
skyl / linkify.coffee
Created February 22, 2012 03:25
linkify phone numbers in coffeescript
s = """
Extensions are not supported.
Alphabetic phonenumbers eg 1888-FOR-RILZ are not supported.
Of course, you'll want to prevent injection by stripping html tags first.
It switches the numbers to international format (or sth) - suggestions welcome!
706 555 5001put some
ill formed(404) 555-1397text in here
+34712938479 to make it interesting...5
404.555.1239.
@skyl
skyl / kwacros.py
Created February 1, 2012 05:03
Django Template macros with args and kwargs
#
# templatetags/kwacros.py - Support for macros in Django templates
#
# Based on snippet by
# Author: Michal Ludvig <michal@logix.cz>
# http://www.logix.cz/michal
#
# modified for args and kwargs by Skylar Saveland http://skyl.org
#
@skyl
skyl / gist:1531186
Created December 29, 2011 02:15
Fill varnish with requests
import urllib
import requests
exposure_liability_map = {
"people": [
#("RESDQ", "All residents Day"),
("RESNQ", "Night Residents"),
("RESFDQ", "Female residents Day"),
("RESN4Q", "Night residents < 4yo"),
],
@skyl
skyl / gist:1422095
Created December 2, 2011 06:43
canvas img linear filter in coffeescript
minmax = (value, low, high) -> Math.min Math.max(low, value), high
class ImageProcessor
constructor: (@img, parent=document.body) ->
@canvas = document.createElement("canvas")
@context = @canvas.getContext("2d")
@canvas.width = @img.width
@canvas.height = @img.height
parent.appendChild @canvas
@skyl
skyl / gist:1410323
Created November 30, 2011 19:01
Python order of operations gotcha
In [61]: l
Out[61]: [1, 2, 3, False]
In [62]: i
Out[62]: 1
In [63]: not i in l
Out[63]: False
In [64]: (not i) in l