Skip to content

Instantly share code, notes, and snippets.

View albertoperdomo's full-sized avatar

Alberto Perdomo albertoperdomo

View GitHub Profile
@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?
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"
We couldn’t find that file to show.
the work-around is to get a console ("irb -rinit") and do "Integrity::Build.all.select { |b| b.commit.nil? }.each { |b| b.destroy! }"
#----------------------------------------------------------------------------
# Git Setup
#----------------------------------------------------------------------------
file '.gitignore', <<-FILE
.DS_Store
log/*.log
tmp/**/*
config/database.yml
db/*.sqlite3
public/uploads/*
require 'irb/completion'
require 'irb/ext/save-history'
require 'rubygems'
require 'wirble'
require 'hirb'
#completion
ARGV.concat [ "--readline", "--prompt-mode", "simple" ]
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?
$(function(){
$("select#search_country_id").change(function(){
$("img#spinner_city_id").show();
$("select#search_city_id").disable();
$.getJSON("/cities.json",{country_id: $(this).val(), ajax: 'true'}, function(j){
var options = '';
for (var i = 0; i < j.length; i++) {
options += '<option value="' + j[i]["city"]["id"] + '">' + j[i]["city"]["name"] + '</option>';
}
$("select#search_city_id").html(options);
## I18n backends benchmarks
#
# All these benchmarks were performed using REE with the suite at
# at http://github.com/svenfuchs/i18n/tree/master/benchmark/run.rb
#
# When compared to ActiveRecord backend, Redis and Tokyo
# just cannot store procs. All other tests pass.
#
# Used rufus-tokyo (1.0.7) and redis (2.0.0) as gems and N = 10.
@albertoperdomo
albertoperdomo / ci.rake
Created April 16, 2010 22:57
Sample rails rake task for continous integration and deployment
namespace :ci do
task :copy_yml do
sh "cp #{Rails.root}/config/example_database.yml #{Rails.root}/config/database.yml"
end
desc "Prepare for CI and run entire test suite"
task :build do
Rake::Task['db:migrate'].invoke
Rake::Task['db:test:prepare'].invoke
Rake::Task['test:units'].invoke