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
#!/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|
@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|
@mourdok
mourdok / gist:575805
Created September 12, 2010 03:19
Simple Xls to Html Converter
# To use this application, you need to install the following and specify RubyGem
# >> sudo gem install roo -v 1.3.11
# Which should return something like
# >> Successfully installed ruby-ole-1.2.10.1
# >> Successfully installed spreadsheet-0.6.4.1
# >> Successfully installed GData-0.0.4
# >> Successfully installed roo-1.3.11
# >> 4 gems installed
@beniwohli
beniwohli / unicode_to_latex.py
Created January 27, 2011 14:08
Map to convert unicode characters to their respective LaTeX representation
# original XML at http://www.w3.org/Math/characters/unicode.xml
# XSL for conversion: https://gist.github.com/798546
unicode_to_latex = {
u"\u0020": "\\space ",
u"\u0023": "\\#",
u"\u0024": "\\textdollar ",
u"\u0025": "\\%",
u"\u0026": "\\&",
@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',
@mrdwab
mrdwab / Stratified.R
Created May 21, 2011 17:06
R stratified random sampling from a data frame
stratified = function(df, group, size) {
# USE: * Specify your data frame and grouping variable (as column
# number) as the first two arguments.
# * Decide on your sample size. For a sample proportional to the
# population, enter "size" as a decimal. For an equal number
# of samples from each group, enter "size" as a whole number.
#
# Example 1: Sample 10% of each group from a data frame named "z",
# where the grouping variable is the fourth variable, use:
#
@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' )