Skip to content

Instantly share code, notes, and snippets.

View kensnyder's full-sized avatar

Ken Snyder kensnyder

View GitHub Profile
/*
# Usage in html template:
"xxx | nl2br"
<div ng-bind-html=" YourString | nl2br "></div>
or:
@kensnyder
kensnyder / 0_reuse_code.js
Created November 12, 2015 16:33
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#! /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
// 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.