Skip to content

Instantly share code, notes, and snippets.

View albertoperdomo's full-sized avatar

Alberto Perdomo albertoperdomo

View GitHub Profile
A backup of http://sites.google.com/site/redcodenl/creating-shazam-in-java-1 just in case
Why is this necessary? Read http://sites.google.com/site/redcodenl/patent-infringement
Please fork, tweet about, etc.
----
Creating Shazam in Java
A couple of days ago I encountered this article: How Shazam Works
This got me interested in how a program like Shazam works… And more importantly, how hard is it to program something similar in Java?
require 'irb/completion'
require 'irb/ext/save-history'
require 'rubygems'
require 'wirble'
require 'hirb'
#completion
ARGV.concat [ "--readline", "--prompt-mode", "simple" ]
#----------------------------------------------------------------------------
# Git Setup
#----------------------------------------------------------------------------
file '.gitignore', <<-FILE
.DS_Store
log/*.log
tmp/**/*
config/database.yml
db/*.sqlite3
public/uploads/*
the work-around is to get a console ("irb -rinit") and do "Integrity::Build.all.select { |b| b.commit.nil? }.each { |b| b.destroy! }"
We couldn’t find that file to show.
Feature: Cool AJAX autocomplete
Scenario: Autocomplete city
When I fill in "City" with "Madr"
Then I should see "Madrid, Spain"
When I follow "Madrid, Spain"
Then the field "City" should contain "Madrid, Spain"
@albertoperdomo
albertoperdomo / env.rb
Created August 26, 2010 12:17
Run selenium headlessly on the CI server using the headless gem
Before('@selenium') do
if ENV["SELENIUM_HEADLESS"] == 'true'
require "headless"
@headless = Headless.new
@headless.start
end
end
After('@selenium') do
@headless.destroy if @headless.present?
@albertoperdomo
albertoperdomo / accent_query_translate_using_translate.rb
Created September 14, 2010 21:31
Normalize terms for search in DB
#Así he implementado tu propuesta como scope:
named_scope :normalized_name_begins_with, lambda { |term|
map = [
"âãäåāăąÁÂÃÄÅĀĂĄèééêëēĕėęěĒĔĖĘĚìíîïìĩīĭÌÍÎÏÌĨĪĬóôõöōŏőÒÓÔÕÖŌŎŐùúûüũūŭůÙÚÛÜŨŪŬŮñÑçÇüÜ".mb_chars,
"aaaaaaaaaaaaaaaeeeeeeeeeeeeeeeiiiiiiiiiiiiiiiiooooooooooooooouuuuuuuuuuuuuuuunnccuu"]
# ActiveSupport::Multibyte::Chars#tr broken?
adapted_word = "%#{term.mb_chars.split(//).map {|e| (p = map[0].index(e)) ? map[1][p,1] : e.to_s }.join.downcase}%"
{
// Snippet by @ayosec on IM - Thx ayose! :)
//:ruby
//= form.input :city_id, :as => :string, :input_html => { :value => resource.city_id }
//:javascript
jQuery(function() { city_autocompleter("#resource_city_id", "#{escape_javascript resource.localized_city_long_name || params[:city]}") });
@albertoperdomo
albertoperdomo / 960_plain_small_example.html
Created September 22, 2010 11:08
Short example of 960.gs vs. Compass + 960.gs
// HTML using 960.gs
<body>
<div class="container_16">
// more stuff
<div class="grid_4">
Sidebar
</div>