Skip to content

Instantly share code, notes, and snippets.

@benmanns
benmanns / echo_runner.rb
Created September 16, 2013 17:56
An example of running goworker workers from the command line rather than Redis.
`go run echo_wrapper.go echo_worker.go TESTING` # => [TESTING]
@benmanns
benmanns / queue-redis.sh
Created September 16, 2013 17:23
A comparison of Python RQ to Ruby Resque's Redis data format.
# RQ
redis 127.0.0.1:6379> TYPE rq:queue:default
list
redis 127.0.0.1:6379> RPOP rq:queue:default
"3662e57b-0188-4b78-982c-6904058242d8"
redis 127.0.0.1:6379> TYPE rq:job:3662e57b-0188-4b78-982c-6904058242d8
hash
redis 127.0.0.1:6379> HGETALL rq:job:3662e57b-0188-4b78-982c-6904058242d8
1) "created_at"
2) "2013-09-16T17:18:16.400954+00:00"
package main
import (
"log"
"time"
)
func main() {
ch := make(chan int)
go func() {
@benmanns
benmanns / gist:5912126
Last active December 19, 2015 06:29 — forked from mguterl/gist:308216
#!/bin/sh
#
# init.d script for single or multiple unicorn installations. Expects at least one .conf
# file in /etc/unicorn
#
# Modified by jay@gooby.org http://github.com/jaygooby
# based on http://gist.github.com/308216 by http://github.com/mguterl
#
## A sample /etc/unicorn/my_app.conf
##
git bisect start HEAD origin --
bundle exec script/server
[ 200 -eq $(curl --write-out %{http_code} --silent --output /dev/null http://localhost:3000) ] && git bisect good || git bisect bad
@benmanns
benmanns / matdot.cl
Created March 13, 2013 02:34
An OpenCL kernel for computing the dot product of two matrices.
__kernel void matdot(__global double * outputC, int widthA, int heightA, int widthB, int heightB, __global double* inputA, __global double* inputB) {
int column = get_global_id(0);
int row = get_global_id(1);
double sum = 0.0;
for (int i = 0; i < widthA; i++) {
sum += inputA[row * widthA + i] * inputB[i * widthB + column];
}
outputC[row * widthB + column] = sum;
}
@benmanns
benmanns / servos.ino
Created February 18, 2013 15:51
Control a servo with a potentiometer. Configured for a HITECH Deluxe HS-322HD.
#include <Servo.h>
Servo servo;
const int analogPin = 0;
const int servoPin = 9;
// The minimum pulse width corresponding to 0-degrees on the servo.
// Default is 544.
@benmanns
benmanns / serial-led.ino
Last active December 13, 2015 19:38
Controlling the LED by sending Y or N over the serial connection.
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
Serial.println("Y for on, N for off.");
}
int ledOn = 0;
void loop() {
(function(){var global = this;function debug(){return debug};function require(p, parent){ var path = require.resolve(p) , mod = require.modules[path]; if (!mod) throw new Error('failed to require "' + p + '" from ' + parent); if (!mod.exports) { mod.exports = {}; mod.call(mod.exports, mod, mod.exports, require.relative(path), global); } return mod.exports;}require.modules = {};require.resolve = function(path){ var orig = path , reg = path + '.js' , index = path + '/index.js'; return require.modules[reg] && reg || require.modules[index] && index || orig;};require.register = function(path, fn){ require.modules[path] = fn;};require.relative = function(parent) { return function(p){ if ('debug' == p) return debug; if ('.' != p.charAt(0)) return require(p); var path = parent.split('/') , segs = p.split('/'); path.pop(); for (var i = 0; i < segs.length; i++) { var seg = segs[i]; if ('..' == seg) path.pop(); else if ('.' != seg) path.push(seg); } return require(path.join('/'), parent); };};require.register("neuralnet
if(localStorage.documents.indexOf("news-website-demo") === -1) { localStorage.documents += ",news-website-demo" }
localStorage.setItem('documents-news-website-demo', "{\"mockups\":[{\"top\":19,\"left\":23,\"z_index\":0,\"tool\":\"rectangle\",\"width\":851,\"height\":26,\"color\":\"#dedede\",\"border\":true},{\"top\":17,\"left\":29,\"z_index\":0,\"tool\":\"heading\",\"text\":\"News Website\",\"size\":\"25\",\"color\":\"black\"},{\"top\":22,\"left\":213,\"z_index\":0,\"tool\":\"label\",\"text\":\"New\",\"size\":\"14\",\"color\":\"#383838\"},{\"top\":72,\"left\":81,\"z_index\":0,\"tool\":\"paragraph\",\"text\":\"Open source localStorage based mockup tool\",\"width\":596,\"background\":\"#dedede\"},{\"top\":23,\"left\":258,\"z_index\":0,\"tool\":\"label\",\"text\":\"Threads\",\"size\":\"14\",\"color\":\"#383838\"},{\"top\":24,\"left\":330,\"z_index\":0,\"tool\":\"label\",\"text\":\"Comments\",\"size\":\"14\",\"color\":\"#383838\"},{\"top\":24,\"left\":419,\"z_index\":0,\"tool\":\"label\",\"text\":\"Ask\",\"size\