Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Roberto Salas robsalasco

🏠
Working from home
View GitHub Profile
View file_organizer.rb
#!/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 )
View foia.rb
# 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
View bookmarklet_template.js
// TODO: remove spaces and newlines
javascript:(function(){
s=document.createElement('script');
s.type='text/javascript';
s.src='http://example.com/bookmarklet.js';
document.body.appendChild(s);
})();
// TODO: bookmarklet code needs to be in an anchor tag
// <a href="javascript:(function(){s=document.createElement('script');s.type='text/javascript';s.src='http://example.com/bookmarklet.js';document.body.appendChild(s);})();">My Bookmarklet</a>
@hank
hank / mdshooters_rss.rb
Created Aug 23, 2009
Provides code to generate a feed of classified ads
View mdshooters_rss.rb
require 'rubygems'
require 'open-uri'
require 'hpricot'
require 'rss/maker'
version = "2.0"
destination = "mdshooters_classifieds.xml"
content = RSS::Maker.make(version) do |m|
m.channel.title = "MDShooters Classifieds RSS"
We couldn’t find that file to show.
@mr-rock
mr-rock / sinatra_jquery_test.rb
Created Oct 9, 2009
An example of Sinatra working with Ajaxified JQuery based on some pieces of code published by Rafael George on the Sinatra Google Group.
View sinatra_jquery_test.rb
require 'sinatra'
require 'dm-core'
require 'haml'
DataMapper.setup(:default, 'sqlite3::memory:')
class Message
include DataMapper::Resource
property :id, Serial
View example_feed.rb
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 Apr 4, 2010
GoogleVisualr::PieChart Creation Example
View example_controller.rb
# 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
Simple way to load Rails plugins in Sinatra
View plugin_loader.rb
# 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
View Custom Feedzirra Flickr parser
module Feedzirra
module Parser
class FlickrEntry
include SAXMachine
include FeedEntryUtilities
element :guid, :as => :id
element :link, :as => :url