Skip to content

Instantly share code, notes, and snippets.

View atnan's full-sized avatar

Nathan de Vries atnan

View GitHub Profile
# 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
#!/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:
#
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();
}
});
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"]
>> 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
/*
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
# 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
//
// 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
#!/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'
//
// 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