View rspec_around_handles_ensure.rb
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}"
View slug.rb
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
View quadrant.rb
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
View gist:e8ca8fae17eb3324d26d
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 ||=
View gist:ef2f8d7732d87d7eb9ed
<core name="catalyst" instanceDir="catalyst" >
<property name="enable.searcher" value="true" />
<property name="enable.master" value="true" />
</core>
View gist:a73eb6a8b6289e59d64d
| Debug
Please submit text block below with your ticket to Fastly
ewogICJnZW9pcCI6IHsKICAgICJjaSI6ICJCYWx0aW1vcmUiLAogICAgInN0IjogIk1EIiwKICAgICJjdCI6ICJVbml0ZWQgU3RhdGVzIiwKICAgICJjbyI6ICJOQSIKICB9LAogICJwb3BMYXRlbmN5IjogewogICAgImRmdyI6IDM2LAogICAgImRlbiI6IDQ2LAogICAgIm9yZCI6IDIxLAogICAgImlhZCI6IDQsCiAgICAiYXRsIjogMTYsCiAgICAiamZrIjogOCwKICAgICJtaWEiOiAyOSwKICAgICJsYXgiOiA2NywKICAgICJzamMiOiA4MCwKICAgICJzZWEiOiA3NQogIH0sCiAgInBvcEFzc2lnbm1lbnRzIjogewogICAgImFjIjogImlhZCIsCiAgICAiYXMiOiAiaWFkIiwKICAgICJkeSI6ICJhdGwiCiAgfSwKICAicmVxdWVzdCI6IHsKICAgICJ0aW1lIjogIjIwMTUtMDQtMTRUMjE6MjY6MTIuMDAwWiIsCiAgICAiaG9zdCI6ICJ3d3cuZmFzdGx5LWRlYnVnLmNvbSIsCiAgICAiYWNjZXB0IjogInRleHQvaHRtbCxhcHBsaWNhdGlvbi94aHRtbCt4bWwsYXBwbGljYXRpb24veG1sO3E9MC45LGltYWdlL3dlYnAsKi8qO3E9MC44IiwKICAgICJ1c2VyYWdlbnQiOiAiTW96aWxsYS81LjAgKE1hY2ludG9zaDsgSW50ZWwgTWFjIE9TIFggMTBfOF81KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWUvNDEuMC4yMjcyLjExOCBTYWZhcmkvNTM3LjM2IiwKICAgICJhY2NlcHRsYW5ndWFnZSI6ICJlbi1VUyxlbjtxPTAuOCIsCiAgICAiY
View gist:053a54c82a970da6d810
<html>
<head>
<title>Fastly Debug App</title>
<style>
* { box-sizing: border-box; }
body {
font-size: 12px;
font-family: 'Helvetica Neue', helvetica, sans-serif;
View gist:4864c69a33ba605e72da
Class Something
attr_accessor :foo
end
something = Something.new
something.respond_to?(:foo) # => true
something.respond_to?(:foo=) # => true
something.respond_to?(:bar) # => false
View gist:22ee1b97a3cb581f9138
to_field "something" do |record, accumulator|
leader = record.leader
# The only reason you want the leader is becuase you are going to do
# SOMETHING with it, right? You're not just gonna index the leader, are ya?
output = do_something_to(leader)
accumulator << output
end
View gist:488d4c5e63677038149d

Thread Pools

A Thread Pool is an abstraction that you can give a unit of work to, and the work will be executed by one of possibly several threads in the pool. One motivation for using thread pools is the overhead of creating and destroying threads. Creating a pool of reusable worker threads then repeatedly re-using threads from the pool can have huge performace benefits for a long-running application like a service.

concurrent-ruby also offers some higher level abstractions than thread pools. For many problems, you will be better served by using one of these -- if you are thinking of using a thread pool, we especially recommend you look at and understand Futures before deciding to use thread pools directly instead. Futures are implemented using thread pools, but offer a higher level abstraction.

But there are some problems for which directly using a thread pool is an appropriate solution. Or, you may wish to make your own thread pool to run Futures on, to be separate or have different characterist