Skip to content

Instantly share code, notes, and snippets.

@jamis
jamis / maze.hs
Last active August 29, 2015 14:27
An implementation of the Recursive Backtracker maze generation algorithm in Haskell
{- --------------------------------------------------------------------------
- A naive random maze generator.
-
- $ ghc -o maze Maze.hs
- $ maze 10 10
-
- Author: Jamis Buck (jamis@jamisbuck.org)
- ------------------------------------------------------------------------ -}
module Main where
@jamis
jamis / maze.erl
Created August 17, 2015 20:05
An implementation of the Recursive Backtracker maze generation algorithm in Erlang
-module(maze).
-export([generate/2,north/3,south/3,west/3,east/3,visualize/1]).
% Generate and return a maze of width W and height H.
generate(W,H) -> try_directions(random:uniform(W)-1, random:uniform(H)-1, directions(), {width,W,height,H,0}).
% Returns true if there is a passage north from the given position in the maze.
north(X,Y,Maze) -> at(X,Y,Maze) band 2#1 =/= 0.
% Returns true if there is a passage south from the given position in the maze.
# Rack::Test doesn't support hitting external webservers. However, when a user enters their credit card info,
# it is submitted directly to braintree, so we need to intregration test with hitting an external server.
# This hack enabled this, by swapping out the Rack::Test's rack app with a Rack::Client instance.
# Rack::Client acts just like a rack app, but under the covers it delegates to Net::HTTP.
require 'rack/client'
module RackTestHack
def new(*a, &b)
$ rvm ruby-1.9.2-p136@ingredients
$ gem list
animalcracker (0.0.2)
bacon (1.1.0)
beet (0.6.9)
berry (0.0.0)
breadcrumbs (0.1.5)
butternut (0.2.1)
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class BuildStatusTest < ActiveSupport::TestCase
test "remove the old statii" do
assert_equal 2, BuildStatus.count
BuildStatus.expire_old
statii = BuildStatus.all
assert_equal 1, statii.size
assert statii[0].updated_at >= 30.days.ago
end
#!/usr/bin/env ruby
# Script for OS X users to install and run the latest nightly Chromium build
#
# Save as file as "chromium_update" in your $PATH; and chmod +x chromium_update
#
# Written by Dr Nic Williams and Bo Jeanes from Mocra; drnicwilliams@gmail.com
require "fileutils"
include FileUtils
@bsodmike
bsodmike / application.rb
Last active September 27, 2015 07:08
Modified config/application.rb to print out initialization points for Rails 3.2.11
require File.expand_path('../boot', __FILE__)
require 'rails/all'
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
@basgys
basgys / gist:1482038
Created December 15, 2011 17:47
Trigger call to all passenger instances
#!/bin/bash
if [ -z $1 ]; then
echo "Usage : "$0" http://passenger_address"
else
echo "address to call: "$1
passenger-status --verbose | grep 'Password:' | cut -d ':' -f2 | while read line; do
echo "Calling : "$line # Passenger instance password
curl --header "X-Passenger-Connect-Password: "$line $1 > /dev/null 2>&1
@jeremyf
jeremyf / fast-one.rb
Created May 10, 2012 17:51
A command line tool to help with testing pull requests.
#!/usr/bin/env ruby
# Before you use this:
# git clone git://github.com/some-other-user/their-repo
# This assumes that origin is the repo that you are merging into!
require 'rubygems'
gem 'rest-client'
gem 'crack'
require 'rest-client'
@ryanb
ryanb / favorite_gems.md
Created March 4, 2011 17:31
A list of my favorite gems for various tasks.