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
# NOT OKAY for Rails5, WILL deadlock if dev-mode class-reloading | |
# an action method in a Rails controller | |
def show | |
futures = 2.times.collect do |n| | |
Concurrent::Future.execute do | |
SomeExpensiveNetworkOrIoWorker.new(n).call | |
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
require 'spec_helper' | |
require 'carmen' | |
# Really more of a set of integration tests, we're proving that tax is actually | |
# calculated how we want on an order | |
describe ByZipTaxCalculator do | |
let!(:taxable_category) { create(:tax_category, name: "Sales and Use Tax", is_default: true) } | |
let!(:non_taxable_category) { create(:tax_category, name: "Non Taxable") } | |
before 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 my_method | |
yield | |
"method" | |
end | |
my_method { return 'block' } | |
# => raises `LocalJumpError: unexpected return` | |
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 'rspec' | |
require 'rspec/autorun' | |
describe "foo" do | |
around do |example| | |
puts "This is before #{example.description}" | |
example.run | |
puts "This is after #{example.description}" |
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 Slug | |
def self.customize(field: :name) | |
Module.new do | |
define_method :to_param do | |
public_send(field).downcase.gsub /\W+/, '-' | |
end | |
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
class Todo | |
attr_accessor :title, :description | |
attr_reader :priority, :urgency | |
def initialize(priority: 1, urgency: 1) | |
@priority, @urgency = priority, urgency | |
raise ArgumentError, "urgency must be between 1 and 10" unless (1..10).cover?(@urgency) | |
raise ArgumentError, "priority must be between 1 and 10" unless (1..10).cover?(@priority) | |
end | |
def quadrant |
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 Todos | |
attr_accessor :priority, :urgency, :title, :description | |
def initialize(priority = 1, urgency = 1) | |
@priority, @urgency = priority, urgency | |
raise ArgumentError, "urgency must be between 1 and 10" unless 1..10 === @urgency | |
raise ArgumentError, "priority must be between 1 and 10" unless 1..10 === @priority | |
end | |
def quadrant | |
@quadrant ||= |
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
<core name="catalyst" instanceDir="catalyst" > | |
<property name="enable.searcher" value="true" /> | |
<property name="enable.master" value="true" /> | |
</core> |
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
| Debug | |
Please submit text block below with your ticket to Fastly | |
ewogICJnZW9pcCI6IHsKICAgICJjaSI6ICJCYWx0aW1vcmUiLAogICAgInN0IjogIk1EIiwKICAgICJjdCI6ICJVbml0ZWQgU3RhdGVzIiwKICAgICJjbyI6ICJOQSIKICB9LAogICJwb3BMYXRlbmN5IjogewogICAgImRmdyI6IDM2LAogICAgImRlbiI6IDQ2LAogICAgIm9yZCI6IDIxLAogICAgImlhZCI6IDQsCiAgICAiYXRsIjogMTYsCiAgICAiamZrIjogOCwKICAgICJtaWEiOiAyOSwKICAgICJsYXgiOiA2NywKICAgICJzamMiOiA4MCwKICAgICJzZWEiOiA3NQogIH0sCiAgInBvcEFzc2lnbm1lbnRzIjogewogICAgImFjIjogImlhZCIsCiAgICAiYXMiOiAiaWFkIiwKICAgICJkeSI6ICJhdGwiCiAgfSwKICAicmVxdWVzdCI6IHsKICAgICJ0aW1lIjogIjIwMTUtMDQtMTRUMjE6MjY6MTIuMDAwWiIsCiAgICAiaG9zdCI6ICJ3d3cuZmFzdGx5LWRlYnVnLmNvbSIsCiAgICAiYWNjZXB0IjogInRleHQvaHRtbCxhcHBsaWNhdGlvbi94aHRtbCt4bWwsYXBwbGljYXRpb24veG1sO3E9MC45LGltYWdlL3dlYnAsKi8qO3E9MC44IiwKICAgICJ1c2VyYWdlbnQiOiAiTW96aWxsYS81LjAgKE1hY2ludG9zaDsgSW50ZWwgTWFjIE9TIFggMTBfOF81KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWUvNDEuMC4yMjcyLjExOCBTYWZhcmkvNTM3LjM2IiwKICAgICJhY2NlcHRsYW5ndWFnZSI6ICJlbi1VUyxlbjtxPTAuOCIsCiAgICAiY |
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
<html> | |
<head> | |
<title>Fastly Debug App</title> | |
<style> | |
* { box-sizing: border-box; } | |
body { | |
font-size: 12px; | |
font-family: 'Helvetica Neue', helvetica, sans-serif; |