This file contains hidden or 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
# Recursively diff two hashes, showing only the differing values. | |
# By Henrik Nyh <http://henrik.nyh.se> 2009-07-14 under the MIT license. | |
# | |
# Example: | |
# | |
# a = { | |
# "same" => "same", | |
# "diff" => "a", | |
# "only a" => "a", | |
# "nest" => { |
This file contains hidden or 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 "Generate and deploy assets" | |
task :deploy_assets, :roles => :app do | |
# get the previous timestamp | |
old_timestamp = File.read("config/deploy_timestamp").to_i rescue 0 | |
# generate timestamp into config/deploy_timestamp | |
timestamp = Time.now.to_i | |
File.open("config/deploy_timestamp", 'w') do |f| | |
f.write(timestamp) | |
end |
This file contains hidden or 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 'rubygems' | |
require 'sinatra' | |
require 'net-ldap' | |
require 'digest/sha1' | |
require 'base64' | |
require 'haml' | |
LDAP_HOST = 'localhost' | |
ADMIN_DN = 'cn=admin,dc=company,dc=com' |
This file contains hidden or 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
module BinaryTree | |
class Node | |
attr_reader :word, :count, :left, :right | |
include Enumerable | |
def initialize(word) | |
@word, @count = word, 1 | |
end |
This file contains hidden or 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
# Gemfile | |
source "http://rubygems.org" | |
gem 'eventmachine', '~>1.0.0.beta.3' | |
gem 'em-synchrony', '~>0.3.0.beta.1' | |
gem 'em-http-request', '~>1.0.0.beta3' | |
gem 'addressable', :require => 'addressable/uri' | |
# Capturing and passing cookies on redirects | |
require "rubygems" |
This file contains hidden or 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
#!/bin/bash | |
ROOT_UID=0 | |
FIX_JAR_MIME="rm -vf /usr/share/mime/packages/sun-java*-jre.xml | |
update-mime-database /usr/share/mime" | |
if [ "$UID" -ne "$ROOT_UID" ]; then | |
kdesudo -c "$FIX_JAR_MIME" | |
kbuildsycoca4 #only possible if run as underprivileged | |
else | |
"$FIX_JAR_MIME" |
This file contains hidden or 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 ~/ | |
git clone git://github.com/ariya/phantomjs.git && cd phantomjs | |
qmake-qt4 && make | |
sudo cp bin/phantomjs /usr/local/bin/ |
This file contains hidden or 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 new webpage object | |
var page = new WebPage(); | |
//load the page | |
page.open('http://espn.go.com/nfl', function (status) { | |
//fire callback to take screenshot after load complete | |
page.render('espn.png'); | |
//finish | |
phantom.exit(); | |
}); |
This file contains hidden or 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 page = new WebPage(); | |
page.open('http://espn.go.com/nfl/', function (status) { | |
//once page loaded, include jQuery from cdn | |
page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", function() { | |
//once jQuery loaded, run some code | |
//inserts our custom text into the page | |
page.evaluate(function(){$("h2").html('Many NFL Players Scared that Chad Moon Will Enter League');}); | |
//take screenshot and exit | |
page.render('espn.png'); |
This file contains hidden or 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
sudo apt-get install flashplugin-nonfree msttcorefonts |
OlderNewer