This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Something = function(arg){ | |
| console.log(['something:', arg]); | |
| }; | |
| var Weird = function(fn){ | |
| this.Something = function(arg){ | |
| console.log(['something weird:', arg]); | |
| }; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // basic usage: | |
| $('myParentElement').relayEvents({ | |
| 'a.menuitem':{ | |
| 'click': function(e){} | |
| }, | |
| 'input[name=phone]':{ | |
| 'keydown': function(e){}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function $mergeAdd(){ | |
| var mix = {}; | |
| var obs = Array.flatten(arguments); | |
| for (var i = 0, l = obs.length; i < l; i++){ | |
| var object = obs[i]; | |
| if ($type(object) != 'object') continue; | |
| for (var key in object){ | |
| var object_prop = object[key], mp = mix[key]; | |
| if(!object_prop && $type(object_prop)!='number') continue; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function formatCurrency(num){ | |
| num = (num||'0').toString().replace(/\$|\,/g,''); | |
| if(isNaN(num)) num = "0"; | |
| if(num+0 == 0) return '$0'; | |
| var sign = (num == (num = Math.abs(num))); | |
| num = Math.floor(num*100+0.50000000001); | |
| var cents = num%100; | |
| num = Math.floor(num/100).toString(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // TODO: Remove this once it's added to MooTools code | |
| Element.implement({ | |
| toFormHash: function(){ | |
| var formHash = $H(); | |
| this.getElements('input, select, textarea', true).each(function(el){ | |
| if (!el.name || el.disabled) return; | |
| var value = (el.tagName.toLowerCase() == 'select') ? Element.getSelected(el).map(function(opt){ | |
| return opt.value; | |
| }) : ((el.type == 'radio' || el.type == 'checkbox') && !el.checked) ? null : el.value; | |
| $splat(value).each(function(val){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function pp(object){ | |
| switch ($type(object)){ | |
| case 'object': | |
| object = $H(object); | |
| var h = '{ '; | |
| object.each(function(value, key){ | |
| h += '{key}: {value}, '.substitute({key:key, value: pp(value) }) | |
| }) | |
| h += ' }' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| mkdir -p ~/Library/KeyBindings | |
| mv ~/Desktop/DefaultKeyBinding.dict ~/Library/KeyBindings/DefaultKeyBinding.dict #*/ | |
| { | |
| /* Modifier keys: start with C-m */ | |
| "^m" = { | |
| "^ " = ("insertText:", "\U2423"); /* C-space space */ | |
| "^e" = ("insertText:", "\U21A9"); /* C-e return */ | |
| "e" = ("insertText:", "\U2305"); /* e enter */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Class.Mutators.Logs=function(self,methods){ | |
| $splat(methods).each(function(methodName){ | |
| var method = self[methodName]; | |
| self[methodName]=function(){ | |
| try{ console.log(Array.flatten([methodName, arguments]).join(',')); }catch(e){}; | |
| return method(arguments); | |
| }; | |
| }); | |
| return self; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (?x-m)^ | |
| # Yes *+ Open ( Blank |Comments | (No Paren | String) | String | (Nested Parens ) )*+ | |
| (?> \g<yesS>*+ \[ (?<yesS> (?!.) |//.*+|/\*((?!\*/).)++(\*/|$)|(^)((?!/\*).)*(\*/)| (?<noS>[^\[\]''"/]) | (?<str> ''(\\''|[^''])*+'' | "(\\"|[^"])*+" | /(\\/|[^/])*+/) | (?<squar> \[ \g<yesS>*+ \] ) )*+ | |
| | \g<yesR>*+ \( (?<yesR> (?!.) |//.*+|/\*((?!\*/).)++(\*/|$)|(^)((?!/\*).)*(\*/)| (?<noR>[^\(\)''"/]) | \g<str> | (?<round> \( \g<yesR>*+ \) ) )*+ | |
| | \g<yesC>*+ \{ (?<yesC> (?!.) |//.*+|/\*((?!\*/).)++(\*/|$)|(^)((?!/\*).)*(\*/)| (?<noC>[^\{\}''"/]) | \g<str> | (?<curly> \{ \g<yesC>*+ \} ) )*+ | |
| )$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # | |
| # This hook does two things: | |
| # | |
| # 1. update the "info" files that allow the list of references to be | |
| # queries over dumb transports such as http | |
| # | |
| # 2. if this repository looks like it is a non-bare repository, and | |
| # the checked-out branch is pushed to, then update the working copy. | |
| # This makes "push" function somewhat similarly to darcs and bzr. |