Skip to content

Instantly share code, notes, and snippets.

View zholmquist's full-sized avatar
🏠
Working from home

Zach Holmquist zholmquist

🏠
Working from home
View GitHub Profile
/*
jQuery publish/subscribe by Mark Meyer
- http://markdotmeyer.blogspot.com/2008/09/jquery-publish-subscribe.html
jQuery unsubscribe by Zach Holmquist
*/
jQuery.subscribe = function( eventName, obj, method ){
$(window).bind( eventName, function() {
obj[method].apply( obj, Array.prototype.slice.call( arguments, 1 ) );
});
return jQuery;
<script>
//#function
function track_event(category, action, label)
{
if(window.pageTracker) {
pageTracker._trackEvent(category, action, label);
}
}
@font-face
{
font-family: "Delicious";
src: url("/fonts/delicious.otf");
}
body
{
font-family: "Delicious", "Helvetica Neue", Arial, sans-serif;
}
Function.prototype.before = function() {
console.debug('before')
};
function someObject()
{
this.before = Function.prototype.before
}
<script>
Function.prototype.before = function(methodName, newFunc) {
var oldFunc = this[methodName];
console.debug(oldFunc)
};
function someObject()
Function.prototype.before = function(methodName, newFunc) {
if(typeof this == "function") {
var oldFunc = this.prototype[methodName];
this.prototype[methodName] = function() {
newFunc.apply(this, arguments);
return oldFunc.apply(this, arguments);
};
} else if(typeof this == "object") {
var oldFunc = instance[methodName];
instance[methodName] = function() {
@zholmquist
zholmquist / gist:658474
Created November 1, 2010 16:42
Forcing Landscape Mode on iOS Apps
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) ||
(interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
@zholmquist
zholmquist / gist:1279669
Created October 11, 2011 22:33
OAuth Popups
/* netflix oauth */
this.beginNetflixOAuth = function()
{
var popupParams = 'location=0,status=0,width=320,height=480';
self._netflixWindow = window.open('/login/', 'netflixWindow', popupParams);
self._netflixInterval = window.setInterval(self.completeNetflixConnect, 1000);
self.logEvent('Authentication', 'netflix', 'begin')
};
/* netflix is complete. */
@zholmquist
zholmquist / gist:2209206
Created March 26, 2012 19:56
canOpenURL - check if phone has apps installed.
/*
canOpenURL
Clear App ( http://www.realmacsoftware.com/clear/ ) checks if app exsits,
then unlocks a theme based on that app. In Clear, they check if you have
Tweetbot.
Example Usage:
BOOL hasTweetbotInstalled = [self checkIfPhoneCanOpenAppUrlScheme:@"tweetbot://"];
@zholmquist
zholmquist / gist:5685618
Last active December 17, 2015 22:59
Quick Gif Search with Alfred App v2 + Giphy
# Paste URL into your browser of choice.
# Note, this only works with single words due to the way Giphy does searches.
alfred://customsearch/Gif%20tagged%20%27%7Bquery%7D%27/gif/utf8/noplus/http://giphy.com/tags/{query}