This file contains 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
const ALL_HEX_COLORS_LIST: string[] = lodash.range(0, 16777216).map((n: number): string => lodash.padStart(n.toString(16), 6, '0')); |
This file contains 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
// based on https://gist.github.com/maggiben/9457434 | |
import { Pipe, PipeTransform } from '@angular/core'; | |
@Pipe({name: 'humanize'}) | |
export class Humanize implements PipeTransform { | |
transform(value: number): any { | |
let si: string[], exp: number, result: any; | |
if (value < 1000) { | |
return value; | |
} |
This file contains 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
angular.module('humanize', []).filter('humanize', function() { | |
return function humanize(number) { | |
var si, exp, result; | |
if (number < 1000) { | |
return number; | |
} | |
si = ['K', 'M', 'G', 'T', 'P', 'H']; | |
exp = Math.floor(Math.log(number) / Math.log(1000)); | |
result = number / Math.pow(1000, exp); | |
result = (result % 1 > (1 / Math.pow(1000, exp - 1))) ? result.toFixed(2) : result.toFixed(0); |
This file contains 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
(function () { | |
inputList = [0, 1, 2, 3, 4, 5, 6, 7, 8]; | |
ouputList = []; | |
makeRowsFromList = function makeRowsF(inputList, outputList, colsNum) { | |
var i, len; | |
outputList = outputList || []; | |
len = inputList.length; | |
for (i = 0; i < len; i += colsNum) { | |
outputList.push(inputList.slice(i, i + colsNum)); | |
} |
This file contains 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
#!/usr/bin/env python | |
""" | |
Convert camel-case to snake-case in python. | |
e.g.: CamelCase -> snake_case | |
e.g.: snake_case -> CamelCase | |
e.g.: CamelCase -> dash-case | |
e.g.: dash-case -> CamelCase | |
By: Jay Taylor [@jtaylor] | |
Me<modifier>: Yahya Kacem <[email protected]> | |
Original gist: https://gist.github.com/jaytaylor/3660565 |