Skip to content

Instantly share code, notes, and snippets.

View solnic's full-sized avatar

Peter Solnica solnic

View GitHub Profile
Tue, 14 Feb 2012 14:56:18 GMT ~ debug ~ (0.002120) DROP TABLE IF EXISTS "users"
Tue, 14 Feb 2012 14:56:18 GMT ~ debug ~ (0.001219) DROP TABLE IF EXISTS "addresses"
Tue, 14 Feb 2012 14:56:18 GMT ~ debug ~ (0.003135) CREATE TABLE "users" ( "id" SERIAL NOT NULL PRIMARY KEY, "username" VARCHAR(50) NOT NULL, "age" SMALLINT NOT NULL )
Tue, 14 Feb 2012 14:56:18 GMT ~ debug ~ (0.002443) CREATE TABLE "addresses" ( "id" SERIAL NOT NULL PRIMARY KEY, "user_id" INTEGER NOT NULL, "street" VARCHAR(50) NOT NULL, "zipcode" VARCHAR(10) NOT NULL, "city" VARCHAR(50) NOT NULL )
Tue, 14 Feb 2012 14:56:18 GMT ~ debug ~ (0.000816) INSERT INTO "users" ("id", "username", "age") VALUES (1, 'John', 18)
Tue, 14 Feb 2012 14:56:18 GMT ~ debug ~ (0.000443) INSERT INTO "users" ("id", "username", "age") VALUES (2, 'Jane', 21)
Tue, 14 Feb 2012 14:56:18 GMT ~ debug ~ (0.000532) INSERT INTO "addresses" ("id", "user_id", "street", "zipcode", "city") VALUES (1, 1, 'Street 1/2', 'Chicago', '12345')
Tue, 14 Feb 2012 14:56:18 GMT ~ debug ~ (0.000463)
@solnic
solnic / test.rb
Created January 12, 2012 11:33 — forked from tenderlove/test.rb
# encoding: utf-8
require 'rubygems'
require 'benchmark/ips'
require 'set'
TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE'].to_set
BOOLEAN_MAP = Hash[ %w[ 1 on t true y yes ].product([ true ]) ]
def original value
/Users/solnic/.rvm/rubies/ruby-1.9.2-p290/bin/ruby -S rspec spec/unit/virtus/attribute/array_spec.rb spec/unit/virtus/attribute/boolean_spec.rb spec/unit/virtus/attribute/class_methods/determine_type_spec.rb spec/unit/virtus/attribute/class_spec.rb spec/unit/virtus/attribute/date_spec.rb spec/unit/virtus/attribute/date_time_spec.rb spec/unit/virtus/attribute/decimal_spec.rb spec/unit/virtus/attribute/default_value/class_methods/new_spec.rb spec/unit/virtus/attribute/default_value/instance_methods/evaluate_spec.rb spec/unit/virtus/attribute/float_spec.rb spec/unit/virtus/attribute/hash_spec.rb spec/unit/virtus/attribute/integer_spec.rb spec/unit/virtus/attribute/numeric/class_methods/descendants_spec.rb spec/unit/virtus/attribute/object/class_methods/descendants_spec.rb spec/unit/virtus/attribute/string_spec.rb spec/unit/virtus/attribute/time_spec.rb spec/unit/virtus/attribute_set/append_spec.rb spec/unit/virtus/attribute_set/each_spec.rb spec/unit/virtus/attribute_set/element_reference_spec.rb spec/unit/virtu
@solnic
solnic / virtus_dm_validations_example.rb
Created October 27, 2011 16:29
Virtus + DataMapper Validations
# this uses upcoming dm-validations, it's not released yet
class User
include Virtus
include DataMapper::Validations
# basic info
attribute :email, String
attribute :password, String
attribute :password_confirmation, String
@solnic
solnic / gist:1284019
Created October 13, 2011 11:34 — forked from bragi/gist:1283869
Stevey's Google Platforms Rant

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't really have SREs and they make engineers pretty much do everything,

@solnic
solnic / improved_dirty_tracking_in_dm_1.2.0.rb
Created October 13, 2011 11:25
improved_dirty_tracking_in_dm_1.2.0.rb
require 'rubygems'
require 'data_mapper'
DataMapper.setup :default, 'sqlite::memory:'
class Book
include DataMapper::Resource
property :id, Serial
property :meta, Json

dm-active_model

Piotr Solnica - 2011-09-09T11:17:57-07:00 - details

Regenerate gemspec for version 1.2.0.rc1

dm-adjust

Piotr Solnica - 2011-09-09T11:18:24-07:00 - details

Regenerate gemspec for version 1.2.0.rc1

require 'rubygems'
require 'bundler/setup'
require 'dm-core'
require 'dm-migrations'
DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, 'sqlite::memory:')
class Person
include DataMapper::Resource