Skip to content

Instantly share code, notes, and snippets.


Ry Biesemeyer yaauie

View GitHub Profile

RFC: On handling exceptions whose constants may not be present

I recently submitted some very dirty [code][1] to mitigate the fact that some of the exceptions we need to handle aren't present on all systems. This isn't the first time I've come across it, and the solution I came up with looks rather terrible.

There must be a better way.

View where.rb
#!/usr/bin/env ruby
# encoding: utf-8
module Where
extend self
def where(cmd)
return enum_for(:where, cmd) unless block_given?
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
exts.each do |ext|
View no_timeout.rb
require 'thread'
require 'timeout'
module NoTimeout
extend self
def no_timeout
current_thread_eigenclass = (class << Thread.current; self; end)
original_raise_method = current_thread_eigenclass.instance_exec do
method(:raise).tap do |original_raise_method|
yaauie /
Created Sep 17, 2013
On a Mac, this script will suspend your user session, locking your computer and bring up the user-switcher without logging you out. I use it in combination with a Quicksilver trigger to be activated on keystroke (⌥⌘L).
/System/Library/CoreServices/Menu\ Extras/ -suspend
View gist:7508274

My general thoughts on Resque Next is that it should be more of a protocol and an interface than an end-all-be-all solution for delayed work in Ruby, that it should provide at least one implementation for each of the interfaces, but that it should leave further implementation up to third-parties and separate include-if-you-want-it gems (that may be published to either the resque org or elsewhere).

This includes the dependency on Redis. When a consumer out-grows Redis and needs to use a queueing service that has actual, non-emulated queueing semantics, they shouldn't have to rewrite all of their worker code and start over from

View gist:7577249

It looks like Ruby's Time::strptime isn't properly plumbed to strptime(3) and ignores week arguments altogether.

# => "ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.3.0]"
002> require 'time'
# => true
003> fmt_string = '%Y-W%W-%w'
# => "%Y-W%W-%w"
004> week_iso8601 = # formatting works

Keybase proof

I hereby claim:

  • I am yaauie on github.
  • I am 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:

    # @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) { } }
View .bash_profile
export PATH=$HOME/.bin:$PATH
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
yaauie / gist:80770b162ad095a6e1e0
Created May 8, 2014
DataMapper InMemoryAddapter that respects your keys.
View gist:80770b162ad095a6e1e0
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 =