This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| st> String comment | |
| 'My instances represent 8-bit character strings. Being a very common | |
| case, they are particularly optimized. | |
| Note that, if you care about multilingualization, you should treat | |
| String only as an encoded representation of a UnicodeString. The I18N | |
| package adds more Unicode-friendliness to the system so that encoding | |
| and decoding is performed automatically in more cases. In that case, | |
| String represents a case when the encoding is either unknown, irrelevant, | |
| or assumed to be the system default.' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe "#pop" do | |
| subject { [3, 4, 5].pop } | |
| it { should == 5 } | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Group < AR::Base | |
| has_many :memberships | |
| has_many :members, through: :memberships, class_name: "User" | |
| has_many :global_admin_members, through: :memberships, class_name: "User", conditions: { admin: true } | |
| end | |
| class User < AR::Base | |
| has_many :memberships | |
| has_many :groups, through: :memberships | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://en.wikipedia.org/wiki/Sleeping_barber_problem | |
| require 'celluloid' | |
| class Barbershop | |
| include Celluloid | |
| include Celluloid::Logger | |
| def initialize | |
| @waiting_room = WaitingRoom.new | |
| @barber = Barber.new(Actor.current) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ╰─$ lein vimclojure | |
| Exception in thread "main" java.io.FileNotFoundException: Could not locate clojure/tools/nrepl/ack__init.class or clojure/tools/nrepl/ack.clj on classpath: (lein2.clj:1) | |
| at clojure.lang.Compiler.eval(Compiler.java:5440) | |
| at clojure.lang.Compiler.eval(Compiler.java:5415) | |
| at clojure.lang.Compiler.load(Compiler.java:5857) | |
| at clojure.lang.RT.loadResourceScript(RT.java:340) | |
| at clojure.lang.RT.loadResourceScript(RT.java:331) | |
| at clojure.lang.RT.load(RT.java:409) | |
| at clojure.lang.RT.load(RT.java:381) | |
| at clojure.core$load$fn__4519.invoke(core.clj:4915) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defn A [x y] | |
| (cond | |
| (= y 0) 0 | |
| (= x 0) (* 2 y) | |
| (= y 1) 2 | |
| :else (A (- x 1) | |
| (A x (- y 1))))) | |
| (A 1 10) | |
| (A 0 (A 1 9)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def method_under_test(&block) | |
| SomethingElse.new(&block) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| unless File.exists?('Gemfile') | |
| File.write('Gemfile', <<-GEMFILE) | |
| source 'https://rubygems.org' | |
| gem 'rails', github: 'rails/rails' | |
| gem 'sqlite3' | |
| GEMFILE | |
| system 'bundle' | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function! AckGrep() | |
| let command = "ack ".expand("<cword>") | |
| cexpr system(command) | |
| cw | |
| endfunction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| router = -> | |
| @resource 'campaign_pics', {path: '/campaigns'}, -> | |
| @route 'new' | |
| @resource 'campaign_pic', {path: '/campaigns/:campaign_pic_id'}, -> | |
| @route 'edit' | |
| @resource 'email_templates', {path: '/templates'}, -> | |
| @route 'new', {path: '/new'} | |
| @route 'export', {path: ':email_template_id/export'} |