Skip to content

Instantly share code, notes, and snippets.

View coffeeaddict's full-sized avatar

Hartog C. de Mik coffeeaddict

View GitHub Profile
@JiriChara
JiriChara / gist:11213670
Last active August 29, 2015 14:00
Create fast pull request to OrganisedMinds from current branch
#!/usr/bin/env ruby
require 'open3'
begin
stdout, status = Open3.capture2("git status -uno --porcelain")
rescue Errno::ENOENT
abort "Cannot run `git status -uno --porcelain`."
end
require 'thread'
class Worker
def initialize(count = 1)
@queue, @closing, @threads, @mutex = Queue.new, false, [], Mutex.new
add_worker(count)
end
def add_worker(count = 1)
@mutex.synchronize do
@coffeeaddict
coffeeaddict / alt.rb
Created March 6, 2012 16:09
Akka 2.0 experiment
# A JRuby alternative for the Akka.io homepage scala and java examplatory code.
require 'java'
require './lib/scala-library.jar'
require './lib/akka/akka-actor-2.0.jar'
module Akka
include_package 'akka.actor'
end
@nesquena
nesquena / jbuilder.rb
Created February 14, 2012 01:15
JBuilder and RABL Syntax Comparison
Jbuilder.encode do |json|
json.content format_content(@message.content)
json.(@message, :created_at, :updated_at)
json.author do |json|
json.name @message.creator.name.familiar
json.email_address @message.creator.email_address_with_name
json.url url_for(@message.creator, format: :json)
end
@coffeeaddict
coffeeaddict / bak.sh
Created January 30, 2012 07:38
My backup solution
#!/bin/sh
for file in $*
do
path=`dirname $file`
name=`basename $file`
if [ `printf "%.1s" $path` = "/" ]
then
echo "Files must be specified relative: $file"
# make an alternative for send_later that accepts a run_at time
#
module Delayed
module MessageSending
def send_later_at(at, method, *args)
Delayed::Job.enqueue(
Delayed::PerformableMethod.new(self, method.to_sym, args),
0, #priority
at #run_at
)
@jtimberman
jtimberman / nginx.conf
Created March 5, 2010 21:01 — forked from johnthethird/nginx.conf
nginx front end for Riak
# Config for Nginx to act as a front-end for Riak
# The main goal is to proxy all GETs directly to Riak, and disallow anything else (POST, PUT, etc)
# Also, disallow use of the map/reduce query links (i.e. /riak/bucket/key/_,_,_)
# Config is in /etc/nginx/sites-available/default or somewhere like that
# Set up load-balancing to send requests to all nodes in the Riak cluster
# Replace these IPs/ports with the locations of your Riak nodes
upstream riak_hosts {
server 127.0.0.1:8098;