This file contains 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
/^([a-z\d]([a-z\d\-]{0,61}[a-z\d])?\.)+[a-z]{2,}$/i |
This file contains 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
expr `ls -1 -- {32x32,45x45,90x90} | wc -l` / 3 |
This file contains 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
# remove :: from file name | |
# bad version | |
for file in ::*; | |
do | |
mv $file `echo $file | sed -e 's/^:://'`; | |
done; | |
# bad version | |
for file in $(ls); |
This file contains 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 getElementsByClassName = function(name) { | |
if(document.getElementsByClassName) | |
return document.getElementsByClassName(name); | |
else if(document.querySelectorAll) | |
return document.querySelectorAll('.' + name); | |
else { | |
var list = document.getElementsByTagName('*'), i = list.length, | |
array = name.split(/\s+/), result = []; |
This file contains 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
flags |= bit; // turn on | |
flags &= ~bit; // turn off |
This file contains 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
// 0. | |
'<script><\/script>' // deprecated | |
'<' + 'script>' + '<' + '/script>' // trash | |
// 1. | |
var script = document.createElement('script'); | |
script.textContent = 'var foo = 1'; |
This file contains 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
// LZW-compress a string | |
function lzw_encode(s) { | |
var dict = {}; | |
var data = (s + "").split(""); | |
var out = []; | |
var currChar; | |
var phrase = data[0]; | |
var code = 256; | |
for (var i=1; i<data.length; i++) { | |
currChar=data[i]; |
This file contains 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 cursor_position = { | |
get: function(input) { | |
if (input === null) | |
return 0; | |
var position = 0; | |
if ('selectionStart' in input || input.selectionStart == 0) { | |
position = input.selectionStart; | |
} |
This file contains 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
# save file as root | |
:w !sudo tee % |
This file contains 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.prototype.decorate = function(fn, context) { | |
return fn.bind(context || this, this); | |
}; | |
var foo = function() { | |
return 1; | |
} | |
.decorate(function(callback) { | |
return '<a>' + callback() + '</a>'; |