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
class GameChannel < ApplicationCable::Channel | |
def subscribed | |
game = Game.find(params[:id]) | |
stream_for game | |
end | |
end | |
## When the game state changes | |
GameChannel.broadcast_to(game, GameSerializer.render(game)) |
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 |
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
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); |
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 |
# 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 .} |
class ExampleCrawler < PoltergeistCrawler | |
def crawl | |
visit "https://news.ycombinator.com/" | |
click_on "More" | |
page.evaluate_script("window.location = '/'") | |
end | |
end | |
ExampleCrawler.new.crawl |
# This is a skeleton for testing models including examples of validations, callbacks, | |
# scopes, instance & class methods, associations, and more. | |
# Pick and choose what you want, as all models don't NEED to be tested at this depth. | |
# | |
# I'm always eager to hear new tips & suggestions as I'm still new to testing, | |
# so if you have any, please share! | |
# | |
# @kyletcarlson | |
# | |
# This skeleton also assumes you're using the following gems: |
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.
⇐ back to the gist-blog at jrw.fi
Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.
I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.
This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso