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 jqe(str) | |
str.gsub( /[!"\#$%&'()*+,.\/:\\;<=>?@\[\]^`{|}~]/, '\\\\\\\\\&') | |
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
# encoding: utf-8 | |
class DocumentUploader < CarrierWave::Uploader::Base | |
include ::CarrierWave::Backgrounder::Delay | |
include CarrierWave::MimeTypes | |
# Include RMagick or MiniMagick support: | |
include CarrierWave::RMagick | |
# include CarrierWave::MiniMagick | |
include CarrierWave::UNOConv |
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
The following items are not documented: | |
class ARGF # is documented | |
# in file io.c:11364 | |
# +ARGF.argv->ARGV+ is not documented |
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
diff --git a/lib/profiler.rb b/lib/profiler.rb | |
index be33daf..22f3490 100644 | |
--- a/lib/profiler.rb | |
+++ b/lib/profiler.rb | |
@@ -76,7 +76,7 @@ module Profiler__ | |
@@start = nil # the start time that profiling began | |
@@stacks = nil # the map of stacks keyed by thread | |
@@maps = nil # the map of call data keyed by thread, class and id. Call data contains the call count, total time, | |
- PROFILE_CALL_PROC = TracePoint.new(*%i[call c_call b_call]) {|tp| # :nodoc: | |
+ PROFILE_CALL_PROC = TracePoint.new(:call, :c_call, :b_call) {|tp| # :nodoc: |
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
class Foo | |
extend Forwardable | |
def_delegators :'self.class', :foo, :bar | |
def self.foo | |
:foo | |
end | |
def self.bar | |
'bar' |
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
#! /usr/bin/env ruby | |
class FizzBuzz | |
attr_reader :limit, :matchers | |
DEFAULT_LIMIT = 100 | |
DEFAULT_MATCHERS = [ | |
-> x { "Fizz" if (x % 3).zero? }, | |
-> x { "Buzz" if (x % 5).zero? }, |
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
class FooBaz | |
attr_reader :replacements, :range | |
def initialize range, replacements | |
@range = range | |
@replacements = replacements | |
end | |
def call | |
range.each do |number| |
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
- 100.times do | |
%p/ | |
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
DIGIT_VALUES = { | |
'I' => 1, | |
'IV' => 4, | |
'V' => 5, | |
'IX' => 9, | |
'X' => 10, | |
'XL' => 40, | |
'L' => 50, | |
'XC' => 90, | |
'C' => 100, |
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 count_queries(&blk) | |
x = 0 | |
counter = -> (*args) { x += 1 } | |
ActiveSupport::Notifications.subscribed counter, 'sql.active_record', &blk | |
x | |
end |
OlderNewer