Skip to content

Instantly share code, notes, and snippets.

@sr75
sr75 / spec_helper.rb
Created February 2, 2012 16:24
Example rails 3.1 spec_helper.rb file using spork, rspec, factory_girl, database_cleaner, I18n
require 'spork'
Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
@sr75
sr75 / httpi_fork_perl_shell
Created August 26, 2011 14:36
httpi fork perl process for shell script (.pl,.ksh) file name passed through url
#!/bin/perl
($var_name, $process_name) = split(/=/,$ENV{'QUERY_STRING'});
print "HTTP/1.0 200 OK\r\n";
print "Content-type: text/plain\r\n\r\n";
print "OK";
#print $ENV{'QUERY_STRING'};
$process_path = "";
@sr75
sr75 / csv_to_array
Created August 26, 2011 13:19
csv_to_array
def csv_to_array(file_location)
csv = CSV::parse(File.open(file_location, 'r') {|f| f.read })
fields = csv.shift
csv.collect { |record| Hash[*(0..(fields.length - 1)).collect {|index| [fields[index],record[index].to_s] }.flatten ] }
end