Skip to content

Instantly share code, notes, and snippets.

View agibralter's full-sized avatar
:shipit:

Aaron Gibralter agibralter

:shipit:
View GitHub Profile
@agibralter
agibralter / inherited.rb
Last active August 3, 2023 10:34
Trying to figure out how to properly `include` an `inherited` hook
module Hook
def self.included(base)
# base.extend ClassMethods
base.class_eval do
# def self.inherited(baseclass)
# # super
# puts "1 #{baseclass.to_s}"
module ActiveRecordEachBy
# This method lets you iterate over the results of a .find, in groups.
# (Basically an interface to LIMIT.)
# Anything you can pass as options to .find, you can pass here.
# Example 1:
# Order.each_by(100, :conditions => { :cc_processed_at => nil }) do |order|
# # do stuff with order
# end
# Example 2:
# Person.each_by(50, :order => 'name') do |person, index|
@agibralter
agibralter / culerity-hooks.rb
Created April 2, 2010 18:31
Cucumber hooks for culerity + rvm
Before("@culerity,@celerity,@javascript") do |scenario|
unless @env_rvm_jruby
@env_rvm_jruby = {}
require 'yaml'
rvm_info = YAML::load(`bash -l -c 'source ~/.rvm/scripts/rvm; rvm jruby ; rvm info'`).values.first
rvm_info['environment'].each do |k, v|
@env_rvm_jruby[k] = v
end
@env_jruby_path = rvm_info['binaries']['ruby'].gsub(%r{^(.*)/ruby$}, '\1')
end
@agibralter
agibralter / gist:430807
Created June 8, 2010 23:41
a hack so facebooker doesn't cause cucumber steps to explode if using rack 1.1.0
ActionController::Integration::Session.class_eval do
def generic_url_rewriter
env = {
'REQUEST_METHOD' => "GET",
'QUERY_STRING' => "",
"REQUEST_URI" => "/",
"HTTP_HOST" => host,
"SERVER_PORT" => https? ? "443" : "80",
"HTTPS" => https? ? "on" : "off",
"rack.input" => "wtf"

Keybase proof

I hereby claim:

  • I am agibralter on github.
  • I am agibralter (https://keybase.io/agibralter) on keybase.
  • I have a public key whose fingerprint is BA38 FE55 E22E 227E B70D DCE9 A847 216C 1298 BF13

To claim this, I am signing this object:

class GiantRobot
constructor: ->
@moves = []
smash: ->
@moves.push("smash!")
crash: ->
@moves.push("crash!")
html = $ JST["some_template"]
foo: bar
@agibralter
agibralter / gist:4744055
Last active December 12, 2015 08:29
split vs. index
require 'benchmark'
n = 100000
a = nil
b = nil
c = nil
STRING = "foo=bar; domain=example.com; path=/; expires=Sat, 09-Feb-2013 07:27:33 GMT; HttpOnly".freeze
Benchmark.bm do |x|
@agibralter
agibralter / local_redis.rb
Last active December 11, 2015 04:58
Trying to get `ThinkingSphinx::Test.start_with_autostop` and Redis to stop when guard exits.
# -*- encoding : utf-8 -*-
module LocalRedis
module ClassMethods
def run_in_foreground!
unless pid = fork
Dir.chdir(Rails.root)
exec(cmd)
end
Verifying that +agibralter is my blockchain ID. https://onename.com/agibralter