Skip to content

Instantly share code, notes, and snippets.

View mrageh's full-sized avatar
💪
Waaat

Adam Magan mrageh

💪
Waaat
View GitHub Profile
@mrageh
mrageh / gist:6633419
Created September 20, 2013 04:48
dataset.rb - adam
require 'csv'
require "pry"
require "./attendee"
class DataSet
attr_reader :storage, :attendees
def initialize(file = "event_attendees.csv")
@file = file
@storage = []
end
@mrageh
mrageh / gist:6633429
Last active December 23, 2015 12:09
attendees - adam
require "pry"
class Attendee
attr_accessor :first_name, :last_name,
:zipcode, :city,
:email_address, :state,
:street, :homephone,
:regdate, :row
def initialize(row)
@first_name = row[:first_name]
@mrageh
mrageh / gist:6633432
Created September 20, 2013 04:50
event_reporter - adam
require "pry"
class EventReporter
def initialize
@queue = []
end
def run
input = ''
@mrageh
mrageh / gist:7798453
Last active December 30, 2015 07:49
users controller lol
def create
@user = User.new(user_params)
if @user.save && current_order.id
session[:user_id] = @user.id
current_order.update_attributes(:user_id => @user.id) # new line
current_order.save
redirect_to order_path(current_order.id), :notice => "Signed up!"
elsif @user.save && !current_order.id
session[:user_id] = @user.id
redirect_to menu_path
@mrageh
mrageh / about.md
Last active August 29, 2015 14:11 — forked from jasonrudolph/about.md
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', path: '~/programming/projects/rails', branch: '4-2-stable'
@mrageh
mrageh / sieve.rs
Created January 30, 2016 16:12
Basic implementation of Sieve of Eratosthenes
/// Find all prime numbers less than `n`.
/// For example, `sieve(7)` should return `[2, 3, 5]`
pub fn sieve(n: usize) -> Vec<usize> {
let mut p:usize = 2;
let range = p..n;
let mut list:Vec<usize> = vec![];
//build list
for x in range {
list.push(x);
@mrageh
mrageh / user.rb
Created June 25, 2016 15:26 — forked from harlow/user.rb
Extract a validator in Rails. Zip code validation.
# app/models/user.rb
class User < ActiveRecord::Base
validates :zip_code, presence: true, zip_code: true
end
@mrageh
mrageh / bosh-init-failure.log
Last active July 15, 2016 11:23
Bosh init failure log from following this CF tutorial https://docs.cloudfoundry.org/deploying/aws/setup_bosh_aws.html
[File System] 2016/07/14 21:41:44 DEBUG - Copying dir '/Users/Adam/.bosh_init/installations/924920ae-200f-404a-7704-9ac3c6cf284e/tmp/rendered-jobs553169157' to '/Users/Adam/.bosh_init/installations/924920ae-200f-404a-7704-9ac3c6cf284e/tmp/rendered-job-list-archive177362242/nats'
[File System] 2016/07/14 21:41:44 DEBUG - Copying dir '/Users/Adam/.bosh_init/installations/924920ae-200f-404a-7704-9ac3c6cf284e/tmp/rendered-jobs553169157/bin' to '/Users/Adam/.bosh_init/installations/924920ae-200f-404a-7704-9ac3c6cf284e/tmp/rendered-job-list-archive177362242/nats/bin'
[File System] 2016/07/14 21:41:44 DEBUG - Copying file '/Users/Adam/.bosh_init/installations/924920ae-200f-404a-7704-9ac3c6cf284e/tmp/rendered-jobs553169157/bin/nats_ctl' to '/Users/Adam/.bosh_init/installations/924920ae-200f-404a-7704-9ac3c6cf284e/tmp/rendered-job-list-archive177362242/nats/bin/nats_ctl'
[File System] 2016/07/14 21:41:44 DEBUG - Copying dir '/Users/Adam/.bosh_init/installations/924920ae-200f-404a-7704-9ac3c6cf284e/tmp/rendered-jobs553