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
var css64Encode = function (string) { | |
return $.base64Encode(string). | |
replace(/\//g, '--_'). | |
replace(/\+/g, '-_'). | |
replace(/\=/g, '_'); | |
}; | |
var css64Decode = function (string) { | |
return $.base64Decode(string. | |
replace(/--_/g, '/'). |
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
# | |
# RFC822 Email Address Regex | |
# -------------------------- | |
# | |
# Originally written by Cal Henderson | |
# c.f. http://iamcal.com/publish/articles/php/parsing_email/ | |
# | |
# Translated to Ruby by Tim Fletcher, with changes suggested by Dan Kubb. | |
# | |
# Licensed under a Creative Commons Attribution-ShareAlike 2.5 License |
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
# monkey patch for setting headers | |
# http://bit.ly/aYhlWg | |
module Capybara | |
class Session | |
def set_request_header(name, value) | |
driver.header(name, value) | |
end | |
end | |
end |
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
desc 'shortcut to do:dev' | |
task :do => 'do:dev' | |
namespace :do do | |
FileList["#{CONFIG_DIR}/*.json"].each do |f| | |
target = File.basename(f, '.*') | |
desc "do stuff for #{target}" | |
task target do | |
Rake::Task['do:stuff'].invoke(target) |
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
# borrowed from rails actionpack/lib/action_view/helpers/javascript_helper.rb | |
JS_ESCAPE_MAP = { | |
'\\' => '\\\\', | |
'</' => '<\/', | |
"\r\n" => '\n', | |
"\n" => '\n', | |
"\r" => '\n', | |
'"' => '\\"', | |
"'" => "\\'" } |
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
$(window).load(function(){ | |
if (!Modernizr.input.placeholder){ | |
$('input').supportPlaceHolder(); | |
} | |
if (!Modernizr.textarea.placeholder){ | |
$('textarea').supportPlaceHolder(); | |
} | |
}); |
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
# I was getting this err out of the blue: [BUG] cross-thread violation on rb_gc() | |
# that's bad news... Here is how I fixed it: | |
curl -o java.1.5.0-leopard.tar.gz http://ituploads.com/software-downloads/apple/java.1.5.0-leopard.tar.gz | |
tar -xvzf java.1.5.0-leopard.tar.gz | |
sudo mv 1.5.0 /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0-leopard | |
cd /System/Library/Frameworks/JavaVM.framework/Versions/ | |
sudo rm 1.5.0 | |
sudo ln -s 1.5.0-leopard 1.5.0 |
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
# adapted from rspec-rails http://github.com/rspec/rspec-rails/blob/master/spec/rspec/rails/mocks/mock_model_spec.rb | |
shared_examples_for "ActiveModel" do | |
require 'test/unit/assertions' | |
require 'active_model/lint' | |
include Test::Unit::Assertions | |
include ActiveModel::Lint::Tests | |
# to_s is to support ruby-1.9 | |
ActiveModel::Lint::Tests.public_instance_methods.map{|m| m.to_s}.grep(/^test/).each do |m| |
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
$ cd ~/clients | |
$ DISPLAY=:1; bundle exec cucumber features/web-client/test.feature --format progress | |
Using the default profile... | |
F.F.F-- | |
(::) failed steps (::) | |
unable to obtain stable firefox connection in 60 seconds (Selenium::WebDriver::Error::WebDriverError) | |
./features/web-client/step_definitions/elements.rb:4:in `evaluate_script' | |
./features/web-client/step_definitions/web.rb:53:in `__instance_exec_609716008' |
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
- (id) init | |
{ | |
/** | |
* Enable cookies | |
**/ | |
NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; | |
[cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; | |
NSHTTPCookie *cookie; | |
for (cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] | |
cookies]) { |