Skip to content

Instantly share code, notes, and snippets.

View shifatul-i's full-sized avatar
🍒
Gitting

Shifatul Islam (Sif) shifatul-i

🍒
Gitting
View GitHub Profile
@shifatul-i
shifatul-i / date-ago.pipe.ts
Last active December 8, 2022 12:31
Angular — date ago pipe (minutes / hours / days / months / years ago)
import {Pipe, PipeTransform} from '@angular/core';
@Pipe({
name: 'dateAgo',
pure: true
})
export class DateAgoPipe implements PipeTransform {
transform(value: any, args?: any): any {
if (value) {
@shifatul-i
shifatul-i / short-number.pipe.ts
Last active May 14, 2024 17:00
Angular - short number suffix pipe 1K / 2M / 3B
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'shortNumber'
})
export class ShortNumberPipe implements PipeTransform {
transform(number: number, args?: any): any {
if (isNaN(number)) return null; // will only work value is a number
if (number === null) return null;
@shifatul-i
shifatul-i / short-domain.pipe.ts
Created October 8, 2018 21:03
Angular - short domain pipe (URL to domain - https://github.com/ThunderRoid → github.com)
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'shortDomain'
})
export class ShortDomainPipe implements PipeTransform {
transform(url: string, args?: any): any {
if (url) {
if (url.length > 3) {
@shifatul-i
shifatul-i / short-domain.pipe.ts
Created October 8, 2018 21:03
Angular - short domain pipe (URL to domain - https://github.com/ThunderRoid → github.com)
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'shortDomain'
})
export class ShortDomainPipe implements PipeTransform {
transform(url: string, args?: any): any {
if (url) {
if (url.length > 3) {
@shifatul-i
shifatul-i / short-url.pipe.ts
Created October 8, 2018 23:39
Angular - short URL pipe (Long URL to short URL - https://github.com…roid)
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'shortUrl'
})
export class ShortUrlPipe implements PipeTransform {
transform(url: string, args?: any): any {
if (url) {
const len = url.length;
print("Hello, World!")
x = 1
if x == 1:
# indented four spaces
print("x is 1.")
my_var = 7
print(my_var)
my_var = 7.0
print(my_var)
my_var = int(my_var) # casting
print('int again:', my_var)
my_var = 'hello'
a, b, c = 3, 4, 'Max'
print(a, b, c)
mylist = []
mylist.append(1)
mylist.append(2)
mylist.append(3)
print(mylist[0]) # prints 1
print(mylist[1]) # prints 2
print(mylist[2]) # prints 3
# prints out 1,2,3