Skip to content

Instantly share code, notes, and snippets.

View pastelInc's full-sized avatar
🍵
tea time

Kenichiro Okada pastelInc

🍵
tea time
View GitHub Profile
String.prototype.number_format = function(d) {
const absValue = Math.abs(d)
let c = isNaN(absValue) ? 2 : d;
let n = this;
let s = n < 0 ? "-" : "";
const i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
return s + (j ? i.substr(0, j) + ',' : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + ',') + (c ? '.' + Math.abs(n - i).toFixed(c).slice(2) : "");
}
@pastelInc
pastelInc / Retry.elm
Created March 7, 2019 01:12
Http.Retry
module Http.Retry exposing (Config, send, sendWith)
import Http
import Process
import Task exposing (Task)
import Time
type alias Config =
{ retries : Int
@pastelInc
pastelInc / Validator.elm
Last active June 25, 2018 15:13
I wanted to abstract Int and String and validate it by combining validation with function composition.
module Validator
exposing
( ValidatableInput
, gte
, int
, lte
, mixAlpha
, mixLowercase
, mixNumeric
, mixSpecial