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
# Set up pool | |
SharedPool = Concurrent::ThreadPoolExecutor.new( | |
:max_threads => 50, | |
:idletime => 10.minutes | |
) | |
# Worker thread | |
results = inputs.map do |input| | |
Concurrent::Future.execute_on(SharedPool) { DB.run_some_query(input) } | |
end.map(&:value!) |
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 UberException < Exception | |
attr_reader :source | |
def initialize(source, context) | |
@source, @context = source, context | |
end | |
def resume(val = nil) | |
@context.call val # Method context lost: LocalJumpError | |
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
# Ruby 2.0.0 is needed for the following code to work | |
def foo value, **keywords | |
puts [value,keywords].inspect | |
end | |
foo("somthing") #This works | |
foo("somthing", key: 'value') #This also works | |
foo(Hash.new(something: 'else')) #This raises 'ArgumentError: wrong number of arguments (0 for 1)' |
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
" Vim color scheme | |
" Name: vividchalk.vim | |
" Author: Tim Pope <[email protected]> | |
" Version: 2.0 | |
" GetLatestVimScripts: 1891 1 :AutoInstall: vividchalk.vim | |
" Based on the Vibrank Ink theme for TextMate | |
" Distributable under the same terms as Vim itself (see :help license) | |
if has("gui_running") |
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
# Instant result methods w/block (and different arities) | |
[ [ %w[partition group_by sort_by min_by max_by minmax_by | |
any? one? all? none?], ""], | |
[ %w[each_slice each_cons each_with_object], "arg" ], | |
[ %w[each_with_index reverse_each each_entry find | |
detect find_index], "*args"] ].each do |methods, arguments| | |
methods.each do |method| | |
class_eval <<-METHOD_DEF | |
def #{method} #{arguments} |