Skip to content

Instantly share code, notes, and snippets.

View herval's full-sized avatar
:shipit:

Herval Freire herval

:shipit:
View GitHub Profile
# String extension to remove non-ascii/graphic accent characters
# pt-BR: métodos para remover acentos (e espaços) de String
require 'iconv'
class String
# São José do Poço -> Sao Jose do Poco
def remove_non_ascii
Iconv.iconv("ASCII//IGNORE//TRANSLIT", "UTF-8", self).join.gsub(/[^a-z._0-9 -]/i, "").tr(".", "_")
end
# Configuração do Sphinx para partial matching e caracteres acentuados em português
production:
enable_star: 1
min_infix_len: 2
charset_table: "\
U+00C0->a, U+00C1->a, U+00C2->a, U+00C3->a, U+00C4->a, U+00E0->a, U+00E1->a, U+00E2->a, U+00E3->a, U+00E4->a, \
U+00C7->c, U+00E7->c, \
U+00C8->e, U+00C9->e, U+00CA->e, U+00CB->e, U+00E8->e, U+00E9->e, U+00EA->e, U+00EB->e, \
U+00CC->i, U+00CD->i, U+00CF->i, U+00EC->i, U+00ED->i, \
U+00D2->o, U+00D3->o, U+00D4->o, U+00D5->o, U+00D6->o, U+00F2->o, U+00F3->o, U+00F4->o, U+00F5->o, U+00F6->o, \
Estamos dando início a um projeto novo, e temos uma a duas vagas pra estágios em desevolvimento.
Estou procurando interessados para fazer parte do projeto.
As duas vagas pedem por experiência mínima: leia-se noção das tecnologias citadas
(obviamente, quanto mais experiência melhor), proatividade e interesse em aprender até a cabeça estourar,
trabalhando em um projeto que vai dar o que falar :-)
RIA Padawan
- Flex e/ou Flash (visual e programação com actionscript)
- Java SE (Swing, SWT, JavaFX)
@herval
herval / santas.rb
Created April 6, 2010 20:50
Perl-ish solution for the Secret Santas Ruby Quiz (http://rubyquiz.com/quiz2.html)
# Perl-ish solution for the Secret Santas Ruby Quiz (http://rubyquiz.com/quiz2.html)
santas = "Luke Skywalker <luke@theforce.net>
Leia Skywalker <leia@therebellion.org>
Gus Portokalos <gus@weareallfruit.net>
Toula Portokalos <toula@manhunter.org>
Bruce Wayne <bruce@imbatman.com>
Virgil Brigman <virgil@rigworkersunion.org>
Lindsey Brigman <lindsey@iseealiens.net>
".split("\n")
@herval
herval / gist:951054
Created May 2, 2011 01:03
Parsing Facebook's signed_request (in ruby)
def parse_data
# This is a typical set of parameters passed by Facebook
# Parameters: {"signed_request"=>"vsSe9NNeyqom0hAtGyb2L9scc3-aNbY5Xb25EW55LpE.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImV4cGlyZXMiOjEzMDA3NzAwMDAsImlzc3VlZF9hdCI6MTMwMDc2NDg2Niwib2F1dGhfdG9rZW4iOiIxNzE2MDQwOTI4NjgwNTd8Mi4xQnBWNm5mU2VXRm5RT0lOdzltNWFRX18uMzYwMC4xMzAwNzcwMDAwLTE1MjAwMzkxfEFpNXctc2t4WlJyVUd1ZzZvOU95aDZBQmdSZyIsInVzZXIiOnsiY291bnRyeSI6InVzIiwibG9jYWxlIjoiZW5fVVMiLCJhZ2UiOnsibWluIjoyMX19LCJ1c2VyX2lkIjoiMTUyMDAzOTEifQ"}
# If we have the signed_request parameters, stash them away
session[:signed_request] = params[:signed_request] if params[:signed_request]
encoded_user_data = session[:signed_request]
return if encoded_user_data.blank?
@herval
herval / gist:2044137
Created March 15, 2012 13:13
My .bash_profile prompt
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
# <rvm_ruby@gemset> (<git branch, if in a git folder>) @ <current path in disk>
PS1='\[\e[0;32m\]$(~/.rvm/bin/rvm-prompt i v g) $(parse_git_branch)\[\e[m\] @ \[\e[1;34m\]\w\[\e[m\] \[\e[m\]
\[\e[1;32m\]\$ \[\e[m\]\[\e[m\] '
curl -i -H "Accept: application/json" -X POST -d "title=<bug title>&access_token=<your access token>" https://api.github.com/repos/<username>/<your repo>/issues
@herval
herval / each_hash_inject.rb
Created September 25, 2012 21:45
Comparing each, Hash[] and inject performance
require 'benchmark'
runs = 1000
original_data = {}
1000.times do |t| # 1000 depts with 100 guys each
original_data["dept_#{t}"] = (1..100).to_a
end
def employee_name(id)
@herval
herval / shakespeare_rnn.txt
Created October 28, 2015 08:56
Shakespeare generator LSTM RNN
Output from https://github.com/deeplearning4j/dl4j-0.4-examples/blob/master/src/main/java/org/deeplearning4j/examples/rnn/GravesLSTMCharModellingExample.java
Using existing text file at /var/folders/zs/vsf7sw7540s3jrqjf8ty0jfc0000gp/T/Shakespeare.txt
Loaded and converted file: 5459809 valid characters of 5465100 total characters (5291 removed)
22:37:27.108 [main] DEBUG org.reflections.Reflections - going to scan these urls:
jar:file:/Users/herval/.gradle/caches/modules-2/files-2.1/org.nd4j/nd4j-jblas/0.4-rc3.4/1548e2f266bab6e5bc1a5cd3161c4c850c0059c9/nd4j-jblas-0.4-rc3.4.jar!/
jar:file:/Users/herval/.gradle/caches/modules-2/files-2.1/org.nd4j/nd4j-api/0.4-rc3.5/9c16cbc97c0da0dba3b1a9fe4fc2efcfa6d689c1/nd4j-api-0.4-rc3.5.jar!/
jar:file:/Users/herval/.gradle/caches/modules-2/files-2.1/org.nd4j/nd4j-bytebuddy/0.4-rc3.5/e8c11225c9ef69166c328c0b97335f54f3af1955/nd4j-bytebuddy-0.4-rc3.5.jar!/
22:37:27.263 [main] INFO org.reflections.Reflections - Reflections took 148 ms to scan 3 urls, producing 82 keys and 375 v
class Entity < Struct.new(:name, :ratings)
end
@gamers = [
Entity.new('Lisa', {
'Prince of Persia' => 2.5,
'Doom' => 3.5,
'Castle Wolfenstein' => 3.0,
'Rise of the Triad' => 3.5,
'Commander Keen' => 2.5,