Skip to content

Instantly share code, notes, and snippets.

View darkhelmet's full-sized avatar
🏠
Working from home

Daniel Huckstep darkhelmet

🏠
Working from home
View GitHub Profile
# Server
redis_version:2.6.9
redis_git_sha1:00000000
redis_git_dirty:0
redis_mode:standalone
os:Linux 2.6.32-45-server x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.4.3
process_id:19938
@darkhelmet
darkhelmet / actor.rb
Last active December 12, 2015 08:29
Make Your own Celluloid
require 'forwardable'
require 'thread'
require 'monitor'
module LolConcurrency
module Actor
Context = Struct.new(:method, :args, :block)
Async = Struct.new(:instance, :mailbox) do
extend Forwardable
@darkhelmet
darkhelmet / migrator.rb
Last active December 11, 2015 14:58
A migrator for 37Signals' BCX.
require 'httparty'
require 'active_support/all'
module PartyPooper
def get(url, options = {})
self.class.get("/#{account_id}/api/v1/#{url}", options.merge(extras))
rescue => boom
puts boom.message
retry
end
#!/usr/bin/env bash
# Usage: dh serve path/to/serve
# Summary: Serve a directory on port 8080
tmpfile="/tmp/serve.$$.go"
dir=`greadlink -f $1`
if [ ! -d "$dir" ]; then
exec dh help serve
fi
safe_gopath_export $PWD
config=`heroku config -s`
export `echo $config | tr ' ' '\n' | grep READABILITY_TOKEN`
export `echo $config | tr ' ' '\n' | grep POSTMARK_TOKEN`
export `echo $config | tr ' ' '\n' | grep FROM`
function watch() {
puncher 'killall -USR1 tinderizer' src/bookmarklet/bookmarklet.coffee
}
@darkhelmet
darkhelmet / tinderizer.md
Created September 16, 2012 02:54
A history of Tinderizer

Genesis

I wanted to use the Readability script to turn web pages into nice readable things and dump them on my Kindle. This was in November 2010.

I figured with jsdom and other things on node.js it would be pretty easy. Lo and behold, somebody had ported the script to run on node.js already, so I just plugged in the parts and made it work.

Upgrades

Who writes plain Javascript anymore? Right? Right? Anyway, rewrote in coffeescript because the original code was hacked together as a proof of concept almost, so I used some other libs to clean things up along the way. This is Version 2

2012/08/21 10:41:40 took 1.831589s (9 ns/op) to try 'a' for index 0
2012/08/21 10:41:42 took 1.812426s (9 ns/op) to try 'b' for index 0
2012/08/21 10:41:45 took 1.816416s (9 ns/op) to try 'c' for index 0
2012/08/21 10:41:48 took 1.82774s (9 ns/op) to try 'd' for index 0
2012/08/21 10:41:50 took 1.814831s (9 ns/op) to try 'e' for index 0
2012/08/21 10:41:53 took 1.825167s (9 ns/op) to try 'f' for index 0
2012/08/21 10:41:56 took 1.858311s (9 ns/op) to try 'g' for index 0
2012/08/21 10:41:59 took 1.818296s (9 ns/op) to try 'h' for index 0
2012/08/21 10:42:02 took 1.883082s (9 ns/op) to try 'i' for index 0
2012/08/21 10:42:04 took 1.834942s (9 ns/op) to try 'j' for index 0
// ==UserScript==
// @name Amazon Canonical
// @namespace http://verboselogging.com/
// @version 0.1
// @description Make the main title of an Amazon product page a link to the canonical URL of the page.
// @match http://*amazon*/*
// @copyright 2012+, Daniel Huckstep
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// ==/UserScript==
grayscale = (canvas) ->
context = canvas.getContext('2d')
width = canvas.width
height = canvas.height
img = context.getImageData(0, 0, width, height)
pixels = img.data
for i in [0...height]
for j in [0...width]
index = (i * 4) * width + (j * 4)
[r, g, b, a] = [index, index + 1, index + 2, index + 3]
require 'delegate'
class LolRuby < SimpleDelegator
def +(x)
__getobj__ + (x * 10)
end
end
def add_one(x)
x + 1