Skip to content

Instantly share code, notes, and snippets.

View tomash's full-sized avatar

Tomasz Stachewicz tomash

View GitHub Profile
@tomash
tomash / email_template.rb
Created November 19, 2010 09:27
globalize3 problems
class EmailTemplate < ActiveRecord::Base
translates :name, :content
end
@tomash
tomash / openkeyval.java
Created November 1, 2010 15:32
OpenKeyVal simple getting and setting in plainest Java
import java.net.*;
import java.io.*;
public class HelloOpenKeyVal {
static String base_url = "http://openkeyval.org/";
public static void main(String[] args) throws Exception {
//System.out.println(get("cowboytomash10"));
//System.out.println(post("cowboytomash10", "what the fuck, man"));
}
@tomash
tomash / metal.rb
Created October 21, 2010 13:28
Metal Lorem Ipsum preview
# Returns a randomly generated sentence of lorem ipsum text.
# The first word is capitalized, and the sentence ends in either a period or
# question mark. Commas are added at random.
def sentence
# Determine the number of comma-separated sections and number of words in
# each section for this sentence.
sections = []
1.upto(rand(5)+1) do
sections << (WORDS.sort_by{rand}.slice(0...(rand(9)+3)).join(" "))
@tomash
tomash / migrate_model_translations_from_globalize1.rb
Created May 31, 2009 11:56
Script to migrate from Globalize1 to Globalize2 model translations
require 'config/environment.rb'
class GlobalizeCountry < ActiveRecord::Base
end
class GlobalizeLanguage < ActiveRecord::Base
end
class GlobalizeTranslation < ActiveRecord::Base
belongs_to :language, :class_name => "GlobalizeLanguage"