Skip to content

Instantly share code, notes, and snippets.

View shanemhansen's full-sized avatar

Shane Hansen shanemhansen

View GitHub Profile
#!/bin/bash
synclient VertTwoFingerScroll=1
synclient TapButton1=1
synclient TapButton2=3
synclient TapButton3=2
synclient VertScrollDelta=-243
import (
"fmt"
"regexp"
"strconv"
"testing"
)
func BenchmarkFmt(b *testing.B) {
url := "/client/11/merchants"
pattern := "/client/%d/merchants"
(ns Foo
(:gen-class))
(defn tick [[queue rung1 rung2 rung3]]
(let [ball (first queue) queue (rest queue)]
(if (not= (count rung1) 4)
[queue (cons ball rung1) rung2 rung3]
(let [queue (concat queue rung1) rung1 ()]
CREATE TABLE timeline (
mid int,
uid text,
ts timestamp,
PRIMARY KEY ((mid, uid), ts)
)
// query is
select ts from timeline where mid=? and uid=? and ts >= ?
@shanemhansen
shanemhansen / if.go
Created July 2, 2014 00:01
Go interfaces
type ProfileFetcher struct {
Session interface {
Query(string, ...interface{}) interface {
Iter() Scanner
}
}
Duration time.Duration
}
#include <stdio.h>
#include <stdlib.h>
struct List {
struct List *next;
};
int main(int argc, char **argv) {
struct List *l = malloc(sizeof (struct List));
l->next = l;
int i;
struct List {
next: Option<Box<List>>
}
fn main() {
let mut l = Some(box List{next: None});
for _ in range(0, 156751200) {
l = match l {
Some(l) => l.next,
None => None
}
@shanemhansen
shanemhansen / main.go
Created June 30, 2014 23:43
Read "csv"
package main
import (
"bufio"
"fmt"
"github.com/davecheney/profile"
"os"
"strings"
)
(pprof) top10
Total: 174 samples
44 25.3% 25.3% 78 44.8% strings.genSplit
33 19.0% 44.3% 33 19.0% strings.Count
25 14.4% 58.6% 25 14.4% runtime.aeshashbody
21 12.1% 70.7% 21 12.1% markonly
13 7.5% 78.2% 16 9.2% MCentral_Grow
11 6.3% 84.5% 12 6.9% syscall.Syscall
7 4.0% 88.5% 7 4.0% runtime.indexbytebody
4 2.3% 90.8% 4 2.3% scanblock
nil = None
def goify(f):
"""
You know why
"""
@functools.wraps(f)
def wrapper(*args, **kwargs):
"""
Wrap wrap a function that can return an error
in a tuple of (result, error)