Skip to content

Instantly share code, notes, and snippets.

Working from home

Tom jsdevtom

Working from home
View GitHub Profile
jsdevtom / PaypalWebhookVerifierExample.cs
Last active Aug 4, 2022
The solution to getting Paypal's verify endpoint to work was to serialize JSON manually like so:
View PaypalWebhookVerifierExample.cs
using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
jsdevtom / recursify-onto.type.ts
Last active Aug 30, 2019
Recursifies an object on to another object in Typescript
View recursify-onto.type.ts
* T: The normal object to apply O to at every nested object
* @example
export const OBJECT_ID = Symbol('_objectId');
export interface IHasOBJECT_ID {
jsdevtom / deep-equals.ts
Created May 18, 2019
fast deep equals in TypeScript
View deep-equals.ts
const isArray = Array.isArray;
const keyList = Object.keys;
const hasProp = Object.prototype.hasOwnProperty;
export function isDeeplyEqual<T extends any>(a: T, b: T): boolean {
if (a === b) { return true; }
if (a && b && typeof a === 'object' && typeof b === 'object') {
const arrA = isArray(a)
jsdevtom / frontend-ws-connection.ts
Last active Jul 1, 2022
kubernetes-ingress websockets with nodejs
View frontend-ws-connection.ts
export const ws = webSocket<WebsocketMessage>(`wss://${location.hostname}:${location.protocol === 'https:' ? 443 : 80}/ws/`);
export const wsObserver = ws
retryWhen(errors =>
jsdevtom /
Last active Feb 6, 2021
Angular 2 4 5 6 +: Find out if FormControl has required validator with Angular Material example.

Although this pipe is impure, it uses a "Blazing fast" hash in order to check if the AbstractControl has changed at all before calculating whether or not the AbstractControl has a required field.

You will need to install hash-sum like so:

npm i -S hash-sum

jsdevtom / index.ts
Created Jul 29, 2018
Connect to MongoDB from Google Cloud function best practice through Maintaining Persistent Connections
View index.ts
import {CustomError} from "./error/custom-error.interface";
import {RequestHandler} from 'express';
import {MongoClient} from 'mongodb';
let client: MongoClient;
const connectToClientIfDropped: () => Promise<void> = async () => {
if (client && client.isConnected()) {
jsdevtom / upper-case-node-transform.js
Last active Apr 16, 2018
A simple implementation of a node.js transformer class in ES6.
View upper-case-node-transform.js
const {Transform} = require('stream')
class UpperCase extends Transform {
_transform (chunk, encoding, done) {
done(null, chunk.toString().toUpperCase())
module.exports = UpperCase
jsdevtom / app-routing.animation.ts
Last active Mar 13, 2022
Fade out angular 2 loading page/ Fade in first angular 2 component
View app-routing.animation.ts
import {
} from '@angular/animations';
import { AnimationEntryMetadata } from "@angular/core";