Skip to content

Instantly share code, notes, and snippets.

Ry Biesemeyer yaauie

Block or report user

Report or block yaauie

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View where.rb
# 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|
(cd $(bundle show yajl-ruby)/ext/yajl; sed -i '.bak' 's/inline void/static void/g' yajl_ext.h yajl_ext.c; make clean all)
View exception.cause.rb
# quick and dirty back-port of Ruby 2.1's Exception#cause
class Exception
allocate.tap do |exception|
exception.send(:initialize, *args)
exception.cause = $!
# @return [Exception, nil]
View pry-kernel.raise.rb
# encoding: utf-8
require 'pry'
module Kernel
alias_method :raise_without_pry, :raise
def raise_with_pry(*a, &b)
# `exit true` to continue *without* raising.
binding.pry || raise_without_pry(*a, &b)
alias_method :raise, :raise_with_pry
View hourly-week-distribution
#!/usr/bin/env ruby
# Given STDIN of unix timestamps (one or more per line),
# analyze the weekly distribution at hourly granularity.
day_counts_by_hour = []
$stdin.each_line do |line|
next if line.chomp.empty?

Sometimes your redis needs a little help keeping up with expiries.

First, it's helpful to know how expiries are handled in redis internals:

Redis keys are expired in two ways: a passive way, and an active way.

A key is actively expired simply when some client tries to access it, and the key is found to be timed out.

yaauie / gi
Created Nov 21, 2014
Lately I've been fat-fingering git commands, injecting a space between `gi` and `t` and failing to inject a space between that `t` and the command; this simple script fixes that.
View gi
#!/usr/bin/env ruby
# gi - a dynamic alias for poorly-typed git commands
# handle a command `gi tdiff --cached`,
# transparently as `git diff --cached`.
exit(127) if ARGV.empty?
exit(127) unless ARGV.first.start_with?('t')
argv = ARGV.dup
View easy-krypt.rb
# encoding: utf-8
require 'openssl'
class EasyKrypt
class Error < RuntimeError
def initialize(*args)
@cause = $!
attr_reader :cause
View united-states-simplified-sea-borders.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
yaauie / resque-scheduler-find-delayed-job.rb
Last active Aug 29, 2015
Scan through all Resque Scheduler delayed jobs and emit the timestamps and payload of all matching jobs.
View resque-scheduler-find-delayed-job.rb
# @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'
You can’t perform that action at this time.