This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
for file in $* | |
do | |
path=`dirname $file` | |
name=`basename $file` | |
if [ `printf "%.1s" $path` = "/" ] | |
then | |
echo "Files must be specified relative: $file" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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; |