Replace IRB with Pry (in your Gemfile) and Byebug with pry-byebug
.
gem 'pry-rails', group: [:development, :test]
gem 'pry-byebug', group: [:development, :test]
require 'benchmark/ips' | |
Benchmark.ips do |x| | |
x.report('#exists?') { User.where(id: 1).exists? } | |
x.report('#any?') { User.where(id: 1).any? } | |
x.report('#present?') { User.where(id: 1).present? } | |
x.compare! | |
end |
# Tasks for managing Unicorn instances of a Rails application. | |
# Compatible with Ruby >= 1.9.2 and Rails >= 2 . | |
# Unicorn signals: http://unicorn.bogomips.org/SIGNALS.html | |
namespace :unicorn do | |
class UnicornPIDError < StandardError; end | |
def rails_env | |
Rails.env |
For reference: http://postgis.net/install
The most reliable way to get PostGIS on OSX is to download and install Postgres.app. Great for development and testing. Do not mix with other installations. Select the extension when prompted.
[2] pry(main)> Product.last(10).map{|p| p.variants}.flatten | |
Product Load (1.1ms) SELECT "products".* FROM "products" ORDER BY "products"."id" DESC LIMIT 10 | |
Variant Load (96.5ms) SELECT "variants".* FROM "variants" WHERE "variants"."nomenclature_id" = 247664 AND "variants"."archived_at" IS NULL ORDER BY order_weight [["nomenclature_id", 247664]] | |
Variant Load (0.6ms) SELECT "variants".* FROM "variants" WHERE "variants"."nomenclature_id" = 247665 AND "variants"."archived_at" IS NULL ORDER BY order_weight [["nomenclature_id", 247665]] | |
Variant Load (0.3ms) SELECT "variants".* FROM "variants" WHERE "variants"."nomenclature_id" = 247666 AND "variants"."archived_at" IS NULL ORDER BY order_weight [["nomenclature_id", 247666]] | |
Variant Load (0.6ms) SELECT "variants".* FROM "variants" WHERE "variants"."nomenclature_id" = 247667 AND "variants"."archived_at" IS NULL ORDER BY order_weight [["nomenclature_id", 247667]] | |
Variant Load (0.5ms) SELECT "variants".* FROM "variants" WHERE "variants"."nome |
var curr_domain = window.location.href.split('//')[1].split('/')[0]; | |
var outside_links = []; | |
var links = document.getElementsByTagName("a"); | |
for(var i=0; i<links.length; i++) { | |
var res = links[i].href.split('//')[1]; | |
if(typeof res == 'undefined') continue; | |
if(res.split('/')[0] == curr_domain) continue; | |
outside_links.push('http://' + res); | |
} |
class Attachment < ActiveRecord::Base | |
mount_uploader :attachment, AttachmentUploader | |
# Associations | |
belongs_to :attached_item, polymorphic: true | |
# Validations | |
validates_presence_of :attachment |
/** | |
* Jesse Weisbeck's Crossword Puzzle (for all 3 people left who want to play them) | |
* | |
*/ | |
(function($){ | |
$.fn.crossword = function(entryData) { | |
/* | |
Qurossword Puzzle: a javascript + jQuery crossword puzzle | |
"light" refers to a white box - or an input |
require 'benchmark/ips' | |
GITHUB_COM = %r{https?://(?:www\.)?github\.com}i | |
Benchmark.ips do |x| | |
x.report('with o') { %r{\A#{GITHUB_COM}/([^/]+)/?\z}o } | |
x.report('without o') { %r{\A#{GITHUB_COM}/([^/]+)/?\z} } | |
x.compare! | |
end |