save_and_open_page
have_button(locator)| require "celluloid" | |
| class MyClass | |
| include Celluloid | |
| def initialize | |
| @a = 0 | |
| end | |
| def do_something |
| trans = Transaction.filter(~{:somecolumn => nil}, :send_time => nil) | |
| trans.each do |t| | |
| # do something | |
| end |
| require 'celluloid' | |
| class MyClass | |
| include Celluloid | |
| def do_some | |
| 'yo' | |
| end | |
| end | |
| a = Myclass.new |
| require 'celluloid' | |
| class Yo | |
| include Celluloid | |
| end | |
| puts Celluloid::Actor.all.length |
| # 2. Include Sweeping module in your controller(s) to have cache_sweeper | |
| # method to be avaliable, or right in ApplicationController so it will be | |
| # available in all controllers inheriting from it. | |
| class ApplicationController < ActionController::Base | |
| include ActionController::Caching::Sweeping | |
| # ... | |
| end |
| let(:date) do | |
| Time.now | |
| end | |
| it "converts the elements properly" do | |
| p date.zone | |
| mongoized.first.should eq(date) | |
| p date.zone | |
| end |
| # Any difference between: | |
| [:db_create, :db_drop, :db_list].each do |cmd| | |
| #THIS: | |
| define_method(cmd) do |*args| | |
| NoBrainer.run { RethinkDB::RQL.send(cmd, *args) } | |
| end | |
| # OR THIS |
| require "benchmark/ips" | |
| Benchmark.ips do |x| | |
| x.report("double quote assignment:") {a = "yo man"} | |
| x.report("double quote +:") {|i| a = "yo man" + i.to_s} | |
| x.report("double quote <<:") {|i| a = "yo man" << i.to_s} | |
| x.report("double quote interpolation:") {|i| a = "yo man #{i}"} | |
| x.report("single quote assignment:") {a = 'yo man'} | |
| x.report("single quote +:") {|i| a = 'yo man' + i.to_s} |
| (ns phrase | |
| (:require [clojure.string :as str])) | |
| (defn- strip-punctuation [phrase] | |
| (str/replace phrase #"[^\w\s]" "") | |
| ) | |
| (defn word-count [phrase] | |
| (frequencies (str/split(str/lower-case (strip-punctuation phrase)) #"\s+")) | |
| ) |