Skip to content

Instantly share code, notes, and snippets.

View yahyaKacem's full-sized avatar

Yahya Kacem yahyaKacem

View GitHub Profile
@yahyaKacem
yahyaKacem / index.ts
Created December 9, 2017 14:34
list all hex colors with lodash
const ALL_HEX_COLORS_LIST: string[] = lodash.range(0, 16777216).map((n: number): string => lodash.padStart(n.toString(16), 6, '0'));
// 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;
}
@yahyaKacem
yahyaKacem / humanize.js
Last active June 14, 2016 01:06 — forked from maggiben/humanize.js
Human Readable Numbers (AngularJS filter)
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);
@yahyaKacem
yahyaKacem / make_rows_from_list.js
Last active August 29, 2015 14:04
make equal rows from a list
(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));
}
@yahyaKacem
yahyaKacem / string_converter.py
Created December 29, 2013 13:51
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
#!/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