Skip to content

Instantly share code, notes, and snippets.

View x's full-sized avatar
🐦

Devon Peticolas x

🐦
View GitHub Profile
@x
x / gist:b89172e7304e40bb4484
Last active August 29, 2015 14:09
clojure kafka consumer
(ns test-kafka.core
(:gen-class)
(:require [clj-kafka.consumer.zk :refer :all]
[clj-kafka.core :refer :all]
[msgpack.core :refer :all]))
(def config {"zookeeper.connect" "zk04/cb/kafka/pingqueue"
"group.id" "clj-kafka.consumer"
"auto.offset.reset" "smallest"
"auto.commit.enable" "false"})
@x
x / gist:07b6c260b666e1c5cc5f
Created October 16, 2014 21:14
get collections with unique indexes
db.getCollectionNames().filter(function(col){return db[col].getIndexes().filter(function(idx){return idx.unique}).length})
@x
x / gist:ae168992c33024d9d4c9
Created August 6, 2014 21:57
kill by grep
ps aux | grep FOOBARBAZ | tr -s ' ' | cut -d' ' -f2 | xargs kill -9
@x
x / gist:86892f50894cc2e46602
Created July 30, 2014 18:29
Named Tuple vs Dict Vs Tuple
$ python -m timeit -s 'from collections import namedtuple; NT = namedtuple("NT", "a"); nt = NT(1)' 'nt.a'
10000000 loops, best of 3: 0.138 usec per loop
/U/d/chartbeat(dev)(master)$ python -m timeit -s 'd = (1, )' 'd[0]'
10000000 loops, best of 3: 0.0409 usec per loop
/U/d/chartbeat(dev)(master)$ python -m timeit -s 'd = {"a": 1}' 'd["a"]'
10000000 loops, best of 3: 0.0358 usec per loop
@x
x / gist:93793c12003b1312ffda
Created July 30, 2014 11:56
get s3 files by grep
s3cmd ls s3://S3_BUCKET | grep PATTERN | tr -s ' ' | cut -d' ' -f4- | xargs s3cmd get
@x
x / gist:21fd81938df43d3ef742
Created July 29, 2014 17:38
top processes by memory
ps aux --sort -pmem | head
@x
x / gist:4ccbf329d70cf74ecec8
Created July 7, 2014 15:52
find port of process
ps aux # get the pid
netstat -tulpn | grep PID
@x
x / namechecker
Created May 16, 2014 13:33
Chartbeat About Page Name Checker Bookmarklet
javascript:(function()%7Bvar name%3Dprompt(%27Enter a name%27)%3B%24(%27%23team-grid li h3%27).each(function()%7Bif(!%24(this).html().match(new RegExp(name,%27i%27)))%7B%24(this).parent().parent().parent().toggleClass(%27dim%27)%7D%7D)%7D)()%3B
@x
x / gist:11225232
Created April 23, 2014 17:30
getting csv of paths without xys
def main():
"""
[debug-only]
"""
define("domain", default="theverge.com")
define("path", default=None)
define("console", default=True, type=bool)
define("debug", default=True, type=bool)
define("click_through_host", default="localhost")
define("minutes", default=5)
[ [43/1951]
{
"_id" : {
"t" : ISODate("2014-04-14T13:48:07Z"),
"vh" : BinData(0,"SK9o5qTZfIsFvOsRRPMrvA=="),
"ph" : BinData(0,"HC+s0NvoJhAjtxUDTpI9bQ==")
},
"vaup" : {
"auto" : 0,
"unkn" : 1,