- Start a Sinatra server on port 4000
- GET / to that server triggers a
git pull
and mod_rails restart - Hit port 4000 locally after pushing
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 'rubygems' | |
if RUBY_VERSION >= "1.9.0" | |
require 'csv' | |
else | |
require 'fastercsv' | |
CSV = FasterCSV | |
end | |
# Write out dummy data file |
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
# Rake task to automatically run something (i.e. specs) when code files are changed | |
# By Peter Çoopér | |
# | |
# Motivation: I couldn't get autotest to run on my Sinatra project for some reason but realized | |
# it didn't require overengineering. Just detect when a file is changed and then re-run the specs! | |
# | |
# Examples: | |
# # rake on_update "rake" | |
# # rake on_update "spec spec/user_spec.rb" | |
# |
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
# Create a new git repository on Dreamhost | |
# Function tweaked from that found at http://craigjolicoeur.com/blog/hosting-git-repositories-on-dreamhost | |
# | |
# Just add the code below to your .bashrc. | |
# Usage: | |
# newgit some-repo.git | |
# | |
# Then locally: | |
# | |
# git push --all ssh://$MACHINE/home/$USER/git/my-new-repos.git |
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
$ gem push pkg/choice-0.1.4.gem | |
Pushing gem to Gemcutter... | |
You do not have permission to push to this gem. | |
$ gem migrate choice | |
Starting migration of choice from RubyForge... | |
A migration token has been created. | |
Uploading the migration token to choice.rubyforge.org. Please enter your RubyForge login: | |
Login: defunkt | |
Password: |
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
# A horribly scrappy "just for fun" entry into Satish Talim's latest Ruby | |
# challenge. Didn't want to use any libraries, etc, just bashed at it true 1980s style! | |
# It makes the assumption, as was raised in several comments, that the first time in | |
# the array is the first of the "block" of times.. | |
def average_time_of_day(times) | |
pr = nil | |
times.map! do |t| | |
h,m = t.scan(/\d+/).map(&:to_i) | |
h += 12 if t =~ /pm/ || (pr && h < pr) |
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
*** LOCAL GEMS *** | |
actionmailer (2.2.2, 1.3.6) | |
actionpack (2.2.2, 1.13.6) | |
actionwebservice (1.2.6) | |
activerecord (2.2.2, 1.15.6) | |
activeresource (2.2.2) | |
activesupport (2.2.2, 1.4.4) | |
acts_as_ferret (0.4.3) |
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
# RUBY MAZE CHALLENGE | |
# By Peter Cooper | |
# | |
# = INTRODUCTION | |
# | |
# Mazes are known to have challenged humans from as far back as the 5th century | |
# BC. There are many types of maze, but typically you need to find your way | |
# from a start point to an end point. | |
# | |
# In this Ruby challenge, you will need to develop a class that can be used to| |
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
# Peter Cooper's initial Maze solution | |
class Maze | |
START_CHARACTER = 'A' | |
END_CHARACTER = 'B' | |
WALL_CHARACTER = '#' | |
def initialize(maze) | |
# Get the height and width of the maze | |
@maze_width = maze[/^.*?\n/].length - 1 |