I hereby claim:
- I am yaauie on github.
- I am yaauie (https://keybase.io/yaauie) on keybase.
- I have a public key whose fingerprint is 0FA5 1969 4D7F 08F0 083F A1B6 CF2C 1D14 E392 052D
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
# @return [Proc]
def nested_around_hooks
final_hook = lambda { perform_job }
hooks[:around].reverse.inject(final_hook) do |last_hook, hook|
lambda { perform_hook(hook) { last_hook.call } }
end
end
export PATH=$HOME/.bin:$PATH | |
GIT_PS1_SHOWDIRTYSTATE=1 | |
GIT_PS1_SHOWUNTRACKEDFILES=1 | |
GIT_PS1_SHOWUPSTREAM="auto" | |
PS1=' \u@\h \W$(__git_ps1 " (%s)") ' | |
PS1="\n╭ <\e[1;34m\]$PS1\[\e[0m>\n╰ $ " | |
# load bash_completion | |
if [ -f $(brew --prefix)/etc/bash_completion ]; then |
module DataMapper | |
module Adapters | |
# DataMapper.setup(:default, 'in_memory_with_keys::') | |
class InMemoryWithKeysAdapter < InMemoryAdapter | |
def create(resources) | |
records = records_for(resources.first.model) | |
resources.each do |resource| | |
key_names = resource.model.properties(self.name).select(&:key?).map(&:name).map(&:to_s) |
# Get reasonable CLI confirmation before continuing. | |
# | |
# @param text [String] - the descriptive text | |
# @param options [Hash{Symbol=>Object}] | |
# @option options [Boolean] :default - the default action (false) | |
# @option options [#puts] :out - the IO on which to puts output ($stderr) | |
# @option options [#readline] :in - the IO on which to readline input ($stdin) | |
# @option options [String] :prompt - the prompt string ("ok?") | |
# | |
# @example |
$ ruby ~/Desktop/sleepy.rb | |
signals registered. | |
^CCAUGHT INT! | |
4 |
# encoding: utf-8 | |
# | |
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
# Version 2, December 2004 | |
# | |
# Copyright (C) 2004 Ryan Biesemeyer <wtf@yaauie.com> | |
# | |
# Everyone is permitted to copy and distribute verbatim or modified | |
# copies of this license document, and changing it is allowed as long | |
# as the name is changed. |
require 'thread' # Mutex | |
require 'monitor' # MonitorMixin::ConditionVariable | |
# A semaphore that supports Read Locks, Write Locks, and Sized Semaphores | |
class Yaauie::Semaphore | |
INFINITY = Float::INFINITY | |
# @param options [Hash{Symbol=>Object}] | |
# @option options [Integer, INFINITY] :readers_max (INFINITY) | |
def initialize(options = {}) |
def time_thread_contention(options = {}) | |
thread_count = options.fetch(:threads, 10) | |
iterations = options.fetch(:iterations, 10) | |
start_time = Time.now | |
iterations.times.each_slice(thread_count).to_a.transpose.map do |idxs| | |
Thread.new do | |
idxs.each do |idx| | |
yield | |
Thread.pass if idx.odd? |
# @param search [String, Regexp] | |
# @yieldparam time [Time] | |
# @yieldparam payload [String] | |
# @yieldreurn [void] | |
# @return [void] | |
def find_delayed_jobs(search) | |
return enum_for(__method__, search) unless block_given? | |
min = 0 | |
max = '+inf' |