Skip to content

Instantly share code, notes, and snippets.

@astanway
astanway / gist:1708369
Created January 31, 2012 02:39
Just emailing to confirm your interview. Are you still available tomorrow at 8?
var confirmed = true;
var skype = "abe.stanway";
var hitMeUpYo = function(skype, confirmed){
confirmed
? console.log("Looking forward to speaking with you! My Skype is " + skype)
: console.log("Sorry, gonna have to pass")
};
hitMeUpYo(skype, confirmed);
@astanway
astanway / client.coffee
Created June 29, 2012 23:56
node pubsub
# NOTE: Requires https://github.com/technoweenie/nubnub
Client = require '../src/client'
cli = Client.build(
hub: "http://hub.etsy.com/"
mode: "subscribe"
verify: 'sync'
topic: 'http://www.etsy.com/api/push/listings/latest.atom'
callback: 'http://ec2-23-20-144-147.compute-1.amazonaws.com:8080/callback'
apikey: 'YOURKEYHERE'
~/code/hackerleague.org$ bundle exec foreman start
13:50:08 web.1 | started with pid 18516
13:50:08 worker.1 | started with pid 18517
13:50:20 web.1 | => Booting Thin
13:50:20 web.1 | => Rails 3.2.3 application starting in development on http://0.0.0.0:5000
13:50:20 web.1 | => Call with -d to detach
13:50:20 web.1 | => Ctrl-C to shutdown server
13:51:39 web.1 | Exiting
13:51:39 web.1 | /Users/abestanway/.rvm/gems/ruby-1.9.2-p290/gems/mongo-1.6.2/lib/mongo/connection.rb:415:in `connect': Failed to connect to a master node at localhost:27017 (Mongo::ConnectionFailure)
13:51:39 web.1 | from /Users/abestanway/.rvm/gems/ruby-1.9.2-p290/gems/mongo-1.6.2/lib/mongo/connection.rb:589:in `setup'
import socket
import sys
import pickle
import redis
"""
Basically, this bad boy needs to receive 500k pickled metrics of the type [name, (timestamp,
value)] every 10 seconds. It needs to then unpickle them and pop them in Redis. When you fire
it up, it works for about five seconds (just listening - not even Redising yet), and then it
stops, with a weird exception in gen_unpickle:
@astanway
astanway / namespaced_to_dict.py
Last active December 10, 2015 01:18
Wherein a drunk Abe needed a fast and easy way to turn a namespaced string into a nested dictionary.
string = "stats.pages.home_page.visitors"
split_string = string.split('.')
tree = {}
tree_string = 'tree'
for i in range(0, len(split_string)):
try:
tree_string = tree_string + '[split_string[' + str(i) + ']]'
exec(tree_string)
except KeyError:
@participations = 0
@hacks.each do |hack|
@participations += hack.hackers_count
end
unless @participations == 0
@average = sprintf("%.1f", (@hacks.length / @participations))
else
@average = 0
end
@astanway
astanway / SHELL_SLOW_CAP.sh
Created February 19, 2013 02:50
SHELL SLOW CLAP
#!/bin/bash
SLOW=10
while true
do sleep $SLOW
echo "clap"
SLOW=$(($SLOW - 1))
done
# Optimizations
ujson_loads = ujson.loads
time_time = time.time()
settings_ANALYZER_PROCESSES = settings.ANALYZER_PROCESSES
self_analyze = self.analyze
json = ujson_loads('my string')
self_analyze(json)
from pandas import stats, Series
import numpy as np
from numpy import linalg as numpy_linalg
from numpy import mean as numpy_mean
from numpy import sqrt as numpy_sqrt
from numpy import round as numpy_round
from scipy import stats as sci_stats
from scipy import array as scipy_array
from scipy import std as scipy_std
from time import time
func Pummeler(schema interface{}, callback string, failedAttempts chan bool, pummelers chan int) {
pummelers <- 1
// Format request
jsonEncoded, err := json.Marshal(schema)
if err != nil {
log.Println("Could not encode JSON")
return
}