Skip to content

Instantly share code, notes, and snippets.

View tomash's full-sized avatar

Tomasz Stachewicz tomash

View GitHub Profile
@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"
@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 / 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 / email_template.rb
Created November 19, 2010 09:27
globalize3 problems
class EmailTemplate < ActiveRecord::Base
translates :name, :content
end
@tomash
tomash / 20101021132131_add_translations_table.rb
Created November 19, 2010 10:51
i18n database backend conflicting with globalize3
class AddTranslationsTable < I18n::Backend::Database::Migration
def self.up
create_table :translation_migrations do |t|
t.string :version
end
create_table :translations do |t|
t.string :locale
t.string :key
t.text :value
We build our client experience
Developing software is a complicated and challenging task. Therefore we are happy to make it great experience for our clients. By hiring only experts and having them work within great process, we put our best effort to create outstanding communication and best quality.
Every client is different and so is every project. We adjust our work style to best fit your project needs. Whatever is the key in your business is our goal as well: time to market, quality, user experience.
Agile
We use Scrum, Kanban and XP mixture as a base for our process, although we keep in mind that business requirements are the most important factor. Therefore we eliminate everything that does not bring a value for the project, adjusting our process to suit our clients while motivating team to create outstanding software.
100% of our production code is pair programmed or goes through code review. We use TDD/BDD, Continuous Integration and extensive human tests. We believe quality is the key to customer e
@tomash
tomash / passwords_controler_decorator.rb
Created February 28, 2011 13:16
override method for devise password recovery
# fails after one call even when not doing anything invasive at all:
Devise::PasswordsController.class_eval do
# POST /resource/password
def create
# email is not unique, so iterate amongst all the users
resource_class.where(:email => params[resource_name][:email]).all.each do |res|
logger.info res.username
end
redirect_to new_session_path(resource_name)
@tomash
tomash / pulp_rate.rb
Created April 27, 2011 09:28
Spree shipping cost calculator
class Calculator::PulpRate < Calculator
preference :category1_rate, :decimal, :default => 0
preference :category2_rate, :decimal, :default => 0
preference :category3_rate, :decimal, :default => 0
preference :category4_rate, :decimal, :default => 0
preference :category5_rate, :decimal, :default => 0
WEIGHT_RANGES = {
0..350 => :preferred_category1_rate,
351..500 => :preferred_category2_rate,
@tomash
tomash / gist:957184
Created May 5, 2011 14:52
output of backup's rspec
tomek@asus-laptop:~/ruby_apps/backup$ bundle exec rspec spec/
1) Backup::Encryptor::OpenSSL when a block is provided
Failure/Error: encryptor.password.should == "my_secret_password"
expected: "my_secret_password"
got: nil (using ==)
# ./spec/encryptor/open_ssl_spec.rb:37
2) Backup::Encryptor::OpenSSL when a block is provided
@tomash
tomash / twitter_worker.rb
Created September 29, 2011 09:37
twitter worker: multiple twitter streams
require "daemon_spawn"
require "socket"
require "tmpdir"
require 'twitter/json_stream'
require 'json'
require "./config/environment"
# todo: write tests
class TwitterWorker