Skip to content

Instantly share code, notes, and snippets.

View martinrehfeld's full-sized avatar

Martin Rehfeld martinrehfeld

View GitHub Profile
/*
* CPBundle.sj
* AppKit
*
* Created by Nicholas Small.
* Copyright 2009, 280 North, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@martinrehfeld
martinrehfeld / philerity_env.rb
Created March 5, 2010 08:41 — forked from phillipkoebbe/philerity_env.rb
optimized ENV for Culerity
require 'culerity'
$env_javascript_tag = ENV['CULERITY_JAVASCRIPT_TAG'] || '@javascript'
def set_jruby_env
rvm_jruby = ENV['CULERITY_RVM_JRUBY'] || 'jruby'
info = `rvm info #{rvm_jruby}`
gem_home = info =~ /GEM_HOME:\s?"([^"]*)"/ ? $1 : ''
gem_path = info =~ /GEM_PATH:\s?"([^"]*)"/ ? $1 : ''
my_ruby_home = info =~ /MY_RUBY_HOME:\s?"([^"]*)"/ ? $1 : ''
module RackHeaderHack
def set_headers(headers)
driver = page.driver
def driver.env
@env.merge(super)
end
def driver.env=(env)
@env = env
end
driver.env = headers
@martinrehfeld
martinrehfeld / gist:395331
Created May 9, 2010 18:29 — forked from jamesgolick/gist:345040
Syntax highlighting for Ruby code (webby helper)
require 'syntax/convertors/html'
require 'uv'
module Code
BACKGROUND_COLOR = '#2B2B2B'
COLOR = '#E6E1DC'
COLORS = {
:keyword => '#CC7833',
:symbol => '#6E9CBE',
:constant => '#DA4939',
@martinrehfeld
martinrehfeld / patiently.rb
Created June 10, 2010 20:51 — forked from langalex/patiently.rb
retry wrapper for cucumber steps
def patiently(&block)
cycles = 0
begin
yield
rescue => e
cycles += 1
sleep 0.1
if cycles < 10
retry
else
@martinrehfeld
martinrehfeld / application_helper.rb
Created June 20, 2010 17:54 — forked from indirect/application_helper.rb
Breadcrumbs helper -- requires inherited_resources gem
class ApplicationHelper
def breadcrumbs
result = "".html_safe
association_chain.each_with_index do |item, index|
# note that .name works for both classes and objects
result << link_to(item.name.humanize.titlecase, association_chain[0..index])
result << " &raquo; ".html_safe
end
@martinrehfeld
martinrehfeld / first.rb
Created June 20, 2010 17:57 — forked from mtodd/first.rb
A more clumsy take on breadcrumbs
def get_bread_crumb(request, separator = " &raquo; ", breadcrumb = [], so_far = '/')
url = request.respond_to?(:request_uri) ? request.request_uri : request
elements = url.split('/')
elements.each_with_index do |element, i|
is_last = i == elements.size - 1 # whether this is the last item or not
so_far += element + '/' # the URL for this element
breadcrumb << # append this element to the breadcrumb
case element
var hasFlash = false;
if (navigator.plugins && navigator.plugins.length) {
if (navigator.plugins['Shockwave Flash']) {
hasFlash = true;
}
} else if (navigator.mimeTypes && navigator.mimeTypes.length) {
var mimeType = navigator.mimeTypes['application/x-shockwave-flash'];
hasFlash = mimeType && mimeType.enabledPlugin;
} else {
try {
@martinrehfeld
martinrehfeld / a.md
Created July 3, 2012 08:58 — forked from rkh/a.md

This allows you to use the following video streaming services outside of the US from your Mac without having to use a proxy or VPN, so no big bandwidth issues:

  • Netflix
  • Hulu / HuluPlus
  • CBS
  • ABC
  • MTV
  • theWB
  • CW TV
  • Crackle
@martinrehfeld
martinrehfeld / integration_test_helper.rb
Created July 17, 2012 05:42 — forked from masone/integration_test_helper.rb
Headless integration testing of facebook dialogs with capybara-webkit

## Most important settings

Create a new facebook app (1) and make sure the canvas url (2) in the basic tab matches the host and port configured with Capybara.server_port and Capybara.app_host. Activating sandbox mode (3) in the advanced tab enables you to roll without providing an SSL canvas url. You want to set the display mode (4) of your facebook dialogs to page, which is also the default.

  1. https://developers.facebook.com/apps
  2. http://screencast.com/t/lt6ORnb1sf
  3. http://screencast.com/t/tPSUyE6s
  4. https://developers.facebook.com/docs/reference/dialogs/