Skip to content

Instantly share code, notes, and snippets.

View rafapolo's full-sized avatar

Rafael Polo rafapolo

View GitHub Profile
class PopulaEstadosCidades < ActiveRecord::Migration
def self.up
Estado.create(:sigla => 'AC', :nome => "Acre") do |e|
e.cidades.build(:nome => "Acrelândia")
e.cidades.build(:nome => "Assis Brasil")
e.cidades.build(:nome => "Brasiléia")
e.cidades.build(:nome => "Bujari")
e.cidades.build(:nome => "Capixaba")
e.cidades.build(:nome => "Cruzeiro do Sul")
e.cidades.build(:nome => "Epitaciolândia")
#!/usr/bin/python
# -*- coding: latin1 -*-
# author: rafael polo
# created_at: 06.out 3am
print "============"
print "Carregando libs..."
import re
try:
import matplotlib.pyplot as plt
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# author: rafael polo
WIKI_PAGE = 'http://pt.wikipedia.org/w/index.php?title=Fisica&printable=yes'
print "============"
print "Carregando libs..."
import urllib2, re, htmlentitydefs
try:
#!ruby
#encoding: utf-8
#data: out-2010
morses = {
'a' => '.-',
'b' => '-...',
'c' => '-.-.',
'd' =>'-..',
'e' => '.',
@rafapolo
rafapolo / image-frame.pde
Created December 3, 2010 00:59
salva cada frame de um movie como uma imagem
import processing.video.*;
Movie myMovie;
float framesPerSecond = .1;
float currentSecond = 0;
int frame = 0;
void setup() {
size(640, 480, P3D);
@rafapolo
rafapolo / get_video_name.rb
Created December 3, 2010 01:07
Pega o título do vídeo no youtube ou no vimeo a partir da URL.
def get_video_name(url)
begin
if url.index("vimeo")
id = url.match(/(\d+)/)[0]
link = "http://vimeo.com/api/v2/video/#{id}.json"
result = JSON.parse(open(link).read)
name = result[0]["title"]
else
# youtube
id = url.match(/=([\w]+)/)[1]
@rafapolo
rafapolo / conca-translator.js
Created December 19, 2010 21:16
corrige os problemas do teclado do Conca
$("#translate").click(function(){
var means = $("#wrote").val();
means = means.replace(/xc/g, "c")
means = means.replace(/we/g, "e")
means = means.replace(/ew/g, "e")
means = means.replace(/sd/g, "d")
means = means.replace(/ds/g, "d")
$("#means").text(means);
})
@rafapolo
rafapolo / virus-natale-2010.java
Created December 22, 2010 03:06
adiciona a toca do papai noel em todo rosto detectado em todas as imagens .jpg do usuário com menos de 1mb
// author: Rafael Polo
// created_at: 21.dez.2010
import hypermedia.video.*;
import java.awt.Rectangle;
import javax.swing.JOptionPane;
OpenCV opencv;
PImage marca;
@rafapolo
rafapolo / DamnatioMemoriae.java
Created January 25, 2011 13:44
Damnatio Memoriae is a conceptual-virus that appends a black stripe over jpeg images with faces
/*
======================
~ Damnatio Memoriae ~
======================
a conceptual-virus that appends a black stripe over jpeg images with faces
======================
author | Rafael Polo
======================
Memefest | International festival of radical communication memefest.org
======================
@rafapolo
rafapolo / parallelnews.rb
Created February 15, 2011 18:28
pega as top stories do google news e lista as notícias paralelas aplicando outra cor às palavras já ditas.
#encoding: utf-8
class FrontController < ApplicationController
def list
coder = HTMLEntities.new
@entries = []
url = "http://news.google.com/?output=rss"
link = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=10&q="+url
result = ActiveSupport::JSON.decode(open(link).read)
max = 0