Skip to content

Instantly share code, notes, and snippets.

View robsalasco's full-sized avatar
🏠
Working from home

Roberto Salas robsalasco

🏠
Working from home
View GitHub Profile
require 'csv'
require 'pry'
file = 'lackp_starting_rosters.csv'
# Create an empty teams hash
teams = {}
# Open up the CSV and save it to the variable csv
csv = CSV.open(file, headers: true)
require "sinatra"
require "csv"
require "shotgun"
before do
@players = []
CSV.foreach('lackp_starting_rosters.csv', headers: true, header_converters: :symbol) do |row|
@players << {
name: row[0] + ' ' + row[1], position: row[2], team_name: row[3]
}
#!/usr/bin/env ruby
#
# file_organizer.rb
# (http://gist.github.com/16180)
#
# By M@ McCray -- www.mattmccray.com (matt at elucidata dot net)
#
# Usage:
#
# organize_files_within( target_folder )
@trek
trek / foia.rb
Created January 26, 2009 20:35
# convert PDF to jpg
# use sips if available, ImageMagick(`convert`) with ghostscript otherwise
# convert -quality 90 /Users/trek/Desktop/postcard.pdf /Users/trek/Desktop/postcard.png
#
# postful image should be
#
# 6.25"x4.5" (450x324)
# 0.125" trim
# 300dpi
# 1875x1350
We couldn’t find that file to show.
require 'rubygems'
require 'feedzirra'
# gem install feedzirra
url = "http://sunlightlabs.com/blog/feeds/tag/datacatalog/"
feed = Feedzirra::Feed.fetch_and_parse(url)
puts feed.title
puts feed.url
puts feed.feed_url
@winston
winston / example_controller.rb
Created April 4, 2010 11:41
GoogleVisualr::PieChart Creation Example
# http://code.google.com/apis/visualization/documentation/gallery/piechart.html#Example
def pie_chart
@chart = GoogleVisualr::PieChart.new
@chart.add_column('string', 'Task')
@chart.add_column('number', 'Hours per Day')
@chart.add_rows(5)
@chart.set_value(0, 0, 'Work' )
@chart.set_value(0, 1, 11 )
@chart.set_value(1, 0, 'Eat' )
@robhurring
robhurring / plugin_loader.rb
Created May 18, 2010 15:42
Simple way to load Rails plugins in Sinatra
# Simple bootloader for Rails plugins in Sinatra
# This checkes the +plugin_folder+ for plugin-like bundles. For each folder it finds it will do:
# If the +lib+ folder exists: add it to our load path
# If a +init.rb+ file exists: require it
# Not very robust but it is lightweight for loading simple rails plugins
class PluginLoader
attr_reader :plugin_folder
def initialize(plugin_folder)
@plugin_folder = plugin_folder
@marano
marano / Custom Feedzirra Flickr parser
Created June 12, 2010 17:19
Custom Feedzirra parsers
module Feedzirra
module Parser
class FlickrEntry
include SAXMachine
include FeedEntryUtilities
element :guid, :as => :id
element :link, :as => :url
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
$KCODE = 'UTF8'
require 'rubygems'
require 'google-search'
query = ARGV[0] || "paris hilton"
HTML = File.dirname(__FILE__) + '/face.html'
open(HTML, 'w') do |file|