This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rates = Rate.where(hotel_id: 1, | |
room_type: '1 bed', | |
check_in_date: Date.today) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# All index fields are required, | |
# the rest is the schemaless content | |
rate = Rate.put(hotel_id: 1, | |
room_type: '1 bed', | |
check_in_date: Date.today, | |
discount_type: 'geo', | |
net_price: 120.0) # potentially ~20 fields | |
rate[:hotel_id] # => 1 | |
rate[:net_price] # => 120.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RateStore.create_tables! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/rate.rb | |
class Rate | |
RateStore.attach(self) | |
index do | |
integer :hotel_id | |
string :room_type | |
string :check_in_date |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/rate_store.rb | |
RateStore = Shameless::Store.new(:rate_store) do |c| | |
c.partition_urls = [ | |
ENV['RATE_STORE_DATABASE_URL_0'], | |
ENV['RATE_STORE_DATABASE_URL_1'] | |
] | |
# total number of shards across all partitions | |
c.shards_count = 512 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem ‘shameless’ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shameless usage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ dig js.pusher.com | |
; <<>> DiG 9.9.2-P1 <<>> js.pusher.com | |
;; global options: +cmd | |
;; Got answer: | |
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 63691 | |
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 | |
;; OPT PSEUDOSECTION: | |
; EDNS: version: 0, flags:; udp: 4096 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unless ENV.include?('CI') | |
ENV['DISPLAY'] = ':99' | |
pid = Process.spawn('Xvfb :99 -ac', out: '/dev/null', err: '/dev/null') | |
at_exit { Process.kill(:SIGINT, pid) } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Admin_ContentTranslationsControllerTest extends Our_Test_ControllerTestCase | |
{ | |
function testEditFindTranslationByIdTheOldWay() | |
{ | |
$this->table->insert(array('key' => 'foo')); | |
$this->get('edit', array('id' => '1')); | |
$this->assertEquals(1, $this->assigns->translation->id); | |
} |
NewerOlder