This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generate the models Estado and Cidade: | |
# rails generate Estado sigla:string nome:string | |
# rails generate Cidade estado:references nome: string | |
# rails db:migrate | |
# Put this code on your db/seeds.rb of your Ruby On Rails application | |
# rails db:seed | |
Estado.destroy_all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
:AC=>"Acre", | |
:AL=>"Alagoas", | |
:AP=>"Amapá", | |
:AM=>"Amazonas", | |
:BA=>"Bahia", :CE=>"Ceará", | |
:DF=>"Distrito Federal", | |
:ES=>"Espírito Santo", | |
:GO=>"Goiás", | |
:MA=>"Maranhão", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ListingsController < ApplicationController | |
def index | |
movie_listing_service = ServiceLocator.get_service_instance(:MovieListing) | |
@available_movies = movie_listing_service.available_movies | |
render nothing: true #this is just an example don't get hung up on it :) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bulk merge a bunch of records | |
# | |
# we expect most of the records to import to represent updates | |
# so this method tries to be efficent with database queries | |
# by using a single query to find any existing records matching the key_attributes | |
# updating those records and finally inserting each remaining record | |
# | |
# It DOEST NOT use a transaction or lock. callers responsibilty to | |
# add that if desired | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def resize_nocrop_noscale(image, w,h) | |
w_original = image[:width].to_f | |
h_original = image[:height].to_f | |
if w_original < w && h_original < h | |
return image | |
end | |
# resize | |
image.resize("#{w}x#{h}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"html/template" | |
"labix.org/v2/mgo" | |
"labix.org/v2/mgo/bson" | |
"log" | |
"net/http" | |
"os" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sys = require('sys'), | |
exec = require('child_process').exec; | |
// fs = require('fs'); | |
// ecsv = require('ecsv') | |
function Queue () { | |
var waiting = []; | |
this.max = -1; | |
this.current = 0; | |
//run checks if we're under the max processors, and runs if there is room. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'tempfile' | |
require 'java' if defined?(JRUBY_VERSION) | |
require 'test/unit' | |
require 'fileutils' | |
class TestTempfilesCleanUp < Test::Unit::TestCase | |
def setup | |
@tmpdir = "tmp_#{$$}" | |
Dir.mkdir @tmpdir rescue nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -w | |
# This should be run through './script/runner' | |
options = YAML.load($stdin.read) | |
demo = Demo.find(options[:demo]) | |
runner = Outback::Runner.new | |
runner.manager = demo.manager |
NewerOlder