Skip to content

Instantly share code, notes, and snippets.

def remove_comments(line, pref="", ctx=None, escape=False):
if line == "": return pref
if ctx == "#" and line[0] != '\n':
return remove_comments(line[1:], pref, ctx)
if not ctx:
if line[0] == "#": return remove_comments(line[1:], pref, '#')
for c in ['"""', '"', "'"]:
if line.startswith(c):
# open context
return remove_comments(line[len(c):], pref + c, c)
using AudioIO
macro time_call(ex)
println(ex)
var = gensym()
ex = Expr(:(=), var, ex)
quote
$ex;
AudioIO.pull($var, 44100, 0, 44100);
@time AudioIO.pull($var, 44100, 0, 44100);
@shashi
shashi / sierpinski.elm
Created October 8, 2014 06:37
Sierpinski's triangles in Elm
{- Sierpinski's triangle -}
hscale = sqrt(3) / 2
triangle a =
filled black (path [(-a / 2, -hscale * a / 2),
(a / 2, -hscale * a / 2),
(0, hscale * a / 2)])
sierpinski (x, y) a n =
@shashi
shashi / measure.jl
Last active August 29, 2015 14:08
arithmetic for relative length measures
abstract Measure
immutable Length{unit} <: Measure
value::Float64
end
abstract MeasureOp{n} <: Measure
abstract UnaryOp{A} <: MeasureOp{1}
abstract ScalarOp{A} <: MeasureOp{2}
abstract BinaryOp{A, B} <: MeasureOp{2}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@shashi
shashi / layout.jl
Created April 27, 2015 17:45
Slides for my talk at MetaRefresh 2015. Made with https://github.com/shashi/Escher.jl
# An infinite number of mathematicians walk into a bar...
using Color
colors = distinguishable_colors(9)
box(w, h, n) =
empty |> fillcolor(colors[n % 9 + 1]) |> size(w, h)
socnet {
user users[x],
group groups[y],
}
user {
string name,
string profile,
string username,
string password,
k=1; i=[1,2]
while k:
for j in i:
k*=j
i.append(k+1)
k=1