Skip to content

Instantly share code, notes, and snippets.

@jzajpt
jzajpt / google_translate.rb
Created September 2, 2011 08:48
Google Translate Ruby API
# encoding: utf-8
class GoogleTranslate
BASE_URL = 'https://www.googleapis.com/language/translate/v2'
URL_OPTIONS = [ :key, :target, :source, :q, :format ]
include HTTParty
format :json
@jzajpt
jzajpt / accommodation.rb
Created August 5, 2011 09:23
Mongoid bug
class Accommodation
include Mongoid::Document
references_many :reservations
end
@jzajpt
jzajpt / observe_status.js
Created May 17, 2011 06:57
Mixin for status observing - on records, record arrays etc.
// ==========================================================================
// Project: Billapp.ObserveStatus
// Copyright: ©2011 Blueberry.cz Apps s.r.o.
// ==========================================================================
/*globals Billapp */
/** @namespace
@version 0.1
*/
# encoding: utf-8
require 'mongoid_typecast_attributes'
module Mongoid
module Document
include MongoidTypecastAttributes
end
end
#!/usr/bin/env ruby
# encoding: utf-8
require 'net/scp'
require 'net/ssh'
app = 'his'
lang = 'en'
host = 'zoidberg.blueberry.cz'
# Switch to Ruby 1.8.7
rvm use 1.8.7
# Print out the ruby version
ruby -v
# But the output of this is:
#
# $ ./tryrvm
# <i> Now using ruby 1.8.7 p249 </i>
context "when deleting 2 nested docs" do
let(:person) { Person.new }
before do
person.favorites.build(:title => "Johnny")
person.favorites.build(:title => "Ice cream")
person.favorites.build(:title => "Coke")
person.favorites.build(:title => "Sugar")
person.save!
context "when adding a nested doc and updating existing doc's attributes" do
let(:person) { Person.new }
before do
person.addresses << Address.new({ "street" => "Folsom", "city" => "San Francisco" })
person.save!
@attributes = {
"0" => { "street" => "New Street" },
"1" => { "street" => "5th Street", "city" => "Boston" },
require 'mongomapper'
class Media
include MongoMapper::EmbeddedDocument
key :file, String
end
class Video < Media
key :length, Integer
end
#!/usr/bin/env ruby
# Configures the git author to a list of developers when pair programming
#
# Usage: pair lm bh (Sets the author to 'Luke Melia and Bryan Helmkamp')
# pair (Unsets the author so the git global config takes effect)
#
# Author: Bryan Helmkamp (http://brynary.com)
#######################################################################