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
@mourdok
mourdok / gist:498516
Created July 29, 2010 16:03
11 coisas que estudantes não aprenderiam na escola

11 coisas que estudantes não aprenderiam na escola.

Acredito nas palavras abaixo, os pais devem dar mais limites e responsabilidades aos seus filhos por pior que pareça. A vida pode ser cruel, e a crueldade pode atingir qualquer um, principalmente aqueles que não tem os pés firmes no chão.

Para qualquer pessoa com filhos de qualquer idade ou qualquer pessoa que já foi criança, aqui estão alguns conselhos de Bill Gates em uma conferência de uma escola secundária sobre 11 coisas que estudantes não aprenderiam na escola. Ele fala sobre como a política do "sentir-se bem" tem criado uma geração de crianças sem conceito da realidade e como esta política tem levado as pessoas a falharem em suas vidas posteriores à escola (não é à-toa que ele é um dos homens mais bem sucedidos e ricos do mundo).

Regra 1:

A vida não é fácil - acostume-se com isso.

## Concatenates a subset of columns in Excel amongst multiple sheets into one dump
require "rubygems"
require "active_support"
require "roo"
require "faster_csv"
COLUMNS = ["A", "B"] # Column names of whatever you want
[].tap do |o|
@jrpz
jrpz / dirfiles_combine.rb
Created March 18, 2011 19:45
Combine text based files within a directory into a single file. Requires 'directory' and 'file' parameters.
dir = Dir.new(ARGV[0])
file = File.open(ARGV[1], 'w')
dir.each{|d|
if (d[0] != '.')
f = File.open(ARGV[0] + d)
file.write(f.read)
f.close
end
}
file.close
require 'spreadsheet'
book = Spreadsheet.open 'teams.xls'
sheet = book.worksheet 0
sheet.each do |row|
team = Team.new
team.name = row[0].strip
team.code = row[1].strip
team.save
require 'sinatra'
require 'active_record'
require 'haml'
require 'bluecloth'
require 'cgi'
require 'rack/csrf'
require 'logger'
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
@winston
winston / controller.rb
Created July 1, 2011 06:12
GoogleVisualr Gem - Pie Chart Creation Example
# http://code.google.com/apis/chart/interactive/docs/gallery/piechart.html#Example
def pie_chart
data_table = GoogleVisualr::DataTable.new
data_table.new_column('string', 'Task')
data_table.new_column('number', 'Hours per Day')
data_table.add_rows(5)
data_table.set_cell(0, 0, 'Work' )
data_table.set_cell(0, 1, 11 )
data_table.set_cell(1, 0, 'Eat' )
@metaspatial
metaspatial / jquery.cycle.lazy.js
Created September 21, 2011 10:29
Lazy-loading slideshow with jquery.cycle
// this is a rudimentary attempt to implement a slideshow that doesn't saturate downloads with every image upon page load; instead the first slide is embedded in the HTML and loads with the page immediately, the second upon DOM ready, and subsequent upon the advance of each slide; additionally a progress indicator is displayed and slideshow paused if the next slide is still downloading thus preventing displaying partially downloaded images, or missing images entirely
var slides = [ // this is an array of the html representing each slide to display, in reverse order starting with the second slide (the first should be in the HTML page, see below); this markup may contain anything (e.g. li, div, captions) and should have corresponding css, but the first img tag is assumed to be the main image which we monitor for its download state
'<img src="/path/to/file4.jpg">',
'<img src="/path/to/file3.jpg">',
'<img src="/path/to/file2.jpg">',
];
// callback functions
function loadedSlide(){
@danishkhan
danishkhan / torrents_rss_downloader.rb
Created October 11, 2011 07:03
Script to automatically download torrents from an RSS feed
require 'rubygems'
require 'feedzirra'
require 'whenever'
=begin
Simple script to auto download new torrents from an RSS feed.
You can then utilize whenever and create a cronjob to run the
script at a specified interval.
=end
@samleb
samleb / linkbucks.user.js
Created January 17, 2012 21:40
[userscript] LinkBucks: Redirect to target URL skipping countdown
// ==UserScript==
// @name LinkBucks.com - Auto redirect
// @namespace samleb.github.com
// @description Redirect to target URL skipping countdown.
// @include http*://*.linkbucks.com/
// ==/UserScript==
(function() {
var REGEXP = /TargetUrl\s*=\s*([^;\n]*)/,
urlLiteral = document.body.innerHTML.match(REGEXP)[1],
@fabianoalmeida
fabianoalmeida / gist:1675767
Created January 25, 2012 10:32
Update entries from Feedzirra
require 'activesupport'
require 'feedzirra'
feed = Feedzirra::Parser::RSS.new
feed.feed_url = "http://feeds.feedburner.com/gizmodobr?format=xml" # URL from my database
feed.last_modified = Time.utc(2012, 1, 1) # Feed from my database
entry = Feedzirra::Parser::RSSEntry.new
entry.url = "http://feedproxy.google.com/~r/gizmodobr/~3/5YLB2D-K49w/story01.htm" # Last entry URL on my database