Skip to content

Instantly share code, notes, and snippets.

View niklas-r's full-sized avatar
:shipit:
Shipping code, all day, `err` day

Niklas Kahn niklas-r

:shipit:
Shipping code, all day, `err` day
  • Neat Minds
  • Sweden, Stockholm
View GitHub Profile
@niklas-r
niklas-r / roundFloats.js
Last active August 29, 2015 13:59
Round list of floats to list of integers. The sum of the integers will be the same as the floats combined and then rounded.
function roundFloats(listOfFloats) {
var tempArr,
arraySum,
lowerSum,
largestFraction,
i;
// lowerSum will be the sum of all floats Math.floored
lowerSum = 0;
@niklas-r
niklas-r / uid.js
Last active August 29, 2015 13:57
Generate a UID with an optional paramenter to set length. Thanks to http://stackoverflow.com/a/8809472
/**
* Generate a unique ID
*
* @param {Number} [len=15] - Optionally set a length of the generated string.
* Defaults to 15 characters, it's not recommended
* to go much lower than this in order to ensure
* uniqueness.
*
* @return {string} A unique ID.
*/
@niklas-r
niklas-r / .jshintrc.js
Last active August 29, 2015 13:56 — forked from connor/.jshintrc.js
{
// Settings
"passfail" : false, // Stop on first error.
"maxerr" : 100, // Maximum error before stopping.
// Predefined globals whom JSHint will ignore.
"browser" : true, // Standard browser globals e.g. `window`, `document`.
"node" : true,