Skip to content

Instantly share code, notes, and snippets.

View jridgewell's full-sized avatar
😬

Justin Ridgewell jridgewell

😬
  • New York, NY
  • 06:22 (UTC -04:00)
View GitHub Profile
var doc = $(new DOMParser().parseFromString(response.responseText.replace(/\&taglist\=/g,'&taglist='), 'text/xml'));
@jridgewell
jridgewell / applescript_service
Created August 7, 2011 22:34
Open file/folder in MacVim. Preceded by get Finder Selection
on run {input, parameters}
repeat with i in input
tell application "MacVim"
open (POSIX path of i)
end tell
end repeat
tell application "MacVim"
activate
end tell
return input
#!/usr/bin/env ruby
###########################################################################
# Script to be called as an Xcode 4 behaviour which will attempt to
# uncrustify all source files in the open project.
#
# (c) Copyright 2012 David Wagner.
#
# Complain/commend: http://noiseandheat.com/
#
#*************************************************************************#
@jridgewell
jridgewell / Bookmarklet.js
Created April 2, 2013 22:24
Search 1Password Bookmarklet for iOS
javascript:d=window.location.hostname.split('.');window.location='onepassword://search/'+((d.length>2)?d[1]:d[0]);
@jridgewell
jridgewell / iOSOpenDev-Install.sh
Created April 3, 2013 06:32
A script to install iOSOpenDev
#!/bin/bash
# --------------------------------------------------------------
# iOSOpenDev -- iOS Open Development (http://www.iOSOpenDev.com)
# Copyright (C) 2012 Spencer W.S. James <dev@iosopendev.com>
# --------------------------------------------------------------
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
@jridgewell
jridgewell / adblock.diff
Created June 1, 2013 21:22
Patch Safari Adblock to only blacklist sites.
diff --git a/background.js b/background.js
index f55a9ac..8e2160a 100644
--- a/background.js
+++ b/background.js
@@ -295,6 +295,11 @@
try_to_unwhitelist = function(url) {
url = url.replace(/#.*$/, ''); // Whitelist ignores anchors
var custom_filters = get_custom_filters_text().split('\n');
+ var domain = parseUri(url).hostname.match(/[^.]+\.[^.]+$/);
+ custom_filters[0] += "|~" + domain;
@jridgewell
jridgewell / models.rb
Last active December 18, 2015 09:19
Polymorphic select
class Catch < ActiveRecord::Base
belongs_to :animal, :polymorphic => true
end
class Bird < ActiveRecord::Base
attr_accessible :name
has_one :catch, :as => :animal
end
class Fish < ActiveRecord::Base
@jridgewell
jridgewell / mapReduce.rb
Last active December 18, 2015 16:09
mapReduce geoSpacial in Mongo
require 'mongo_mapper'
map = %Q(function() {
lat_long = Math.floor(this.lat) + Math.floor(this.lon);
emit(lat_long, this.id);
})
reduce = %Q(function(id, values) {
return vals;
})
output_collection = "database.1by1"
@jridgewell
jridgewell / Delegator.php
Created January 20, 2015 23:35
A Delegator Class to extend from
<?php
class Delegator {
private $obj;
public static function from($array) {
return array_map(function($obj) {
return new Delegator($obj);
}, $array);
}
@jridgewell
jridgewell / index.js
Created February 4, 2015 23:42
requirebin sketch
var metal = require('backbone-metal');
metal.deprecate('test');