This shows how different approaches to memoization work (or don't) in different Ruby engines.
If you're using the idiomatic Ruby approach to memoization, like this:
def data
@memo ||= expensive_action
end
require 'active_record' | |
ActiveRecord::Base.logger = Logger.new(STDERR) | |
ActiveRecord::Base.colorize_logging = false | |
ActiveRecord::Base.establish_connection( | |
:adapter => "sqlite3", | |
:dbfile => ":memory:" | |
) |
require 'rubygems' | |
require 'spork' | |
# This code runs once when you run your test suite | |
Spork.prefork do | |
ENV['RAILS_ENV'] ||= 'test' | |
# Mongoid models reload | |
require 'rails/mongoid' | |
Spork.trap_class_method(Rails::Mongoid, :load_models) |
Shoes.setup do | |
end | |
def bottle(x) | |
case x | |
when 0 then "no more bottles" | |
when 1 then "1 bottle" | |
else "#{x} bottles" | |
end + " of beer" | |
end |
#!/bin/sh | |
# one way (older scala version will be installed) | |
# sudo apt-get install scala | |
#2nd way | |
sudo apt-get remove scala-library scala | |
wget http://www.scala-lang.org/files/archive/scala-2.11.4.deb | |
sudo dpkg -i scala-2.11.4.deb | |
sudo apt-get update |
var gulp = require('gulp'), | |
gutil = require('gulp-util'), | |
sass = require('gulp-sass'), | |
csso = require('gulp-csso'), | |
uglify = require('gulp-uglify'), | |
jade = require('gulp-jade'), | |
concat = require('gulp-concat'), | |
livereload = require('gulp-livereload'), // Livereload plugin needed: https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei | |
tinylr = require('tiny-lr'), | |
express = require('express'), |
WITH table_scans as ( | |
SELECT relid, | |
tables.idx_scan + tables.seq_scan as all_scans, | |
( tables.n_tup_ins + tables.n_tup_upd + tables.n_tup_del ) as writes, | |
pg_relation_size(relid) as table_size | |
FROM pg_stat_user_tables as tables | |
), | |
all_writes as ( | |
SELECT sum(writes) as total_writes | |
FROM table_scans |