Skip to content

Instantly share code, notes, and snippets.

George Mauer togakangaroo

Block or report user

Report or block togakangaroo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@togakangaroo
togakangaroo / gist:1664107
Created Jan 23, 2012
Methods of Removing Redundant Code
View gist:1664107

Common methods of removing redundant code scored by

  • Ease of Implementation (lower is more difficult)
  • Dont Repeat Yourself (lower involves more repetition and therefore more prone to bugs)
  • Loose Coupling (lower involves higher degrees of coupling and therefore more prone to bugs)
Ease DRY Loose Coupling Refactoring Method
5 1 5 Copy paste
4 4 2 Extract static method
@togakangaroo
togakangaroo / gist:1676930
Created Jan 25, 2012
Javascript functions returning functions - when you're being an asshole
View gist:1676930
cell.draggable({
helper: "clone",
start: function() { _.each(self.selection(), function(s){ s.cell.addClass('dragged')}) },
stop: function() { _.each(self.selection(), function(s){ s.cell.removeClass('dragged')}) }
});
// Looks good but I can clean that up!
var applyDrag = function(op){
return function() { _.each(self.selection(), function(s){ s.cell[op+'Class']('dragged')}) }
@togakangaroo
togakangaroo / gist:1761525
Created Feb 7, 2012
Javascript hashmap vs. if vs. case
View gist:1761525
//console.time implementation for IE
if (window.console && typeof (window.console.time) == "undefined") {
console.time = function (name, reset) {
if (!name) {
return;
}
var time = new Date().getTime();
if (!console.timeCounters) {
console.timeCounters = {}
};
View underscorify_boookmarklet.js
javascript: (function(){var el=document.createElement('div'),b=document.getElementsByTagName('body')[0];otherlib=false,msg='';el.style.position='fixed';el.style.height='32px';el.style.width='220px';el.style.marginLeft='-110px';el.style.top='0';el.style.left='50%';el.style.padding='5px 10px';el.style.zIndex=1001;el.style.fontSize='12px';el.style.color='#222';el.style.backgroundColor='#f99';if(typeof _ !='undefined'){msg='This page already using Underscore v'+_.VERSION;return showMsg();} function getScript(url,success){var script=document.createElement('script');script.src=url;var head=document.getElementsByTagName('head')[0],done=false;script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=='loaded'||this.readyState=='complete')){done=true;success();script.onload=script.onreadystatechange=null;head.removeChild(script);}};head.appendChild(script);} getScript('http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js',function(){if(typeof _ =='undefined'
@togakangaroo
togakangaroo / tiny-flow-control.coffee
Created Jun 22, 2012
I guess its my turn to write a flow control library
View tiny-flow-control.coffee
###
My tiny little flow control library.
Usage:
$.Deferred.invoke func, context, ...args
func - Function with its two final parameters being onSuccess and onError
context - context to bind to 'this' when func is invoked
args - flat list of arguments
Returns:
jQuery Deferred object
View dabblet.css
ul, li {
margin: 0;
padding: 0;
}
View dabblet.css
ul, li {
margin: 0;
padding: 0;
}
View dabblet.css
ul, li {
margin: 0;
padding: 10px;
list-style: none;
}
@togakangaroo
togakangaroo / gist:3133127
Created Jul 18, 2012
A very simple pretty checkbox plugin
View gist:3133127
$.widget 'someApp.prettyCheckbox',
_create: ->
if not @element.is ':checkbox'
return console.error "Expect widget to be called on a checkbox element", this, this.element
@wrapper = $('<div class=prettyCheckbox-wrapper>')
.css(position: 'relative', display: 'inline-block')
@element
.css(padding: 0, border: 0, opacity: 0, position: 'absolute', left: 0, top: 0)
@prettyBox = $('<div class=prettyCheckbox>')
@togakangaroo
togakangaroo / gist:3318552
Created Aug 10, 2012
My Powershell $profile
View gist:3318552
New-PSDrive HOST -PSProvider FileSystem -Root \\VBOXSVR\georgemauer
$tempDir = ([system.io.path]::GetTempPath())
function edit
{
param( [Parameter(ValueFromPipeline=$true,Position=0)] $file )
begin { set-alias EDITOR 'W:\tools\sublime_text.bat' }
process { EDITOR $file }
}
function Coalesce-Args {
You can’t perform that action at this time.