Skip to content

Instantly share code, notes, and snippets.

View CliffCrerar's full-sized avatar
😎
There is a time to code, and a time to code.

C1I7F05D-C53545 CliffCrerar

😎
There is a time to code, and a time to code.
View GitHub Profile
@CliffCrerar
CliffCrerar / reflection.ts
Last active February 9, 2024 06:49
Demonstrating reflection in typescript
// reflection in typescript
const fida = {
fName: 'Fida',
lName: 'Haq',
age: 28
}
class ReflectionClass {
[property: string]: string | number
@CliffCrerar
CliffCrerar / template-logger.pipe.ts
Created November 8, 2023 07:44
Angular pipe used to log values for inspection and debug purposes in an angular template
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'templateLogger',
})
export class TemplateLoggerPipe implements PipeTransform {
transform(value: any) {
console.log('TEMPLATE LOGGER: ', value)
}
@CliffCrerar
CliffCrerar / guid-util.ts
Created October 25, 2023 08:29
Guid type
export class Guid {
public static validator = new RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$", "i");
public static EMPTY = "00000000-0000-0000-0000-000000000000";
public static isGuid(guid: any) {
const value: string = guid.toString();
return guid && (guid instanceof Guid || Guid.validator.test(value));
}
@CliffCrerar
CliffCrerar / backend-fetch.js
Created August 10, 2023 12:28
writing your own fetch function using node.js http
const https = require('https')
async function fetch(url) {
return new Promise((resolve, reject) => {
const request = https.get(url, { timeout: 1000 }, (res) => {
if (res.statusCode < 200 || res.statusCode > 299) {
return reject(new Error(`HTTP status code ${res.statusCode}`))
}
const body = []
{
"hours": [
{
"airTemperature": {
"noaa": 26.61
},
"time": "2023-06-06T00: 00: 00+00: 00"
},
{
"airTemperature": {
@CliffCrerar
CliffCrerar / install-linux-desktop.sh
Created June 4, 2023 14:41
Install WSL with desktop GUI
# Requires WSL2 on windows
# Required windows config
# ---------------------------------
## in powershell run
# wsl --set-default-version 2
## to set wsl 2 as default
# ---------------------------------
## Then run
# wsl -l -v
@CliffCrerar
CliffCrerar / deletetablesforschema.sql
Last active April 19, 2023 14:03
Delete tables in a schema
-- 1. INTRODUCTION
/*
This script drops all fk constraints and tables from a configured scema.
*/
/*---------------------------*/
/* 2. CONFIGURATION */
/*---------------------------*/
declare @schema varchar(52) = 'dbo';
@CliffCrerar
CliffCrerar / url-tracking.service.ts
Created June 24, 2022 16:50
Angular URL tracking service
import {Injectable} from '@angular/core';
import {NavigationEnd, Router, RouterEvent} from "@angular/router";
import {filter} from "rxjs/operators";
import {Subscription} from "rxjs";
@Injectable({
providedIn: 'root'
})
export class TrackUrlHistoryService {
/* PROPERTIES */
@CliffCrerar
CliffCrerar / callbacks-demo.json
Created June 23, 2022 15:36
callbacks-demo.json
{
"data": [
{
"Name":"Kobus",
"Age": 340,
"Company":["Infinity Arc"]
},
{
"Name": "Cliff",
"Age":903,
@CliffCrerar
CliffCrerar / CountryCodes.json
Created October 3, 2021 14:01 — forked from anubhavshrimal/CountryCodes.json
Country and Dial or Phone codes in JSON format
[
{
"name": "Afghanistan",
"dial_code": "+93",
"code": "AF"
},
{
"name": "Aland Islands",
"dial_code": "+358",
"code": "AX"