Skip to content

Instantly share code, notes, and snippets.

View olleolleolle's full-sized avatar
🙌
In sunny Malmö in Sweden 🌞

Olle Jonsson olleolleolle

🙌
In sunny Malmö in Sweden 🌞
View GitHub Profile
@johan
johan / sandbox-breaker.js
Created August 23, 2010 10:39
Breaks out of the Greasemonkey / Google Chrome user script sandbox and runs the code in the page scope instead, free of sandbox gotchas and deprived of all privileged API:s.
// This block of code injects our source in the content scope and then calls the
// passed callback there. The whole script runs in both GM and page content, but
// since we have no other code that does anything, the Greasemonkey sandbox does
// nothing at all when it has spawned the page script, which gets to use jQuery.
// (jQuery unfortunately degrades much when run in Mozilla's javascript sandbox)
(function(run_me_in_page_scope) {
if ('undefined' == typeof __RUNS_IN_PAGE_SCOPE__) { // unsandbox, please!
var src = arguments.callee.caller.toString(),
script = document.createElement('script');
script.setAttribute("type", "application/javascript");
#!/usr/bin/env ruby
#
# Sometimes massive failure can cause JsTestDriver to hang
# To debug those cases, it's easier to run test cases one by one
# to track which test case is causing trouble.
#
# This script also helps test less capable browsers such as IE6,
# which can get overwhelmed while trying to run too many tests too
# rapidly.
#
@olleolleolle
olleolleolle / TextMate PHP deprecated style checker helper
Created September 1, 2010 10:45
Deprecations checker: A PHP Bundle script that I put on Ctrl-Shift-V (as a second PHP validation). Will jump to the line of the first reported error.
#!/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
@hugs
hugs / selenium-examples.py
Created February 16, 2011 19:40
Example code for using the Selenium 2 Python bindings.
# 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
@tjsingleton
tjsingleton / heroku_env_logger.rb
Created May 12, 2011 15:23
Middleware that logs heroku requests into redis.
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]
@jonasb
jonasb / install
Created July 16, 2011 09:11
My dotfiles install script
#!/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('~')
@klauswuestefeld
klauswuestefeld / gist:1186975
Created September 1, 2011 19:03
Martin Fowler to Usurp Pattern
We couldn’t find that file to show.
@ebi
ebi / buster.sublime-build
Created September 26, 2011 22:01
Small build system for sublime text 2 to execute Buster.JS
{
"cmd": ["buster-test", "--reporter", "xUnitConsole", "--color", "none"],
"working_dir": "${project_path}",
"selector": "source.js",
"file_regex": "@(.*?):([0-9]*)"
}
@qerub
qerub / x_forwarded_for.clj
Created June 12, 2012 15:06
[Clojure] Ring middleware for `X-Forwarded-For` [:remote-addr rewrite]
(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))))
@peterneubauer
peterneubauer / GoT.sql
Created July 11, 2012 13:12
The Game of Thrones Graph
start westeros=node(0)
set westeros.name = "Westeros"
create targaryen={house:"Targaryen"},
stark={house:"Stark"},
lannister={house:"Lannister"},
baratheon={house:"Baratheon"},
tully={house:"Tully"}