Skip to content

Instantly share code, notes, and snippets.

View tombh's full-sized avatar

Thomas Buckley-Houston tombh

View GitHub Profile
@schmurfy
schmurfy / workers.rb
Created September 20, 2012 21:22
Celluloid workers
require 'celluloid'
WORKERS_COUNT = (ARGV[0] || 1).to_i
class Output
include Celluloid
def puts(msg)
Kernel.puts(msg)
end
@gilbert
gilbert / ajax-loader.scss
Created July 8, 2015 16:15
Global Mithril.js AJAX Loader
// Taken from http://loading.io/
uiload {
display: inline-block;
position: relative;
& > div {
position: relative;
}
}
@-webkit-keyframes ajax-loader {
@Earlz
Earlz / gist:5848045
Last active December 18, 2015 21:29
This is the oldest program I can find that once worked which I wrote. This was probably written in either 2003 or 2004 in DarkBasic Professional. I would have been 13 at the time.
rem this is a generic media player
rem this prog was made by jordan earls
starty:
print "type 1 to choose where media is"
print "type 2 to pause music"
print "type 3 to resume music"
print "type 4 to reload music"
print "type 5 to change volume"
print "type 6 to change speed"
start:
@lmars
lmars / commands.txt
Last active January 22, 2016 20:43
Flynn Redis
# create a redis app
flynn create --remote "" redis
# create a release using the latest (at the time of writing) Docker Redis image
flynn -a redis release add -f config.json "https://registry.hub.docker.com?name=redis&id=868be653dea3ff6082b043c0f34b95bb180cc82ab14a18d9d6b8e27b7929762c"
# scale the server to one process. This may time out initially as the server pulls the image, but watch "flynn -a redis ps" and should come up.
flynn -a redis scale server=1
# redis should now be running in the cluster at redis.discoverd:6379
@james-huston
james-huston / hastats.sh
Last active February 7, 2018 13:21
HAProxy stats to StackDriver using a shell script
# run this every minute from cron as a quick and dirty solution to get some
# haproxy stats on each of your listeners over to stackdriver
instance=$(curl -s "http://169.254.169.254/latest/meta-data/instance-id")
# while [ 1 ]; do
cp /dev/null /tmp/hastats.json
echo 'show stat' | socat - UNIX-CLIENT:/tmp/haproxy.sock \
|while IFS=',' read pxname svname qcur qmax scur smax slim stot bin bout dreq \
dresp ereq econ eresp wretr wredis status weight act bck chkfail chdown lastchg \
@inactivist
inactivist / tweepy_raw_response_json.py
Last active December 26, 2020 12:11
How to get the raw Twitter API JSON response from a Tweepy request. It provides a simple way to stash the parsed API request results for later use. It stores the parsed JSON in a _payload field in the returned API results, which can then be iterated over. Not as clean as I'd like, but it allows me to leverage all of Tweepy's API methods and stil…
"""
Taken from my suggestion at:
https://groups.google.com/forum/#!msg/tweepy/OSGRxOmkzL4/yaNT9fL9FAIJ
Note that this is an incomplete snippet; you'll need to create the API auth object.
"""
import simplejson as json
import tweepy
@RedBeard0531
RedBeard0531 / functions.js
Created February 22, 2012 20:13
Min, Max, Sum, Count, Avg, and Std deviation using MongoDB MapReduce
// derived from http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm
function map() {
emit(1, // Or put a GROUP BY key here
{sum: this.value, // the field you want stats for
min: this.value,
max: this.value,
count:1,
diff: 0, // M2,n: sum((val-mean)^2)
});
@eevee
eevee / fonts.conf.xml
Last active September 5, 2022 03:42
my fonts.conf
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<dir>~/.fonts</dir>
<alias>
<family>serif</family>
<prefer>
<family>Source Serif Pro</family>
<family>IPAMincho</family>
</prefer>
@pixeltrix
pixeltrix / time_vs_datatime.md
Last active February 18, 2024 19:20
When should you use DateTime and when should you use Time?

When should you use DateTime and when should you use Time?

It's a common misconception that [William Shakespeare][1] and [Miguel de Cervantes][2] died on the same day in history - so much so that UNESCO named April 23 as [World Book Day because of this fact][3]. However because England hadn't yet adopted [Gregorian Calendar Reform][4] (and wouldn't until [1752][5]) their deaths are actually 10 days apart. Since Ruby's Time class implements a [proleptic Gregorian calendar][6] and has no concept of calendar reform then there's no way to express this. This is where DateTime steps in:

>> shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND)
=> Tue, 23 Apr 1616 00:00:00 +0000
>> cervantes = DateTime.iso8601('1616-04-23', Date::ITALY)
=> Sat, 23 Apr 1616 00:00:00 +0000
@paulirish
paulirish / bling.js
Last active February 20, 2024 14:11
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;