Skip to content

Instantly share code, notes, and snippets.

View csv_to_array
def csv_to_array(file_location)
csv = CSV::parse(, 'r') {|f| })
fields = csv.shift
csv.collect { |record| Hash[*(0..(fields.length - 1)).collect {|index| [fields[index],record[index].to_s] }.flatten ] }
sr75 / httpi_fork_perl_shell
Created Aug 26, 2011
httpi fork perl process for shell script (.pl,.ksh) file name passed through url
View httpi_fork_perl_shell
($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 / spec_helper.rb
Created Feb 2, 2012
Example rails 3.1 spec_helper.rb file using spork, rspec, factory_girl, database_cleaner, I18n
View spec_helper.rb
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 / rvm-quick-setup.txt
Created Mar 14, 2012
rvm quick setup examples
View rvm-quick-setup.txt
# from your user dir
# create or update .bash_profile
touch .bash_profile
# Install RVM: (
curl -L | bash -s stable
sr75 / parse_decimal_from_string.rb
Created Mar 21, 2012
parse decimal from string example method
View parse_decimal_from_string.rb
def parse_decimal_from_string(value)
sr75 / centos6-barebones-vps-rails-server-walkthrough
Last active Oct 2, 2015
centos6-barebones-vps-rails-server-walkthrough (rvm, nginx, mysql, memcached)
View centos6-barebones-vps-rails-server-walkthrough
# CentOS 6.4 barebones walkthrough guide for a new vps rails server instance
# assumes you already have a personal ssh key locally
# script implements the following security approaches:
# disables root login
# configures ssh setup for deployer user
# opens up standard ports
# setup includes:
# rvm & ruby-1.9.3-p429
sr75 / create-mysql-app-user-example.sql
Created Apr 4, 2012
create mysql app user example
View create-mysql-app-user-example.sql
CREATE USER 'sysadmin'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON `appname_environment`.* TO 'sysadmin'@'localhost';
sr75 / Gemfile
Created Apr 11, 2012
Refinery + Twitter Bootstrap WIP
View Gemfile
source ''
gem 'rails', '3.2.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://'
gem 'sqlite3'
sr75 / 0.
Created Jul 25, 2012 — forked from mikhailov/0.
Nginx+Unicorn (production-ready setup)
View 0.
# Nginx optimal congifuration guide.
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies.
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module
$ cd /usr/src
$ wget
$ tar xzvf ./nginx-1.2.2.tar.gz && rm -f ./nginx-1.2.2.tar.gz
$ wget
sr75 / Gemfile
Created Jul 25, 2012 — forked from flomotlik/Gemfile
Unicorn config for cedar stack on Heroku.
View Gemfile
gem 'unicorn'