Skip to content

Instantly share code, notes, and snippets.

View albus522's full-sized avatar

David Genord II albus522

View GitHub Profile
# Regex to find <% ... %> which likely should be <%= ... %>
# Excludes:
# <% @.*
# <% end.*
# <% else.*
# <% elsif.*
# <% if[ (].*
# <% unless.*
/<% ([^e@ui]|e[^nl]|en[^d]|el[^s]|els[^ei]|elsi[^f]|u[^n]|un[^l]|unl[^e]|unle[^s]|unles[^s]|i[^f]|if[^ (])/
worker = Delayed::Worker.new(:min_priority => ENV['MIN_PRIORITY'], :max_priority => ENV['MAX_PRIORITY'])
begin
worker.say "Starting job worker"
trap('TERM') { worker.say 'Exiting...'; $exit = true }
trap('INT') { worker.say 'Exiting...'; $exit = true }
loop do
result = nil
_rvm_cd_complete ()
{
local cur matches i j
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
j=${#COMPREPLY[@]}
for dir in $(echo $CDPATH | tr -s ':' ' ') ; do
for i in $( compgen -d $dir/$cur ) ; do
i="${i}/"
def forked!
ActiveRecord::Base.connection.reconnect!
Rails.cache.instance_variable_get(:@data).reset
Mongoid.config.master.connection.close
load File.join(RAILS_ROOT, 'config/initializers/mongoid.rb')
end
def run(job)
runtime = Benchmark.realtime do
fork do
@albus522
albus522 / nginx_1.0.2_start_time.diff
Created May 11, 2011 15:03
Patch to add $start_time variable to nginx 1.0.2 for newrelic queue time. To apply cd to the source root and run "patch -p0 < nginx_1.0.2_start_time.diff"
--- src/http/ngx_http_variables.c.orig 2011-05-11 10:44:09.000000000 -0400
+++ src/http/ngx_http_variables.c 2011-05-11 10:47:25.000000000 -0400
@@ -93,6 +93,9 @@
static ngx_int_t ngx_http_variable_pid(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_http_variable_start_time(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data);
+
/*
class Message
include ActiveModel::Conversion
include ActiveModel::Validations
extend ActiveModel::Naming
attr_reader :attributes
def initialize(attributes = {})
@attributes = attributes
class Message
include ActiveModel::Conversion
include ActiveModel::Validations
extend ActiveModel::Naming
def initialize(attributes = {})
attributes.each do |key, value|
eval "class << self; attr_accessor :#{key}; end"
send("#{key}=", value)
end
diff --git a/lib/delayed/backend/shared_spec.rb b/lib/delayed/backend/shared_spec.rb
index 8dc94eb..7a8caa6 100644
--- a/lib/delayed/backend/shared_spec.rb
+++ b/lib/delayed/backend/shared_spec.rb
@@ -289,16 +289,18 @@ shared_examples_for "a delayed_job backend" do
end
it "reads five jobs" do
- pending
- described_class.should_receive(:find_available).with(anything, 5, anything).and_return([])
diff --git a/lib/delayed/backend/shared_spec.rb b/lib/delayed/backend/shared_spec.rb
index 8dc94eb..822da9a 100644
--- a/lib/delayed/backend/shared_spec.rb
+++ b/lib/delayed/backend/shared_spec.rb
@@ -279,29 +279,6 @@ shared_examples_for "a delayed_job backend" do
end
end
- context "worker read-ahead" do
- before do
@albus522
albus522 / gist:4119536
Created November 20, 2012 17:43
Infinite Jukebox songs
Jem - 24: http://labs.echonest.com/Uploader/index.html?trid=TRZXJDJ13B1BCEA41C
Adiemus - Adiemus (1999 New Version): http://labs.echonest.com/Uploader/index.html?trid=TRAKKYS13B1ECAC375