Skip to content

Instantly share code, notes, and snippets.

Avatar

Ken Snyder kensnyder

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