This file contains 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
require 'benchmark' | |
nelements = 10 | |
nlines = 10 | |
def repeating_string(base, elements, lines) | |
(([base]*elements).join(',')+"\n")*lines | |
end | |
# test string |
This file contains 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
GC.start | |
first_count = ObjectSpace.each_object(String) { |x| nil } | |
def dummy_function | |
'foo' | |
end | |
second_count = ObjectSpace.each_object(String) { |x| nil } | |
GC.start | |
second_after_gc_count = ObjectSpace.each_object(String) { |x| nil } |
This file contains 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
begin | |
require 'bundler/inline' | |
rescue LoadError => e | |
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler' | |
raise e | |
end | |
gemfile(true) do | |
source 'https://rubygems.org' | |
# NOTE: tests pass on 4.1.x, fail on 4.2 |
This file contains 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 tag="tabs"> | |
<set-scoped tab-names="&[]" tab-contents="&{}"> | |
<ul class="tabs" merge> | |
<do param="default" /> | |
</ul> | |
<do repeat="&scope.tab_names"> | |
<div id="#{this}"> | |
<%= scope.tab_contents[this] %> | |
</div> | |
</do> |
This file contains 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 tag="page" attrs="title, full-title"> | |
<% full_title ||= "#{title} : #{app_name}" %> | |
<html merge-attrs> | |
<head param> | |
<title param><%= strip_tags full_title %></title> | |
<stylesheet name="reset" /> | |
<do param="scripts"> | |
<javascript param name="prototype, effects, dragdrop, controls, lowpro, hobo-rapid"/> | |
<if-ie version="lt IE 7" param="fix-ie6"> |
This file contains 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
en: | |
reservations: | |
messages: | |
create: | |
success: "The appointment was created successfully" | |
error: "Couldn't create the appointment. #{errors}" | |
update: | |
success: "Changes to the appointment were saved" |
This file contains 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
module Outer | |
module M | |
def foo | |
if self.class.superclass.instance_methods.include?('foo') | |
super | |
else | |
puts 'module foo' | |
end | |
end | |
end |
This file contains 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 tag="js-wrapper" attrs="convert"> | |
<set-scoped vals="&[]"> | |
<do param="default" /> | |
<% if convert %> | |
<%= "[#{scope.vals.*.inspect.join(', ')}]" %> | |
<% else %> | |
<% scope.retval = scope.vals %> | |
<% end %> | |
</set-scoped> | |
</def> |
This file contains 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
begin | |
require 'bundler/inline' | |
rescue LoadError => e | |
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler' | |
raise e | |
end | |
gemfile(true) do | |
source 'https://rubygems.org' | |
gem 'activerecord', '4.2.4' |