Skip to content

Instantly share code, notes, and snippets.

/^([a-z\d]([a-z\d\-]{0,61}[a-z\d])?\.)+[a-z]{2,}$/i
@monolithed
monolithed / composite_expr .sh
Last active December 17, 2015 22:39
composite expr
expr `ls -1 -- {32x32,45x45,90x90} | wc -l` / 3
# remove :: from file name
# bad version
for file in ::*;
do
mv $file `echo $file | sed -e 's/^:://'`;
done;
# bad version
for file in $(ls);
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 = [];
flags |= bit; // turn on
flags &= ~bit; // turn off
// 0.
'<script><\/script>' // deprecated
'<' + 'script>' + '<' + '/script>' // trash
// 1.
var script = document.createElement('script');
script.textContent = 'var foo = 1';
// 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];
var cursor_position = {
get: function(input) {
if (input === null)
return 0;
var position = 0;
if ('selectionStart' in input || input.selectionStart == 0) {
position = input.selectionStart;
}
# save file as root
:w !sudo tee %
Function.prototype.decorate = function(fn, context) {
return fn.bind(context || this, this);
};
var foo = function() {
return 1;
}
.decorate(function(callback) {
return '<a>' + callback() + '</a>';