Skip to content

Instantly share code, notes, and snippets.

@stevehodgkiss
stevehodgkiss / redis_timeout_issue_spec.rb
Last active August 29, 2015 13:58
Redis issues with Timeout on Ruby 2.1.1
require 'redis'
require 'securerandom'
require 'timeout'
describe 'timeout/redis issues' do
def reconnect
$redis = Redis.new(db: 1, :port => ENV.fetch('BOXEN_REDIS_PORT', '6379'))
end
def ruby_211_timeout(sec, klass = nil)
@stevehodgkiss
stevehodgkiss / native_columns_store.rb
Last active April 6, 2018 06:56
Allow specified session keys to be stored in a separate column using ActiveRecordStore. Useful for clearing sessions based on user_id.
class NativeColumnStore < ActiveRecord::SessionStore::Session
class << self
attr_reader :native_columns
def native_columns=(columns)
@native_columns = columns.map(&:to_s)
end
@native_columns = []
end
def data
@stevehodgkiss
stevehodgkiss / 1.9.3-p194-falcon
Created October 1, 2012 04:21
ruby-build definition for 1.9.3-p194-falcon https://gist.github.com/3721565
build_package_combined_patch() {
local package_name="$1"
{
curl https://raw.github.com/gist/3721565/91bcda69e3fb998fe160707b8a80334327cc9e61/falcon.patch | patch -p1
autoconf
./configure --prefix="$PREFIX_PATH" $CONFIGURE_OPTS
make -j 8
make install
} >&4 2>&1
@stevehodgkiss
stevehodgkiss / zxcvbn.rb
Created September 13, 2012 04:49
Run zxcvbn.js from ruby with therubyracer
# therubyracer gem - https://github.com/cowboyd/therubyracer
require 'v8'
password = ARGV[0] || 'password'
ARGV.clear
puts "Testing password: #{password}"
puts
class PasswordStrength
@stevehodgkiss
stevehodgkiss / 1.9.3-p125-railsexpress
Created April 26, 2012 02:26
ruby-build definition for 1.9.3-p125-railsexpress
build_package_combined_patch() {
local package_name="$1"
{
curl https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.3/p125/railsexpress/01-merge-revision-s-34719-34720-b.patch | patch -p1
curl https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.3/p125/railsexpress/02-railsbench-gc.patch | patch -p1
curl https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.3/p125/railsexpress/03-display-more-detailed-stack-trace.patch | patch -p1
curl https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.3/p125/railsexpress/04-fork-support-for-gc-logging.patch | patch -p1
curl https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.3/p125/railsexpress/05-track-live-dataset-size.patch | patch -p1
autoconf
@stevehodgkiss
stevehodgkiss / wol
Created April 20, 2012 00:47
Command to send wake on lan packets
#!/usr/bin/env ruby
@mac = "xx:xx:xx:xx:xx:xx"
@address = "myaccount.dyndns.org"
@port = "9"
@count = 3
require 'socket'
@socket = UDPSocket.open
@socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, 1)
@stevehodgkiss
stevehodgkiss / 1.9.3-p125-falcon.sh
Created April 5, 2012 04:23
ruby-build definition for a patched 1.9.3-p125
build_package_combined_patch() {
local package_name="$1"
{
curl https://raw.github.com/gist/1859082/performance_and_backport_gc.patch | patch -p1
autoconf
./configure --prefix="$PREFIX_PATH" $CONFIGURE_OPTS
make -j 8
make install
} >&4 2>&1
@stevehodgkiss
stevehodgkiss / freeagent.rb
Created February 25, 2012 23:42
Script to download all your attachments on FreeAgent
require 'rubygems'
require 'freeagent'
require 'eventmachine'
require 'em-synchrony'
require 'em-http-request'
require 'em-synchrony/fiber_iterator'
require 'active_support'
ATTACHMENTS_DIR = '/Users/steve/Documents/freeagent_attachments'
build_package_patched() {
local package_name="$1"
{
curl https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.2/p290/railsexpress/01-railsbench-gc-patch.patch | patch -p1
curl https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.2/p290/railsexpress/02-display-more-detailed-stack-trace.patch | patch -p1
curl https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.2/p290/railsexpress/03-fork-support-for-gc-logging.patch | patch -p1
curl https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.2/p290/railsexpress/04-track-live-dataset-size.patch | patch -p1
curl https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.2/p290/railsexpress/05-load-performance-fix.patch | patch -p1
curl https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.2/p290/railsexpress/06-trace-bmethods.patch | patch -p1
@stevehodgkiss
stevehodgkiss / hooks.rb
Created April 19, 2011 10:07
Automatically save and open page when a @wip scenario fails
After do |scenario|
if scenario.failed? && scenario.source_tag_names.include?("@wip")
save_and_open_page
end
end