This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create a mock iterator over the given array. | |
* | |
* @param array $a | |
* @param string $class The class to use for the mock, should be/implement/extend Iterator | |
* @param boolean $complete Whether or not to build a complete iteration. This is | |
* used when an exception/break is expected in the middle of the iteration. | |
* @param integer $numElms The number of elements that should be iterated in the case of an | |
* incomplete iteration. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- replace table_name with the name of your database table, e.g. users | |
-- replace data with the serialized field in the table, e.g. nicknames | |
-- output generates serialized data that decrypts to a Ruby array. | |
-- data with quotes, hyphens, or spaces will have issues with this query. | |
-- preview the YAML to JSON to confirm the conversion is working. | |
SELECT data, REPLACE(REPLACE(REPLACE(REPLACE(REGEXP_REPLACE(REPLACE(REPLACE(REPLACE(data, | |
' ', ''), | |
'...', ''), | |
'---', '["'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start westeros=node(0) | |
set westeros.name = "Westeros" | |
create targaryen={house:"Targaryen"}, | |
stark={house:"Stark"}, | |
lannister={house:"Lannister"}, | |
baratheon={house:"Baratheon"}, | |
tully={house:"Tully"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns ring.middleware.x-forwarded-for | |
(:use [clojure.string :only (split)])) | |
(defn wrap-x-forwarded-for [handler] | |
(fn [request] | |
(if-let [xff (get-in request [:headers "x-forwarded-for"])] | |
(handler (assoc request :remote-addr (last (split xff #"\s*,\s*")))) | |
(handler request)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"cmd": ["buster-test", "--reporter", "xUnitConsole", "--color", "none"], | |
"working_dir": "${project_path}", | |
"selector": "source.js", | |
"file_regex": "@(.*?):([0-9]*)" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# update git submodules | |
`git submodule init && git submodule update` | |
# update symlinks | |
# inspired by http://errtheblog.com/posts/89-huba-huba | |
home = File.expand_path('~') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "csv" | |
class HerokuEnvLogger | |
PREFIX = "HerokuRequest" | |
TIME_STEP = 1.minute * 1000 # ms | |
EXPIRE_IN = 6.hours | |
KEYS = %w[HTTP_X_REQUEST_START | |
HTTP_X_HEROKU_QUEUE_WAIT_TIME | |
HTTP_X_HEROKU_QUEUE_DEPTH | |
HTTP_X_HEROKU_DYNOS_IN_USE] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To install the Python client library: | |
# pip install -U selenium | |
# Import the Selenium 2 namespace (aka "webdriver") | |
from selenium import webdriver | |
# iPhone | |
driver = webdriver.Remote(browser_name="iphone", command_executor='http://172.24.101.36:3001/hub') | |
# Android |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# Uses Stas Malyshev's migrate.php script to check code style | |
# | |
require ENV['TM_SUPPORT_PATH'] + '/lib/textmate' | |
version = %x{#{ENV['TM_PHP'] || 'php'} -v}.split[0..2].join(' ') | |
result = `#{ENV['TM_PHP'] || 'php'} /Users/olle/opensource/php/migrate/migrate.php '#{ENV['TM_FILEPATH']}'` | |
result.gsub!("in file #{ENV['TM_FILEPATH']}", '') | |
puts "OK!" if result.empty? | |
puts result |