Skip to content

Instantly share code, notes, and snippets.

View basyusuf's full-sized avatar
Focusing

Yusuf Baş basyusuf

Focusing
  • Turkey
View GitHub Profile
@basyusuf
basyusuf / good_singleton.ts
Created March 10, 2021 22:42
Good Singleton
class Redis {
private static instance: Redis;
private id: number;
private base_url: string;
private port: number;
private constructor(base_url: string, port: number = 6379) {
this.base_url = base_url;
this.port = port;
this.id = new Date().getTime();
}
@basyusuf
basyusuf / custom_validator.ts
Created March 15, 2021 21:56
Custom validator with decarator
enum ValidationTypes {
'required' = 'required',
'positive' = 'positive',
'number' = 'number'
}
interface ValidatorConfig {
[property: string]: {
[validatableProp: string]: string[];
}
@basyusuf
basyusuf / tr_plate_regex.js
Created May 3, 2021 13:34
Turkey Plate Number Regex [JS][TS]
let plates = ["41K1111","41k1111","41 K 1111","41K 1111","41 YB 443","41 YBA 443","41 k 4141"];
let regexFormule = /^(0[1-9]|[1-7][0-9]|8[01])((\s?[a-zA-Z]\s?)(\d{4,5})|(\s?[a-zA-Z]{2}\s?)(\d{3,4})|(\s?[a-zA-Z]{3}\s?)(\d{2,3}))$/
plates.map((item)=>{
let checkRegex = item.match(regexFormule);
if(checkRegex){
console.info("Success");
}
});