Skip to content

Instantly share code, notes, and snippets.

// 25_403 -> 25.4B
// 255_113 -> 255.1B
// 2_013 -> 2B
// 1_350_413 -> 1.4M
// 1_000 -> 1B
// 999 -> 999
func FormatNumbers(number float64) string {
unit := ""
num := number
@alpmusti
alpmusti / number_formatter.go
Last active November 24, 2022 06:10
Convert integers to thousand separated strings
import (
"fmt"
"strconv"
)
// 6543 -> 6.543 (dot separator)
// 10000 -> 10.000
func FormatNum(num int, separator string) string {
if num <= 1000 || separator == "" {
return strconv.Itoa(num)
@alpmusti
alpmusti / api.service.ts
Created January 17, 2021 11:26
A networking layer that includes refresh token mechanism using axios for angular project
import { Injectable } from "@angular/core";
import { environment } from "../../../environments/environment";
import axios, { AxiosInstance } from 'axios';
interface JSONResponse<T> {
success: boolean,
data?: T
error?: any
};
<div class="item html">
<h2>{{i}}</h2>
<svg width="160" height="160" xmlns="http://www.w3.org/2000/svg">
<g>
<title>Layer 1</title>
<circle id="circle" [ngStyle]="{'stroke-dashoffset': strokeDashOffset, 'stroke': strokeColor}" class="circle_animation" r="69.85699" cy="81" cx="81" stroke-width="8" fill="none"/>
</g>
</svg>
</div>
.item {
position: relative;
float: left;
}
.item h2 {
text-align: center;
position: absolute;
line-height: 125px;
width: 100%;
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'circle-countdown',
templateUrl: './circle-countdown.component.html',
styleUrls: [ './circle-countdown.component.css' ],
})
export class CircleCountdownComponent implements OnInit {
@Input() time: number;
@Input() strokeColor: string;
/*
After you have changed the settings at "Your code goes here",
run this with one of these options:
"grunt" alone creates a new, completed images directory
"grunt clean" removes the images directory
"grunt responsive_images" re-processes images without removing the old ones
*/
module.exports = function(grunt) {