Skip to content

Instantly share code, notes, and snippets.

View hshoff's full-sized avatar
📊

Harrison Shoff hshoff

📊
View GitHub Profile
!function(){}(); // => true
~function(){}(); // => -1
+function(){}(); // => NaN
-function(){}(); // => NaN
// Crockford's preference - parens on the inside
(function() {
console.log('Welcome to the Internet. Please follow me.');
}());
(function() {
console.log('Welcome to the Internet. Please follow me.');
})();
@hshoff
hshoff / danger.js
Created October 17, 2012 20:13
Client Side Exception Logger
// Demo:
// -----------------------------------
// Copy & Paste into the console.
// Optional
// run test() => true
// run test(1) => Error
// newTest = wrap(test, {
// name: 'test',
// filename: '/js/danger.js'
// })
var sum = new Function('a', 'b', 'return a + b');
@hshoff
hshoff / wutang.js
Created May 10, 2012 08:02
JS function length property
var a,b,c,d;
(function(a,b,c,d){}).length // => 4
a = function(b,c,d){};
a.length // => 3
@hshoff
hshoff / gist:2364506
Created April 12, 2012 03:55
Grove.io shift arrow channel change
// shift+up and shift+down to move between channels
//
// copy and paste into the console
// or if you're using Fluid.app put
// in Userscripts
$(document).bind('keydown', function(e){
var shifted = e.shiftKey;
if (e.keyCode == 40 && shifted) {
@hshoff
hshoff / grove-ui.js
Created April 11, 2012 17:29 — forked from reissbaker/grove-ui.js
Grove UI improvements
!function($) {
App.on('messageAdded', function() {
var $pic, $picLI, index, $prevLI, $prevPic,
$picSeparator, $picContent,
$pics = $('.userpic img'),
SPACING = '3px';
for(index = $pics.length - 1; index >= 0; index--) {
$pic = $($pics[index]);
$picLI = $pic.closest('li');
if (typeof (AC) === "undefined") {
AC = {}
}
AC.ImageReplacer = Class.create({
_defaultOptions: {
listenToSwapView: true,
filenameRegex: /(.*)(\.[a-z]{3}($|#.*|\?.*))/i,
filenameInsert: "_☃x",
ignoreCheck: /(^http:\/\/movies\.apple\.com\/|\/105\/|\/global\/elements\/quicktime\/|_(([2-9]|[1-9][0-9]+)x|nohires)(\.[a-z]{3})($|#.*|\?.*))/i,
attribute: "data-hires",
@hshoff
hshoff / gist:2004072
Created March 8, 2012 23:17
Extended Example
class Component extends Backbone.View
defaults:
'visible': true
initialize: ->
# defaults gets overriden by @config, which is overridden
# by the passed in options on initialization. So @config
# acts as @defaults for something that extends Component
@options = _.extend({}, @defaults, @config, @options)