Skip to content

Instantly share code, notes, and snippets.

View dbalatero's full-sized avatar

David Balatero dbalatero

View GitHub Profile
#!/usr/bin/env ruby
# Given a lock name and a trailing command, this program
# ensures there's only one instance of a given program running
# at a time, by blocking on a ZooKeeper lock.
#
# Usage:
# ./ensure_locked.rb [lock name] bundle exec rake resque:scheduler
#
diff --git a/element-breakoutrow.php b/element-breakoutrow.php
index 8382135..4b90f24 100644
--- a/element-breakoutrow.php
+++ b/element-breakoutrow.php
@@ -28,10 +28,10 @@
'paged'=>$paged, // Basic pagination stuff.
);
- query_posts($args);
+ $footer_post_query = new WP_Query($args);
<?php
class MediaPistonVerifier {
private $endpoint_path;
private $query_params;
private $api_private_key;
/*
* Constructor:
*
* @param endpoint_path - the path that your notification script is
u = ->(m) do
y = ->(*a, &b) { y = ->(*a) { b.(*a, &y) } }
r = ->(n, f) do
i, g = f.()
i <= n ? [i] + r.(n, g) : []
end
r.(m, y.() { |i, j, &b| -> { [j, b.(j, i + j)] } }.(1, 1))
end
We couldn’t find that file to show.
#header {
display: block;
/* change to w/h of image */
width: 600px;
height: 400px;
/* set the background of the <h1> tag to the header image */
background: transparent url(/path/to/image.png) no-repeat;
/* indent all plain text 99999 pixels off screen */
@dbalatero
dbalatero / failover.rb
Created October 26, 2011 07:17
Provides basic failover for Resque -> MySQL
module Resque
# Provides a Failover to MySQL.
module Failover
def self.extended(base)
base.class_eval do
class << self
alias_method_chain :enqueue, :active_record_failover
alias_method_chain :enqueue_at, :active_record_failover
end
end
1)
'Typhoeus::Response headers when the headers_hash is stubbed returns a properly formatted string built from the headers_hash, code, status_message and http_version' FAILED
expected collection contained: ["\r", "Connection: keep-alive\r", "Content-Length: 0\r", "Content-Type: text/plain\r", "Server: thin 1.2.11 codename Bat-Shit Crazy\r", "Set-Cookie: bar\r", "Set-Cookie: foo\r", "X-Frame-Options: sameorigin\r", "X-Xss-Protection: 1; mode=block\r"]
actual collection contained: ["\r", "Connection: keep-alive\r", "Content-Length: 0\r", "Content-Type: text/plain\r", "Server: thin 1.2.11 codename Bat-Shit Crazy\r", "Set-Cookie: bar\r", "Set-Cookie: foo\r", "X-Frame-Options: sameorigin\r", "X-XSS-Protection: 1; mode=block\r"]
the missing elements were: ["X-Xss-Protection: 1; mode=block\r"]
the extra elements were: ["X-XSS-Protection: 1; mode=block\r"]
100.times do
Thread.new do
array = []
while true
array << ("hahahaha" * 100000000000)
if rand < 0.10
sleep(5) # randomly get a 5 second break from all this
end
end
module A
def self.foo
puts "yes"
end
end
module B
def foo
puts "no"
end