Skip to content

Instantly share code, notes, and snippets.


Helder S Ribeiro hsribei

View GitHub Profile
hsribei /
Last active Aug 29, 2015
Wish: "Read it later" plus "spaced repetition" app for language learners

Update: found something close enough:

Wish: "Read it later" plus "spaced repetition" app for language learners

  • All the usual ways of sending articles to this "Pocket" app: email, browser extensions, the app itself.
  • While reading, select word of phrase, have it translated and added to app as a flashcard. Front: word/phrase highlighted in context; Back: translation + optional notes.
  • Batch mode: toggle batch mode, select multiple words/phrases, have their definitions/translations all added as flashcards.
  • Optionally, go through those new cards right away (as opposed to studying them only in the random-ish order of the whole set's spaced repetition) and, when finished, go back to text. This way you can quickly go through a paragraph in batch mode, mark everything you don't understand, study it, then go back to read it with the necessary vocabulary.
  • When not reading, user can go through flashcards with a spaced repetition algorithm and interface similar to Brainscape's. From
hsribei / catarse_pendentes.js
Last active Aug 29, 2015
Somar contribuições pendentes no Catarse
View catarse_pendentes.js
// Clica no botão de rádio dos pendentes, rola a página até o fim para carregar todas as contribuições,
// abre o console, digita isso e dá Enter:
_.chain($('.value')).map(function(el){ return parseFloat($(el).text()); }).reduce(function(sum, el){ return sum + el; }, 0).value();
hsribei / gist:85300
Created Mar 25, 2009
Script para ripar nomes, partidos, estados e votações de deputados federais.
View gist:85300
# to read it again every time we're testing the extraction of their
# voting history (which is still buggy)
if File.exists?("legislators.yml")
legislators ="legislators.yml") { |f| YAML::load(f) }
page = agent.get('')
form = page.form('form1')
select = form.fields[5]
View gist:111188
# Grep a line in a project's entire network
# (or all the forks you included as remote anyway)
irb(main):001:0> pattern = "task :clear"
irb(main):002:0> `find .git/refs/remotes/ -type f`.split("\n").map{|e| e.gsub(/\.git\/refs\/remotes\//, '')}.each {|e| puts `git grep #{pattern} #{e}`}
View gist:115762
class AddStatsToDelayedJobs < ActiveRecord::Migration
def self.up
add_column :delayed_jobs, :first_started_at, :datetime
add_column :delayed_jobs, :last_started_at, :datetime
add_column :delayed_jobs, :finished_at, :datetime
def self.down
remove_column :delayed_jobs, :finished_at
remove_column :delayed_jobs, :last_started_at
View gist:138159
#!/usr/bin/env ruby
require 'rubygems'
require 'json'
require 'open-uri'
def google_fight(queries)
queries.max { |a,b| JSON.load(open("{a}"))["responseData"]["cursor"]["estimatedResultCount"].to_i <=> JSON.load(open("{b}"))["responseData"]["cursor"]["estimatedResultCount"].to_i }
if __FILE__ == $0
View deputados_scraping.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'mechanize'
require 'ostruct'
require 'open-uri'
require 'hpricot'
require 'yaml'
# fix for screwed up net/http
# found at:
hsribei / debugging_attribution_to_specific_hash_keys.rb
Created Aug 16, 2010
How to debug Hash attribution for a specific key (like when you want to debug Rails' env hash)
View debugging_attribution_to_specific_hash_keys.rb
class Hash
def assign_with_debugger(key, value)
debugger if key == "action_dispatch.request.path_parameters"
self.assign_without_debugger(key, value)
alias :assign_without_debugger :[]=
alias :[]= :assign_with_debugger
hsribei / gist:748665
Created Dec 20, 2010
downcase with accents for latin1 (sort of)
View gist:748665
# -*- coding: utf-8 -*-
class String
def downcase_with_accents
return nil if s.nil?
norm = self.downcase!('ÁÉÍÓÚÇ', 'aeiouç')!('ÀÈÌÒÙ', 'aeiou')!('ÄËÏÖÜ', 'aeiou')!('ÂÊÎÔÛ', 'aeiou')!('áéíóú', 'aeiou')
hsribei / gist:1313618
Created Oct 25, 2011
A merged git branch remains accessible even if deleted after being merged.
View gist:1313618

A merged git branch remains accessible even if deleted after being merged

A merge commit has two parent sha1s, so the old branch would be accessible by its sha1 as one of the parents in the merge commit and thus wouldn't be garbage-collected by Git.