Skip to content

Instantly share code, notes, and snippets.

View akahn's full-sized avatar

Alex Kahn akahn

View GitHub Profile
package main
import (
"io"
"log"
"net/http"
"time"
)
func main() {
package main
import (
"encoding/binary"
"encoding/hex"
"log"
"runtime"
"sync"
"sync/atomic"
"time"

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@akahn
akahn / a-screenshot.md
Created February 10, 2011 17:25 — forked from tmm1/README.md
Embed gravatars in Propane chat

@akahn
akahn / bash_power.txt
Last active March 23, 2020 15:55
Some helpful keyboard shortcuts for bash
Jump forward/back one word
alt-b/alt-f
Go to beginning/end of line
^a/^e
Delete to beginning of command
^u
Navigate through history of commands (this works in many places in OS X)
@akahn
akahn / 3.rb
Last active December 6, 2018 21:57
Advent of Code 2018
require 'strscan'
require 'pry'
class Sheet
def initialize(x, y, initial = 0)
@matrix = Array.new(y) { (Array.new(x) { initial }) }
end
def to_s
s = ''
May 31 14:30:00 l2met-prod-38 l2met-log: 2016/05/31 18:30:00 receiver.go:540: LOGGED_METRIC_IN: [daniel@dubsmash.com] name=dubsmash.password_recovery.send_mail_returns_1 source=dubsmash vals=[1]
May 31 14:30:01 l2met-prod-32 l2met-log: 2016/05/31 18:30:01 receiver.go:540: LOGGED_METRIC_IN: [daniel@dubsmash.com] name=dubsmash.password_recovery.send_mail_returns_1 source=dubsmash vals=[1]
May 31 14:30:02 l2met-prod-35 l2met-log: 2016/05/31 18:30:01 receiver.go:540: LOGGED_METRIC_IN: [daniel@dubsmash.com] name=dubsmash.password_recovery.send_mail_returns_1 source=dubsmash vals=[1]
May 31 14:30:02 l2met-prod-39 l2met-log: 2016/05/31 18:30:02 receiver.go:540: LOGGED_METRIC_IN: [daniel@dubsmash.com] name=dubsmash.password_recovery.send_mail_returns_1 source=dubsmash vals=[1]
May 31 14:30:03 l2met-prod-33 l2met-log: 2016/05/31 18:30:03 receiver.go:540: LOGGED_METRIC_IN: [daniel@dubsmash.com] name=dubsmash.password_recovery.send_mail_returns_1 source=dubsmash vals=[1]
May 31 14:30:05 l2met-prod-33 l2met-log: 20
[Producer.new(pool, notifications_east, Notifier).thread,
Producer.new(pool, notifications_west, Annotator).thread,
Producer.new(pool, annotations_east, Annotator).thread,
Producer.new(pool, annotations_west, Annotator).thread].each &:join
@akahn
akahn / elasticsearch.sh
Created November 5, 2013 02:26
Trying to understand elasticsearch's schema and types
$ curl -XPOST http://localhost:9200/myindex/mytype -d '{"foo": ["bar"]}'
{"ok":true,"_index":"myindex","_type":"mytype","_id":"YYfPUL3TQLaL17zhXQ-ELw","_version":1}
$ curl -XPOST http://localhost:9200/myindex/mytype -d '{"foo": [{"foo": "bar"}]}'
{"error":"MapperParsingException[Failed to parse [foo]]; nested: ElasticSearchIllegalArgumentException[unknown property [foo]]; ","status":400}
$ curl -XDELETE http://localhost:9200/myindex/mytype
{"ok":true}
$ curl -XPOST http://localhost:9200/myindex/mytype -d '{"foo": [{"foo": "bar"}]}'
def case_wat
case number = 1
when number == 1
'expected'
else
'wat'
end
end