Skip to content

Instantly share code, notes, and snippets.

View kisielk's full-sized avatar
🔈

Kamil Kisiel kisielk

🔈
View GitHub Profile
@kisielk
kisielk / linnstrument.sc
Last active July 20, 2023 18:18
Linnstrument + Supercollider
(
var notes, synths, on, off, mod, bend, touch;
~num_channels = 8;
~bend_range = 24;
MIDIIn.connectAll;
notes = Array.newClear(~num_channels);
synths = Array.newClear(~num_channels);
@kisielk
kisielk / https_test.py
Created September 18, 2011 01:32
Testing SSL functionality in tornado
import tornado.web
import tornado.httpserver
import tornado.ioloop
class DefaultHandler(tornado.web.RequestHandler):
def get(self):
self.write("Nothing to see here\n")
if __name__ == "__main__":
app = tornado.web.Application([
@kisielk
kisielk / jsonhandler.go
Created February 15, 2013 16:42
Simple HTTP handler wrapper for conveniently dealing with JSON requests
// JSONResponseWriter wraps an http.ResponseWriter and provides convenience methods for creating JSON responses
type JSONResponseWriter struct {
writer http.ResponseWriter
}
// Response writes an HTTP response with the value v encoded in JSON format.
func (w JSONResponseWriter) Response(v interface{}) {
w.writer.Header().Set("Content-Type", "application/json")
enc := json.NewEncoder(w.writer)
enc.Encode(v)
def E(h, n):
"""
Generates a euclidian rhythm.
Arguments:
k : The number of ones in the sequence.
n : The number of steps in the sequence.
See http://cgm.cs.mcgill.ca/~godfried/publications/banff.pdf
"""
@kisielk
kisielk / gist:7920552
Last active December 31, 2015 02:28
SQLite cares not for schemas.
~ $ sqlite3 foo.db
SQLite version 3.7.13 2012-07-17 17:46:21
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table foo ( f varchar(1) );
sqlite> .schema
CREATE TABLE foo ( f varchar(1) );
sqlite> insert into foo values ("hello world");
sqlite> select * from foo;
hello world
package mutexbench
import (
"runtime"
"sync"
"testing"
)
func BenchmarkMutex100(b *testing.B) { benchMutex(b, 1000) }
func BenchmarkMutex1000(b *testing.B) { benchMutex(b, 1000) }
Kamils-MacBook-Air:tmp kamil$ clang -v
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix
Kamils-MacBook-Air:tmp kamil$ go build -x
WORK=/var/folders/l7/xpn_29dn36qd97kgm79_8dg00000gn/T/go-build207250261
mkdir -p $WORK/_/Users/kamil/tmp/_obj/
mkdir -p $WORK/_/Users/kamil/
cd /Users/kamil/tmp
/Users/kamil/go.tip/pkg/tool/darwin_amd64/cgo -objdir $WORK/_/Users/kamil/tmp/_obj/ -- -I $WORK/_/Users/kamil/tmp/_obj/ foo.go
@kisielk
kisielk / Output
Created September 11, 2013 17:14
A benchmark of slice versus map iteration. Go 1.1.
BenchmarkSlice100 20000000 121 ns/op
BenchmarkSlice1000 1000000 1170 ns/op
BenchmarkSlice10000 200000 11658 ns/op
BenchmarkSlice100000 10000 116510 ns/op
BenchmarkMap100 5000000 670 ns/op
BenchmarkMap1000 200000 9249 ns/op
BenchmarkMap10000 20000 76125 ns/op
BenchmarkMap100000 2000 798339 ns/op
@kisielk
kisielk / gist:5172973
Created March 15, 2013 20:43
Timer, why u no fire?
var (
Forever = time.Duration(math.MaxInt64)
Debounce = time.Second
)
// Other unrelated things here
for {
t := time.NewTimer(Forever)
select {
@kisielk
kisielk / gist:5118235
Created March 8, 2013 17:34
errcheck run on the stdlib
/Network/Cluster/home/kamil/go/src/pkg/archive/tar/reader.go:66:3 mergePAX(hdr, headers)
/Network/Cluster/home/kamil/go/src/pkg/crypto/tls/conn.go:489:6 c.setError(err)
/Network/Cluster/home/kamil/go/src/pkg/crypto/tls/conn.go:500:5 c.sendAlert(alertProtocolVersion)
/Network/Cluster/home/kamil/go/src/pkg/crypto/tls/conn.go:530:6 c.setError(err)
/Network/Cluster/home/kamil/go/src/pkg/crypto/tls/conn.go:543:5 c.sendAlert(alertRecordOverflow)
/Network/Cluster/home/kamil/go/src/pkg/crypto/tls/conn.go:550:5 c.sendAlert(alertUnexpectedMessage)
/Network/Cluster/home/kamil/go/src/pkg/crypto/tls/conn.go:554:6 c.sendAlert(alertUnexpectedMessage)
/Network/Cluster/home/kamil/go/src/pkg/crypto/tls/conn.go:558:6 c.setError(io.EOF)
/Network/Cluster/home/kamil/go/src/pkg/crypto/tls/conn.go:567:6 c.setError(&net.OpError{Op: "remote error", Err: al