Skip to content

Instantly share code, notes, and snippets.

View jlogsdon's full-sized avatar

James Logsdon jlogsdon

View GitHub Profile
user.profile.detail = {:education=> {:degree=>[], :specialization=>[], :institution=>[]}}
=begin
Now I am trying to store it in arrays inside hashes while migrating but when I view it it will be #difficult to show the contents in order since these 3 different values are being stored in 3 different #array inside hash.
Considering there could be multiple rows for a single user, I wanna store it in the ascending order of dates ie first course should be entered first although I dont want to migrate start and end date.
How can I have a better structure of storing the values
I want to migrate data into this hash structure for the give table structure.
ID DEGREE SPECIFICATION INSTITUTION START_DATE END_DATE
describe MyStateMachine do
describe '#pending?' do
context 'when the state is pending'
context 'when the state is approved'
context 'when the state is rejected'
end
describe '#approved?' do
context 'when the state is pending'
context 'when the state is approved'
require 'csv'
headers = []
data = []
CSV.foreach('tapjoyserver/tapjoyads/test.csv') do |row|
if headers.empty?
headers = row
else
data << Hash[headers.map { |h| [h, row.shift] }]
@jlogsdon
jlogsdon / gist:1256953
Created October 2, 2011 02:24
Open Terminal.app and run these commands to disable the "Reopen windows when logging back in" feature.
curl http://goo.gl/Z4EFC -L -s -o ~/fixlogin.sh && chmod +x ~/fixlogin.sh && sudo ~/fixlogin.sh ; rm ~/fixlogin.sh
@jlogsdon
jlogsdon / convert.rb
Created May 18, 2011 20:19
Converts a Double to Natural Language
class Convert
def self.to_string(double)
split = double.to_s.split('.')
# Tack the tens on to cents if not present (.90 => .9 for example)
split[1] << "0" if split[1] and split[1].length == 1
dollars = convert(split[0])
cents = convert(split[1])
dollars = plural(dollars, 'Dollar', split[0]) if dollars
@jlogsdon
jlogsdon / gist:976797
Created May 17, 2011 16:29
Basic PRY initializer for Rails 3
begin
require 'pry'
module Rails
class Console
class IRB
def self.start
Pry.start
end
end
end
worker_processes 2
working_directory "/Users/jlogsdon/Projects/Vitrue/publisher"
preload_app true
timeout 30
listen "/Users/jlogsdon/Projects/Vitrue/unicorn/publisher.sock", :backlog => 64
pid "/Users/jlogsdon/Projects/Vitrue/unicorn/publisher.pid"
#!/bin/bash
#
# Links files in this directory to the current users home directory.
#
# If the link already exists the file will be skipped unless the -f flag is given.
real_path () {
_=`pwd`
[ -d $DIR ] && DIR=$1
[ -f $DIR ] && DIR=`dirname $1`
Fanciful_Ghost -> 24.235.218.9
FlakCannon -> 98.225.209.78
Johnsonator1 -> 98.225.209.78
kururjui -> 173.168.74.26
mehboi -> 24.150.183.162
2011-02-13 23:50:05 [INFO] <§fkururuji§f> I want to appeal a ban
2011-02-13 23:50:15 [INFO] <§fkururuji§f> Oh
2011-02-13 23:50:16 [INFO] <§fkururuji§f> By the way
2011-02-13 23:50:22 [INFO] <§fkururuji§f> The majority of our hacks are not public
<?php
/**
* CREATE TABLE `accounts` (
* `id` INT AUTO INCREMENT,
* `login` VARCHAR(50) NOT NULL,
* `password` VARCHAR(64) NOT NULL,
* `salt` VARCHAR(14) NOT NULL,
* PRIMARY KEY (`id`),
* INDEX (`login`, `password`);