Skip to content

Instantly share code, notes, and snippets.

@igrabes
igrabes / github_caller.rb
Last active August 29, 2015 14:14
call Github
require 'httparty'
require 'pry'
class User
def initialize(username, score, reposcore)
@username = username
@score = score
@reposcore = reposcore
@reponame = ""
@igrabes
igrabes / gist:9798301
Created March 27, 2014 01:50
Request Logger - Write request info to mongo via a sinatra app
require 'sinatra'
require 'mongo'
require 'json'
class RequestLogger
include Mongo
attr_accessor :ip, :path, :method, :body, :url_params
def self.log(request)
@igrabes
igrabes / gist:2114285
Created March 19, 2012 14:29
Adding permissions to mixtapes
#Mixtape Controller
def share
@mixtape = Mixtape.find(params[:id])
@shared_user = User.find(params[:user])
@shared_permission = params[:permission].to_sym
@mixtape.add_user(@shared_user, @shared_permission) if @mixtape.user_mixtapes.find_by_user_id_and_permission(@shared_user,@shared_permission)
@igrabes
igrabes / 2nd iteration.rb
Created March 8, 2012 15:00
Code Project
require 'date'
all_files = []
file_path = "./"
Dir.foreach(file_path) do |file_name|
next if file_name == "." || file_name == ".." || file_name == ".DS_Store" || file_name == "data_display.rb" || file_name == "cyrus_data_display" #potentially could refactor this into a while file_name.includes(/.rb/)
puts "got #{file_name}"
#Can refactor to a case statement
@igrabes
igrabes / gist:1471001
Created December 13, 2011 07:07
HTML Scraper
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'sqlite3'
require 'active_record'
require 'active_support'
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
@igrabes
igrabes / gist:1362714
Created November 13, 2011 21:07
secret_santa (gideon)
@list = Array.new
puts "Please enter all of the people that will be participating in this years Secret Santa"
while true
input = gets.chomp
@igrabes
igrabes / Part 1 Secret Santa Code
Created November 9, 2011 14:24
Secret Santa Program
list = Array.new
puts "Please enter all of the people that will be participating in this years Secret Santa"
while true
input = gets.chomp
if input == ''
break
end
@igrabes
igrabes / gist:1250134
Created September 29, 2011 06:52
CSV Parser
require 'csv'
class CsvReader
def initialize
@number_of_entries = []
end
def read_in_csv_data(csv_file_name)
CSV.foreach(csv_file_name, headers: true ) do |row|
@number_of_entries << ValueInCells.new( row["Amount"])
@igrabes
igrabes / gist:1077134
Created July 12, 2011 00:43
Rake Routes - 7-11-11
root /(.:format) {:controller=>"pages", :action=>"home"}
sessions GET /sessions(.:format) {:action=>"index", :controller=>"sessions"}
POST /sessions(.:format) {:action=>"create", :controller=>"sessions"}
new_session GET /sessions/new(.:format) {:action=>"new", :controller=>"sessions"}
edit_session GET /sessions/:id/edit(.:format) {:action=>"edit", :controller=>"sessions"}
session GET /sessions/:id(.:format) {:action=>"show", :controller=>"sessions"}
PUT /sessions/:id(.:format) {:action=>"update", :controller=>"sessions"}
DELETE /sessions/:id(.:format)
@igrabes
igrabes / gist:1057810
Created July 1, 2011 03:21
6-30-11 Rake Routes
root /(.:format) {:controller=>"pages", :action=>"home"}
sessions GET /sessions(.:format) {:action=>"index", :controller=>"sessions"}
POST /sessions(.:format) {:action=>"create", :controller=>"sessions"}
new_session GET /sessions/new(.:format) {:action=>"new", :controller=>"sessions"}
edit_session GET /sessions/:id/edit(.:format) {:action=>"edit", :controller=>"sessions"}
session GET /sessions/:id(.:format) {:action=>"show", :controller=>"sessions"}
PUT /sessions/:id(.:format) {:action=>"update", :controller=>"sessions"}
DELETE /sessions/:id(.:format)