Skip to content

Instantly share code, notes, and snippets.

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

Jônatas Davi Paganini jonatas

🏠
Working from home
View GitHub Profile
@jonatas
jonatas / README.md
Created February 17, 2014 04:33 — forked from mbostock/.block

From Wikipedia:

Epicyclic gearing or planetary gearing is a gear system consisting of one or more outer gears, or planet gears, revolving about a central, or sun gear. … Epicyclic gearing systems also incorporate the use of an outer ring gear or annulus, which meshes with the planet gears.

Use the menu in the top-left to change the frame of reference, fixing the specified gear in-place.

@jonatas
jonatas / stream_cam
Created March 20, 2014 21:38
raspberry pi cam stuff
mkdir /tmp/stream
cd /tmp/stream
raspistill -w 640 -h 480 -q 5 -q 5 -o /tmp/stream/pic.jpg -tl 100 -t 9999999 -th 0:0:0 &
cd ~/code/mjpg-streamer
LD_LIBRARY_PATH=./ mjpg_streamer -i "input_file.so -f /tmp/stream" -o "output_http.so -w ./www"
@jonatas
jonatas / fala.rb
Created April 30, 2014 12:16
programando um conversor de fala como meu filho lorenzo fala com 2,5 anos
APLICA_COM = {letras: "[a-z]", vogais: "[aeiou]", consoantes: "[bcdfghjklmnpqrstwxyz]"}
def troca string, opts={}
lambda do |na_string|
if entre=opts[:entre]
if entre.is_a? Symbol
start_with = ends_with = APLICA_COM[entre]
elsif entre.is_a? Range
p "range,", entre.first,entre.last, APLICA_COM
start_with, ends_with = APLICA_COM[entre.first], APLICA_COM[entre.last]
@jonatas
jonatas / compare.rb
Created April 30, 2015 17:46
benchmark compare
require "benchmark"
def compare hash, options={}
options[:times] ||= 10
Benchmark.bm(5) do |x|
hash.each do |action, execute|
x.report(action) {
options[:times].times { execute.() }
}
end
#!/usr/bin/env ruby
# traduz uma frase de ingles para portugues
require 'rubygems'
require 'httparty'
class GoogleApi
include HTTParty
base_uri 'ajax.googleapis.com'
def self.translate(string="", to="pt", from="en")
get("/ajax/services/language/translate", :query => {:langpair => "#{from}|#{to}", :q => string, :v => 1.0})
CREATE ROLE mingle with login encrypted password 'mingle' superuser;
@jonatas
jonatas / gist:87763
Created March 30, 2009 12:10
list sorted by time
ls -S -t -lah | more
pg_dump -D -U nome_usuario -h 127.0.0.1 -i -f nome_arquivo.sql -n nome_schema -T ignorar_tabela nome_banco
Dir['*_test.rb'].each do |file|
puts file
linhas = File.readlines(file)
File.open(file, 'w+') do |f|
f.puts(linhas.collect do |linha|
linha.gsub(/Test::Unit::TestCase/,'ActiveSupport::TestCase')
end)
end
end
quero alterar uma linha que começa com:
FROM tabela
para transformar em:
FROM
tabela
para buscar a sintaxe no vim:
/^FROM \(.*\)\(\n\)