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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
/* | |
# Usage in html template: | |
"xxx | nl2br" | |
<div ng-bind-html=" YourString | nl2br "></div> | |
or: |
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 | |
# oops need to first install http://packages.debian.org/sid/i386/libmozjs2d/download | |
# then http://packages.debian.org/sid/i386/libmozjs-dev/download | |
# init | |
mkdir nodejs-couchdb | |
cd nodejs-couchdb | |
# nodejs |
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
// Truncate a string to the closest word | |
String.prototype.truncateToWord = function(len) { | |
return (len = Number(len)) >= 0 ? | |
this.match(new RegExp('^([\\s\\S]{0,' + len + '})(:?\\s|$)'))[1] : | |
undefined; | |
}; | |
// Examples | |
// The "v" marks the first character out of bounds. |