This file contains hidden or 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 | |
script = <<-BASH | |
if [ ! -n "${foobar+x}" ]; then \ | |
echo "foobar is unset"; \ | |
elif [[ ${!foobar[@]} ]]; then \ | |
if [[ $foobar ]]; then \ | |
echo "foobar is set"; \ | |
else \ | |
echo "foobar is set, but empty"; \ |
This file contains hidden or 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
class Canine | |
VERSION = '1.3' | |
def initialize(&block) | |
@commands = Hash.new | |
@default = @latest = :commands | |
@empty = nil | |
@auto = { | |
:commands => hash_command("commands","Show a list of commands",Proc.new { | |
@commands.each { |cmd| c = cmd[1] | |
name = c[:name].to_s |
This file contains hidden or 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 'test/unit' | |
require 'shoulda' | |
class HelpersTest < Test::Unit::TestCase | |
# ServerHelpers is the module that has all the sinatra helpers | |
include ServerHelpers | |
context "a helper" do | |
should "return a number" do | |
assert_equal 42, my_helper_method |
This file contains hidden or 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
This is basically a dirty hack :) I have no idea if messing with the default OSX apache config this way is frowned upon. My view is that it works now, and if it breaks I'll fix it. | |
Add any domains you want to blacklist to /etc/hosts, pointing at 127.0.0.1. You need to enable web sharing to get apache running of course. | |
Changes to the default /etc/apache2/httpd.conf | |
============================================== | |
Listen 127.0.0.1:80 # so that the world can't see the list | |
DocumentRoot "/Library/WebServer/Documents/public" # to fit in with passenger, you need to create the public dir (and maybe /tmp too) |
This file contains hidden or 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
# lexically sort filenames | |
--sort-files | |
# Pipe the output through a pager by default | |
# --pager=less | |
# Highlight the matching text | |
--color | |
# Print 1 line of output context |
This file contains hidden or 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 'clojure' | |
class MyClojureObj < Clojure::Object | |
def initialize | |
dosync { @foo = 'foo' } | |
end | |
def foo; @foo; end | |
def foo=(f); @foo = f; end | |
end |
This file contains hidden or 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
# Runs the given array of +commands+ in parallel. The amount of spawned | |
# simultaneous jobs is determined by the `j' env variable and defaults to 1. | |
def parallel_execute(commands) | |
@jobs ||= ENV['j'] ? ENV['j'].to_i : 1 | |
queue = Queue.new | |
queue = commands.each { |command| queue << command } | |
Array.new(@jobs) do | |
Thread.new do | |
while command = queue.shift |
This file contains hidden or 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
class Proc | |
# "join" two procs | |
def +(other) | |
Proc.new { self.call; other.call } | |
end | |
end |
This file contains hidden or 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
# Java Classpath | |
if [[ -d "${HOME}/classes/" ]] | |
then | |
for jar in ${HOME}/classes/*.jar | |
do | |
CLASSPATH="${jar}:${CLASSPATH}" | |
done | |
fi |
This file contains hidden or 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 'sinatra/base' | |
require 'my_app' | |
run MyApp |