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
# Would help dramatically if the function and arguments were appropriately named | |
def f(ra,n) | |
ra.inject(0) do |accum, value| | |
value.include?(n) ? accum + 1 : accum | |
end | |
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
#!/bin/sh | |
# | |
# This script was written by Toby White under an unknown license, and published | |
# on the Git mailing list: | |
# | |
# http://kerneltrap.org/mailarchive/git/2007/11/21/435536 | |
# | |
# Superficial changes were made by Nathan de Vries to allow the script to be | |
# run under Leopard. Tony's original instructions follow: | |
# |
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
document.observe("dom:loaded", function(loaded) { | |
$("login_via_facebook_connect").observe("click", function(clicked) { | |
FB_RequireFeatures(["Connect"], function() { | |
FB.init("FACEBOOK_API_KEY", "path/to/fb_crossdomain_communications_channel.html", { | |
ifUserConnected: function(uid) { | |
// SessionController#create will get the Facebook session from the | |
// cookie set by Facebook on the Cross Domain Communication Channel | |
clicked.element().up("form").submit(); | |
} | |
}); |
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 "uri" | |
require "net/http" | |
class ShortUrl | |
def self.expand(url) | |
uri = URI.parse(url) | |
response = Net::HTTP.start(uri.host, uri.port) do |request| | |
request.head(uri.path) | |
end | |
response["Location"] |
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
>> endpoint | |
=> #<OpenID::OpenIDServiceEndpoint:0x3f4acc4 @local_id=nil, @display_identifier=nil, @type_uris=["http://specs.openid.net/auth/2.0/server", "http://specs.openid.net/extensions/pape/1.0", "http://openid.net/sreg/1.0", "http://openid.net/extensions/sreg/1.1"], @used_yadis=true, @server_url="https://open.login.yahooapis.com/openid/op/auth", @canonical_id=nil, @claimed_id=nil> | |
>> endpoint.uses_extension("http://specs.openid.net/auth/2.0/signon") | |
=> false |
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
/* | |
Copyright (c) 2009 Nathan de Vries | |
Permission is hereby granted, free of charge, to any person obtaining | |
a copy of this software and associated documentation files (the | |
"Software"), to deal in the Software without restriction, including | |
without limitation the rights to use, copy, modify, merge, publish, | |
distribute, sublicense, and/or sell copies of the Software, and to | |
permit persons to whom the Software is furnished to do so, subject to |
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
# define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); | |
# ifdef DEBUG | |
# define DLog(fmt, ...) ALog(fmt, ##__VA_ARGS__); | |
# else | |
# define DLog(...) | |
# endif |
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
// | |
// UIApplication+TVOut.m | |
// MediaMotion2 | |
// | |
// Created by Rob Terrell on 5/15/09 | |
// Copyright 2009 Stinkbot LLC. All rights reserved. | |
// | |
#define kFPS 10 | |
#define kUseBackgroundThread YES |
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
#!/usr/bin/env ruby | |
def rake_silent_tasks | |
dotcache = "#{File.join(File.expand_path('~'), ".raketabs-#{Dir.pwd.hash}")}" | |
if File.exists?(dotcache) | |
Marshal.load(File.read(dotcache)) | |
else | |
require 'rubygems' | |
require 'rake' | |
load 'Rakefile' |
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
// | |
// SynthesizeSingleton.h | |
// CocoaWithLove | |
// | |
// Created by Matt Gallagher on 20/10/08. | |
// Copyright 2009 Matt Gallagher. All rights reserved. | |
// | |
// Permission is given to use this source code file without charge in any | |
// project, commercial or otherwise, entirely at your risk, with the condition | |
// that any redistribution (in part or whole) of source code must retain |