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
/** | |
* Fancy ID generator that creates 20-character string identifiers with the following properties: | |
* | |
* 1. They're based on timestamp so that they sort *after* any existing ids. | |
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs. | |
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly). | |
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the | |
* latter ones will sort after the former ones. We do this by using the previous random bits | |
* but "incrementing" them by 1 (only in the case of a timestamp collision). | |
*/ |
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
/*! | |
* Replace some functionality of jQuery's $.extend() method | |
* with only native JavaScript. Unlike $.extend(), this | |
* function will ONLY merge plain objects (not arrays). | |
* https://gist.github.com/Error601/9a181a0b9f414b752c38 | |
*/ | |
function isObject( obj ){ | |
return Object.prototype.toString.call(obj) === '[object Object]'; |
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
/*! | |
* Hipster filler text generator. | |
* Inspired by (and words taken from): | |
* http://hipsum.co/ | |
* | |
* Usage: | |
* | |
* // sentences only | |
* APP.utils.hipster.sentence(); // generates 1 sentence with 9, 12, or 18 words | |
* APP.utils.hipster.sentences(3); // generates 3 sentences |
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/bash | |
# file path example | |
FILE=/home/user/src.dir/prog.c | |
echo ${FILE#/*/} # ==> user/src.dir/prog.c -- remove everything BEFORE the SECOND '/' | |
echo ${FILE##*/} # ==> prog.c -- remove part BEFORE LAST '/' | |
echo ${FILE%/*} # ==> /home/user/src.dir -- remove everything AFTER the LAST '/' | |
echo ${FILE%%/*} # ==> nil -- remove everything AFTER the FIRST '/' (returns empty string) | |
echo ${FILE%.c} # ==> /home/user/src.dir/prog -- remove everything AFTER '.c' |