Skip to content

Instantly share code, notes, and snippets.

View lukesutton's full-sized avatar

Luke Matthew Sutton lukesutton

View GitHub Profile
@mralexgray
mralexgray / customURL.m
Created October 19, 2012 00:33
Register Cocoa app for a custom URL scheme
Here is what you need to do to register your app for a custom URL scheme (for the example we will use a "myapp" scheme).
1) In your Info.plist, add a new entry for CFBundleURLTypes: <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLName</key> <string>MyApp's URL</string> <key>CFBundleURLSchemes</key> <array> <string>myapp</string> </array> </dict> </array>
2) Somewhere in your application's startup code (e.g. init), add this code: - (void)registerMyApp { [[NSAppleEventManager sharedAppleEventManager] setEventHandler:self andSelector:@selector(getUrl:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL]; }
- (void)getUrl:(NSAppleEventDescriptor )event withReplyEvent:(NSAppleEventDescriptor )replyEvent { NSString url = [[event paramDescriptorForKeyword:keyDirectObject] stringValue]; // Now you can parse the URL and perform whatever action is needed }
Related Tidbits:
@maxweisel
maxweisel / clickify.js
Created June 28, 2012 23:35
collect.js - use clean urls with Backbone History / Router
(function($){
// Declare the rootUrl used for filtering internal links.
var rootUrl = document.location.protocol + '//' + (document.location.hostname || document.location.host) + (document.location.port ? ':' + document.location.port : '') + '/';
// Helper functions
var getFragment = function(url, root) { // Grab the fragment and format it how Backbone expects
var fragment = url;
if (fragment.indexOf(':') !== -1)
fragment = fragment.replace(/.*:\/\/[^\/]+/, '');
if (!fragment.indexOf(root)) fragment = fragment.substr(root.length);
@markpundsack
markpundsack / gist:2492606
Created April 25, 2012 19:33
Heroku Status API v3

Heroku Status API v3 (second draft)

Get current status

$ curl "https://status-beta.heroku.com/api/v3/current-status"
{"status":{"Production":"green","Development":"green"},"issues":[]}

Get list of issues (optionally limited by date or count)

@hjr3
hjr3 / e-commerce.md
Created April 3, 2012 05:35
Examples of RESTful API calls for E-commerce platforms

Examples of RESTful API calls for E-commerce platforms

These examples are type 3 RESTful API requests and responses. The JSON-HAL specification is used to implement HATEOAS.

Some of the examples are based on my work as architect of the RESTful API at http://www.hautelook.com. All proprietary information has been removed.

Relevant links

@nz
nz / configuring tire for bonsai.md
Last active October 1, 2015 18:58
Configuring Tire to work with Bonsai

1. Configure Tire to use the Bonsai ElasticSearch Heroku add-on

gem 'tire'

config/initializers/bonsai.rb

ENV['ELASTICSEARCH_URL'] = ENV['BONSAI_URL']
@jimweirich
jimweirich / froth.rb
Created February 22, 2012 23:24
Stupid Simple Forth System in Ruby
# Example Usage: ruby froth.rb ": sq dup * ; 2 sq ."
class Froth
attr_reader :storage
attr_accessor :trace
WordDefinition = Struct.new(:name, :xt, :immediate)
class WordDefinition
def immediate?
immediate

SPA Single page architecture lib design "Spah"

Assumptions:

  • Host API is RESTish
  • All host-client transfer is with JSON and all client-host transfer is with POST and multipart POST.
  • Client-side progressive enhancements are the responsibility of the developer
  • The server-side portion of the library will be ruby-based, and the client-side portion will be jquery-based, but the DTOs used to communicate between two will be thoroughly documented to allow drop-in replacement on either side.
@knowtheory
knowtheory / prettyprint.js
Created April 11, 2011 05:44
A pretty printer for Javascript objects that looks like Ruby's pp formatter. In use on Rhino, untested elsewhere.
function pp(object, depth, embedded) {
typeof(depth) == "number" || (depth = 0)
typeof(embedded) == "boolean" || (embedded = false)
var newline = false
var spacer = function(depth) { var spaces = ""; for (var i=0;i<depth;i++) { spaces += " "}; return spaces }
var pretty = ""
if ( typeof(object) == "undefined" ) { pretty += "undefined" }
else if ( typeof(object) == "boolean" ||
typeof(object) == "number" ) { pretty += object.toString() }
else if ( typeof(object) == "string" ) { pretty += "\"" + object + "\"" }