TL;DR
Install Postgres 9.6, and then:
sudo pg_dropcluster 9.6 main --stop
sudo pg_upgradecluster 9.5 main
sudo pg_dropcluster 9.5 main
n = 1_000 | |
id = User.first.id | |
profile = User.only(:profile).find(id).profile | |
Benchmark.bm(50) do |x| | |
x.report('User.find(id).profile') do | |
n.times{ User.find(id).profile } | |
end |
# Assuming you champioin your other DB connection with a class. | |
module OtherDb | |
class Connection < ActiveRecord::Base | |
establish_connection :other_db | |
self.abstract_class = true | |
end | |
end | |
# Alway use the connection for other/legacy connections. |
class ExampleCrawler < PoltergeistCrawler | |
def crawl | |
visit "https://news.ycombinator.com/" | |
click_on "More" | |
page.evaluate_script("window.location = '/'") | |
end | |
end | |
ExampleCrawler.new.crawl |
var getTimeLeft = function(){ | |
var now = moment(); | |
var deadline = now.clone().hour(12).minute(0),second(0); | |
if(now.isAfter(deadline) { | |
// disable RSVP button here | |
return ‘Closed’; | |
}else { | |
// enable RSVP button here | |
// returns “in x hours”, “in x minutes”, “in a few seconds” | |
return deadline.from(now); |
require 'spec_helper' | |
describe "home" do | |
before do | |
@domain = "myshop.myshopify.com" | |
@token = SecureRandom.hex(16) | |
@shopify_session = ShopifyAPI::Session.new(@domain, @token) | |
end | |
RSpec.configure do |config| | |
example_sql_counts = Hash.new(0) | |
config.around(:example) do |procsy| | |
sql_count = 0 | |
callback = ->(*args) { sql_count +=1 } | |
ActiveSupport::Notifications.subscribed(callback, "sql.active_record") do | |
procsy.call | |
end |
# http://technet.microsoft.com/en-us/library/ee692685.aspx | |
# F7 = history | |
# Alt+F7 = history -c | |
# F8 = Ctrl+R | |
Set-Location C: | |
# Easier navigation | |
Set-Alias o start | |
function oo {start .} |
TL;DR
Install Postgres 9.6, and then:
sudo pg_dropcluster 9.6 main --stop
sudo pg_upgradecluster 9.5 main
sudo pg_dropcluster 9.5 main
You could have postgre installed on localhost with password (or without user or password seted after instalation) but if we are developing we really don't need password, so configuring postgre server without password for all your rails project is usefull.
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |