Skip to content

Instantly share code, notes, and snippets.

View dabit's full-sized avatar

David Padilla dabit

View GitHub Profile
@dabit
dabit / optimistic.rb
Last active August 29, 2015 13:56
ActiveRecord Optimistic Locking
require 'active_record'
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :orders do |t|
t.integer :total
t.string :lock_version
end
@dabit
dabit / sort.rb
Created March 21, 2014 03:11
Hermosillo.rb
#
# Vayan a MagmaConf http://www.magmaconf.com
#
require 'minitest/autorun'
require 'minitest/pride'
class Animal
attr_accessor :clase
@dabit
dabit / gist:b640b8f5d0bcdd039265
Last active August 29, 2015 14:06
Create Brazilian States for Spree
brazil = Spree::Country.where(name: "Brazil").last
Spree::State.create!(
[{name: "Acre", abbr: "AC", country: brazil},
{name: "Alagoas", abbr: "AL", country: brazil},
{name: "Amapá", abbr: "AP", country: brazil},
{name: "Amazonas", abbr: "AM", country: brazil},
{name: "Bahia", abbr: "BA", country: brazil},
{name: "Ceará", abbr: "CE", country: brazil},
{name: "Espírito Santo", abbr: "ES", country: brazil},
@dabit
dabit / script.rb
Last active August 29, 2015 14:16
.last sort conundrum
# Activate the gem you are reporting the issue against.
# gem install activerecord -v '3.2.19'
gem 'activerecord', '3.2.19'
require 'active_record'
require 'minitest/autorun'
require 'logger'
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
@dabit
dabit / alias.sh
Last active August 29, 2015 14:17
Elasticsearch quick reindex post
curl -XPOST 'http://localhost:9200/_aliases' -d '
{
"actions" : [
{ "add" : { "index" : "articles-1", "alias" : "articles" } }
]
}'
@dabit
dabit / ruby.rb
Created April 15, 2015 20:29
private protected
class Klass
def public_method
end
private
def private_method1
end
def private_method2
@dabit
dabit / Testing
Created September 13, 2010 22:11
Testing
$ cucumber
Using the default profile...
F---F
Failing Scenarios:
cucumber features/autocomplete.feature:7 # Scenario: Autocomplete
1 scenario (1 failed)
3 steps (3 skipped)
0m0.006s
%ul{:class => "sizes #{product_attribute.name.downcase}"}
-if product_attribute.name == "Width"
-values= product_attribute.values.sort{|x,y| x.id <=> y.id}
-attname='Shoe Witdh'
-objname="product[value_ids][#{product_attribute.solr_name}][]"
-elsif product_attribute.name == "Youth Shoe Sizes"
-values= Value.shoe_sizes
-attname='Shoe Sizes'
-objname="product[value_ids][shoe_sizes][]"
%b
<?php
require_once( 'core.php' );
$t_core_path = config_get( 'core_path' );
require_once( $t_core_path . 'filter_api.php' );
require_once( $t_core_path . 'csv_api.php' );
require_once( $t_core_path . 'columns_api.php' );
?>
<?php auth_attempt_script_login('$MANTIS_USER', '$MANTIS_PASSWORD') ?>