Skip to content

Instantly share code, notes, and snippets.

View agilous's full-sized avatar

Bill Barnett agilous

View GitHub Profile
#!/usr/bin/php
// Submitted by Karl Wilbur @karlwilbur
<?php
$filename = $_SERVER['argv'][1];
if (!file_exists($filename)) die('File "'.$filename.'" does not exist.');
if (!is_readable($filename)) die('File "'.$filename.'" is not readable.');
error_reporting(0);
@agilous
agilous / 0-README.textile
Created October 4, 2011 12:53
Ubuntu 11.10 Ruby Development Environment

Motivation:

This system is intended to be used by American high school students with little or no programming experience and ZERO Linux system administration experience. A seasoned developer will find this setup too simplistic since many of the tools that a proficient Ruby developer relies on but which might confuse a novice Rubyist have been omitted.

Here are some pain points encountered when novice developers where initiated using a “typical” Linux-based development system:

  • Explaining the need for Bundler & RVM/rb-env drastically increased the learning curve.
  • Editors like emacs and vi were too esoteric for novice developers.
  • Choosing Heroku & PostgreSQL permitted us to simply “gloss over” the deployment process.
@agilous
agilous / caha-csv-schedule-to-ical.rb
Created October 21, 2011 03:56
Ruby script to convert Cincinnati Amateur Hockey Association CSV schedule to iCalendar format.
#!/usr/bin/env ruby
require 'rubygems'
require 'csv'
require 'date'
require 'icalendar'
if ARGV.last.nil?
puts "You must pass the path to the CSV file as an argument to this script."
exit
end
@agilous
agilous / bpa-competetive_event-list.rb
Created October 24, 2011 01:43
Parser for the BPA Competitive Event List
#!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
def parse_event_number_and_name(text)
number, name = $1, $2 if text =~ /\(([a-zA-Z0-9]+)\)\s(.*):/
end
doc = Nokogiri::HTML(open('http://www.bpa.org/compete/eventlist'))
@agilous
agilous / gist:1313000
Created October 25, 2011 14:51
Attempting to install imagemagick via brew.
brew install imagemagick
==> Installing imagemagick dependency: jpeg
==> Downloading http://www.ijg.org/files/jpegsrc.v8c.tar.gz
######################################################################## 100.0%
Error: MD5 mismatch
Expected: a2c10c04f396a9ce72894beb18b4e1f9
Got: d93c9ea92e9e2ad0eb1d2df648f56ad5
# Account suspended by Site5. :( http://www.ijg.org/files/jpegsrc.v8c.tar.gz
less jpegsrc.v8c.tar.gz
#!/usr/bin/env ruby
require 'date'
def months_between(start, stop)
diff = (stop - start)
(diff/30).floor.to_i + (diff % 30 > 15 ? 1 : 0)
end
(0..12).each do |i|
(0..100).each do |j|
@agilous
agilous / urinal_etiquette.rb
Created February 21, 2012 23:19 — forked from st23am/urinal_etiquette.rb
Test Problem
class Ptest
def initialize(stalls)
@stalls = Array.new(stalls).map { |s| s = false }
end
def stalls
@stalls
end
def empty?
@agilous
agilous / RailsOnWindows.markdown
Created March 2, 2012 00:05
Ruby on Rails on Windows guide created 2009-03-13

I was recently forced to press my old Windows desktop system into an emergency Rails development platform. During a recent Cincinnati Ruby Brigade meeting a new member who was running Windows would have benefited from a minimalist guide to installing Ruby on Rails on Windows.

Thanks to All About Ruby for providing a starting point for my research for this post.

Nota Bene: These instructions are Windows XP specific. If you're using another flavor of Windows YMMV.

Install Ruby

  1. Download the One-Click Ruby Installer for Windows.
  2. Run the installer. I unchecked the option to install the SciTE text editor which saved a whopping 1.5MB of storage.
@agilous
agilous / apache-access-log-parser.rb
Created April 28, 2012 04:07
Apache access log parser
#!/usr/bin/env ruby
# Helpful link: http://httpd.apache.org/docs/2.4/logs.html
require 'date'
line_count = 0
File.open(ARGV[0]).readlines.each do |line|
line_count += 1
result = /^(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}).*\[(.*)\].*(GET|HEAD|POST|PUT|DELETE|TRACE|CONNECT)\s(.*)\"\s(\d+)\s(\d+)(.*)$/.match(line)
@agilous
agilous / qcmerge-attendee-email.txt
Created May 8, 2012 15:22
QC Merge Attendee Email
Hello QC Mergers!
I hope you're as psyched about the event as we are. More work has gone into putting it all together than we expected when we began planning seven months ago but we think you'll agree that it has been worth it.
Workshops
---------
Please help us ensure that there is sufficient seating for the workshops by completing the survey below as soon as possible:
https://docs.google.com/spreadsheet/viewform?formkey=dEk4SmFqRWh3QTZ3SzVBcUFiSXRoakE6MQ