Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / rvm-quick-setup.txt
Created March 14, 2012 13:55
rvm quick setup examples
# from your user dir
cd
# create or update .bash_profile
touch .bash_profile
# Install RVM: (https://rvm.io/rvm/install/)
curl -L get.rvm.io | bash -s stable
@sr75
sr75 / run-ie-7-8-9-virtualbox-on-osx.txt
Created March 15, 2012 13:52
Run IE 7, 8, and 9 in Mac OS X
# the admin password for all of the IE VMs is “Password1″ without the quotes, it's also used for the password hints
1) Install VirtuaBox on your mac
http://download.virtualbox.org/virtualbox/4.1.10/VirtualBox-4.1.10-76795-OSX.dmg
2) Decide which versions of Internet Explorer you want to download and install – each version of Internet Explorer is contained within a separate virtual machine that runs within VirtualBox. In other words, if you want to run Internet Explorer 7, 8, and 9, you will need to download three separate VM’s, which may take a while so keep that in mind. Select the text below and copy it:
# Install ALL versions of Internet Explorer: IE 7, IE 8, and IE 9 (for now this script will also pull down a IE 6 vm with windows xp)
@sr75
sr75 / parse_decimal_from_string.rb
Created March 21, 2012 13:37
parse decimal from string example method
def parse_decimal_from_string(value)
value.scan(/[-+]?\d*\.?\d+/).join('')
end
@sr75
sr75 / centos6-barebones-vps-rails-server-walkthrough
Last active October 2, 2015 12:38
centos6-barebones-vps-rails-server-walkthrough (rvm, nginx, mysql, memcached)
# 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
sr75 / create-mysql-app-user-example.sql
Created April 4, 2012 20:58
create mysql app user example
CREATE USER 'sysadmin'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON `appname_environment`.* TO 'sysadmin'@'localhost';
@sr75
sr75 / Gemfile
Created April 11, 2012 16:06
Refinery + Twitter Bootstrap WIP
source 'https://rubygems.org'
gem 'rails', '3.2.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
@sr75
sr75 / .gitconfig
Last active October 24, 2019 21:17
gitconfig for git v1.8+ with terminal color and command aliases
[user]
name = yourname
email = yourname @ whatever
[core]
excludesfile = yourhomedir/.gitignore
#git config --global core.eol lf
#git config --global core.autocrlf input
eol = lf
autocrlf = input
#git rm -rf --cached .