Skip to content

Instantly share code, notes, and snippets.

View hshoff's full-sized avatar
📊

Harrison Shoff hshoff

📊
View GitHub Profile
@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:2004073
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)
@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)
@hshoff
hshoff / gist:2003812
Created March 8, 2012 22: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)
@hshoff
hshoff / gist:2002656
Created March 8, 2012 18:50
Neat Backbone.View initialization
class Component extends Backbone.View
initialize: ->
for func, args of @options
if @[func]?
if _.isArray(args)
@[func].apply?(@, args)
else
@[func].call?(@, args)
return null
@hshoff
hshoff / init.coffee
Created February 21, 2012 07:51
A nice way to initialize
class Component extends Backbone.View
initialize: ->
for func, args of @options
unless _.isArray(args)
@[func]?.call(@, args)
else
@[func]?.apply(@, args)
return null
@hshoff
hshoff / init.coffee
Created February 21, 2012 07:35
Nice way to initialize Backbone.Views
Backbone.Component extends Backbone.View
initialize: ->
for func, args of @options
unless _.isArray(args)
@[func]?.call(@, args)
else
@[func]?.apply(@, args)
render: =>