Skip to content

Instantly share code, notes, and snippets.

@samlown
samlown / mage.go
Created August 29, 2018 15:54
Sample project Magefile
// +build mage
package main
import (
"fmt"
"io/ioutil"
"os"
"path"
@samlown
samlown / zmq-test-dealer.rb
Last active August 29, 2015 13:58
ZeroMQ Dealer-Router pattern with Celluloid::ZMQ
require 'celluloid/zmq'
Celluloid::ZMQ.init
class Client
include Celluloid::ZMQ
def initialize(address)
@socket = DealerSocket.new
@samlown
samlown / resque
Created July 26, 2013 10:04
Simple script to queue Resque worker tasks from the console or command line. Especially useful for cron tasks.
#!/usr/bin/env ruby
#
# Resque Runner
#
# Quickly queue a resque task using the command line. Fast alternative to running
# rake from the crontab, and prevent loading too many rake tasks.
#
# Usage:
#
# resque queue WorkerClass [arguments]
@samlown
samlown / couchdb.conf
Created July 18, 2012 09:26
CouchDB 1.2 Upstart Config
# Upstart file at /etc/init/couchdb.conf
# CouchDB
start on runlevel [2345]
stop on runlevel [06]
pre-start script
chown -R couchdb /usr/local/etc/couchdb
chown -R couchdb /usr/local/lib/couchdb
chown -R couchdb /usr/local/var/log/couchdb
@samlown
samlown / gist:2050446
Created March 16, 2012 15:01
CouchDB Payment design doc which suddenly stopped working to requests on designs != all
{
"_id": "_design/Payment",
"_rev": "13-0996651a32cb63639fe01edd01383eb9",
"language": "javascript",
"views": {
"all": {
"map": "function(doc) {\n if (doc['type'] == 'Payment') {\n emit(doc['_id'],1);\n }\n }"
},
"by_sequence": {
"map": " function(doc) {\n if ((doc['type'] == 'Payment') && (doc['sequence'] != null)) {\n emit(doc['sequence'], 1);\n }\n }\n",
@samlown
samlown / gist:2050444
Created March 16, 2012 15:01
CouchDB Payment design doc which suddenly stopped working to requests on designs != all
{
"_id": "_design/Payment",
"_rev": "13-0996651a32cb63639fe01edd01383eb9",
"language": "javascript",
"views": {
"all": {
"map": "function(doc) {\n if (doc['type'] == 'Payment') {\n emit(doc['_id'],1);\n }\n }"
},
"by_sequence": {
"map": " function(doc) {\n if ((doc['type'] == 'Payment') && (doc['sequence'] != null)) {\n emit(doc['sequence'], 1);\n }\n }\n",
namespace :bundler do
task :create_symlinks, :roles => :app do
shared_bundle_path = File.join(shared_path, 'bundle')
release_bundle_path = File.join(current_release, '.bundle')
run("mkdir -p #{shared_bundle_path} && ln -s #{shared_bundle_path} #{release_bundle_path}")
shared_gemfile_path = File.join(shared_path, 'bundle', 'Gemfile.lock')
release_gemfile_path = File.join(current_release, 'Gemfile.lock')
run "touch #{shared_gemfile_path}"
run "ln -s #{shared_gemfile_path} #{release_gemfile_path}"
end
@samlown
samlown / gist:467912
Created July 8, 2010 11:39
Glabels 3 batch failing
sam@sams-imac:~/workspace/glabels$ ./src/glabels-3-batch -i /tmp/projects.csv -o /tmp/output.pdf /tmp/test_130x65.glabels
merge.c:236 (gl_merge_class_init) START
merge.c:242 (gl_merge_class_init) END
merge-text.c:110 (gl_merge_text_class_init) START
merge-text.c:140 (gl_merge_text_class_init) END
prefs.c:58 (gl_prefs_init) START
prefs-model.c:227 (gl_prefs_model_new) START
prefs-model.c:156 (gl_prefs_model_class_init) START
prefs-model.c:172 (gl_prefs_model_class_init) END
prefs-model.c:179 (gl_prefs_model_init) START
@samlown
samlown / gist:459343
Created June 30, 2010 23:13
Error with CouchDB while trying to replicate from a remote server proxied by Nginx
Nginx proxy configuration:
server {
server_name couchdb.ityzen.com;
listen 443;
ssl on;
ssl_certificate /etc/ssl/certs/server.crt;
ssl_certificate_key /etc/ssl/private/server.key;