Fast/efficient approach:
-- execute("UPDATE posts SET comments_count = (SELECT count(1) FROM comments WHERE comments.post_id = posts.id)")
-> 1.3197s
Slow/naïve approach:
en-GB: | |
date: | |
formats: | |
# Use the strftime parameters for formats. | |
# When no format has been given, it uses default. | |
# You can provide other formats here if you like! | |
default: "%d/%m/%Y" | |
short: "%d %b" | |
long: "%d %B, %Y" |
Task ID,Type,Name,Status,Project,Context,Start Date,Due Date,Completion Date,Duration,Flagged,Notes | |
1,Context,Rocky Raccoon,active | |
1.1,Action,Now somewhere in the black mountain hills of Dakota,,,Rocky Raccoon,,,,,0, | |
1.2,Action,There lived a young boy named Rocky Raccoon,,,Rocky Raccoon,,,,,0, | |
1.3,Action,And one day his woman ran off with another guy,,,Rocky Raccoon,,,,,0, | |
1.4,Action,He hit young Rocky in the eye,,,Rocky Raccoon,,,,,0, | |
1.5,Action,Rocky didn't like that he said I'm gonna get that boy,,,Rocky Raccoon,,,,,0, | |
1.6,Action,So one day he walked into town,,,Rocky Raccoon,,,,,0, | |
1.7,Action,Booked himself a room in the local saloon,,,Rocky Raccoon,,,,,0, | |
1.8,Action,Rocky Raccoon checked into his room,,,Rocky Raccoon,,,,,0, |
class Boolean | |
def self.from_json(value) | |
if value.is_a?(TrueClass) || value.is_a?(FalseClass) | |
return value | |
elsif value.is_a?(String) | |
return value == ("true" || "1") | |
elsif value.is_a?(Integer) | |
return value == 1 | |
else | |
nil |
require "faraday" | |
require 'typhoeus' | |
conn = Faraday.new(:url => 'http://httpstat.us') do |builder| | |
builder.request :url_encoded | |
builder.response :logger | |
builder.adapter :typhoeus | |
end | |
conn.in_parallel do |
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'bundler' | |
require 'fileutils' | |
require 'net/http' | |
require 'net/https' | |
require 'uri' | |
TMP_DIR = "/tmp/gems" |
#template for select option, I use it to show regions and draw country flags for each city | |
cityOptionTpl = (obj)-> | |
_.tpl('CitySelectOption')(obj) | |
#helper for rendering option | |
renderCityOption = (entry)-> | |
tplRes = cityOptionTpl({it: | |
title : entry.title | |
region : entry.region | |
country_name : entry.country_name |
# Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations? | |
describe 'Modal' do | |
should 'display login errors' do | |
visit root_path | |
click_link 'My HomeMarks' | |
within '#login_area' do | |
fill_in 'email', with: '[email protected]' | |
fill_in 'password', with: 'test' |
Fast/efficient approach:
-- execute("UPDATE posts SET comments_count = (SELECT count(1) FROM comments WHERE comments.post_id = posts.id)")
-> 1.3197s
Slow/naïve approach:
# Caches Arbre elements in the `Rails.cache`. | |
# | |
# Yielding the first time adds to the output buffer regardless of the | |
# returned value. A cache miss must be handled separately from a hit | |
# to avoid double rendering. | |
# | |
# Returns yielded Arbre on cache miss OR an HTML string wrapped in | |
# an text node on cache hit. | |
def cache_arbre(context, *args, &block) | |
if controller.perform_caching |