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 Foo | |
| CONST_ON_FOO = "the constant on Foo" | |
| class << self | |
| puts "When we're defining CONST_ON_FOOS_CLASS, we're actually in: #{self}, a #{self.class}" | |
| CONST_ON_FOOS_CLASS = "the constant on Foo's class" | |
| end | |
| end | |
| instance = Foo.new |
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
| begin | |
| begin | |
| raise Exception.new("An Exception") | |
| rescue => e | |
| puts "Rescued an unspecified error: #{e.message}" | |
| end | |
| rescue Exception => e | |
| puts "Rescued an exception: #{e.message}" | |
| 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
| $ npm test | |
| > [email protected] test D:\projects\favicons-webpack-plugin | |
| > ava | |
| loudRejection/api is deprecated. Use the currently-unhandled module instead. | |
| 4 passed | |
| 3 failed |
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 insert_part(container, response, charset) | |
| part_list = super | |
| part = part_list.last | |
| part.header[:content_transfer_encoding] = "quoted-printable" | |
| part_list | |
| 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
| module InlineMailPartUrls | |
| def url | |
| # I'm toggling this behaviour based on an environment variable. | |
| # As far as I can see, there is no (better) way to decide whether or not | |
| # the url is being called from a Rails Mailer Preview vs the actual Mailer call. | |
| if ENV["INLINE_MAIL_PART_URLS"] == "true" | |
| # Encode the part body in a data URI | |
| # http://en.wikipedia.org/wiki/Data_URI_scheme | |
| "data:#{mime_type};base64,#{Base64.encode64(body.decoded)}" | |
| else |
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 "Underscore Extend", -> | |
| describe "simple objects", -> | |
| it "bequeaths properties", -> | |
| obj = | |
| prop: "value" | |
| expect(_.extend({}, obj).prop).toEqual("value") | |
| it "bequeaths methods", -> | |
| obj = | |
| meth: () -> |
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
| module InstanceCache | |
| def self.included(receiver) | |
| receiver.extend(ClassMethods) | |
| end | |
| module ClassMethods | |
| # Override me for good times | |
| def find_by_cache_key(cache_key) | |
| find(cache_key) |
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
| module A | |
| def a_method | |
| "a method" | |
| end | |
| end | |
| module B | |
| extend A | |
| def b_method |
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
| #!/usr/bin/env ruby | |
| search = Regexp.new(ARGV[0]) | |
| output = `git branch` | |
| matching = output.lines.select{ |l| l.match(search) } | |
| if matching.size == 0 | |
| STDERR.puts "No branch matches #{ARGV[0]}" | |
| elsif matching.size == 1 | |
| `git checkout #{matching[0].strip}` | |
| else | |
| puts "Multiple branches matched:" |
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
| #!/usr/bin/env ruby | |
| require "rubygems" | |
| require 'activesupport' | |
| file_name = ARGV[0].underscore.gsub(/_test$/, "") | |
| test_name = ARGV[1].gsub(" ", "_") if ARGV[1] | |
| paths = [ | |
| "test/unit/#{file_name}_test.rb", | |
| "test/unit/helpers/#{file_name}_test.rb", |
NewerOlder