Skip to content

Instantly share code, notes, and snippets.


GP paambaati

View GitHub Profile
paambaati / launch.js
Last active May 5, 2022
Debug mocha tests using Visual Studio Code
View launch.js
"version": "0.1.0",
// List of configurations. Add new configurations or edit existing ones.
// ONLY "node" and "mono" are supported, change "type" to switch.
"configurations": [
// Name of configuration; appears in the launch configuration drop down menu.
"name": "Run app.js",
// Type of configuration. Possible values: "node", "mono".
"type": "node",
paambaati /
Last active Nov 24, 2021
Generate yarn resolutions for audit-ci fixes

How to use this

node auditResolutions.js

This will print some output that looks like this –

paambaati / upload_demo_html.html
Last active Mar 28, 2021
Uploading files using NodeJS and Express 4
View upload_demo_html.html
<form action="/upload" enctype="multipart/form-data" method="post">
<input type="text" name="title">
<input type="file" name="file">
<input type="submit" value="Upload">
paambaati / localstorage_logout_sync.tsx
Last active Jun 3, 2020
Logging out of all tabs when logout occurs on 1 tab
View localstorage_logout_sync.tsx
// Your main component.
const MyComponentWrapper = (props) => {
// Watch changes to local storage, and if we logout in 1 tab,
// logout in every other tab.
const syncLogout = (event: StorageEvent): void => {
if (event.key === 'logout') {
paambaati / select.tsx
Created Apr 12, 2020
react-select + react-hook-form
View select.tsx
import { forwardRef } from 'react';
import Select from 'react-select';
import { Controller } from 'react-hook-form';
import type { RefObject } from 'react';
import type { Props as ReactSelectProps } from 'react-select';
const Select = forwardRef(
(props: SelectProps, ref: RefObject<HTMLSelectElement>) => {
return (
View node-liftbridge-grpc-trace.txt
yarn run v1.17.3
$ ts-node src/debug.ts
D0908 08:17:51.870543000 4400821696] Using native dns resolver
I0908 08:17:51.870996000 4400821696] Spawn timer thread
I0908 08:17:51.871014000 4400821696] grpc_init(void)
I0908 08:17:51.871060000 123145562341376] timers not checked: expect another thread to
I0908 08:17:51.871069000 123145562341376] sleep until kicked
I0908 08:17:51.871329000 4400821696] grpc_completion_queue_create_internal(completion_type=0, polling_type=0)
View usa.geo.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
paambaati /
Last active Feb 20, 2019
Handy script to help migrate all Mesos Marathon apps from 1 cluster to another. Can use either a Marathon URI or a local file location for both source & destination sinks. Works on both Python2 & Python3.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
from os import environ
from json import load, loads, dumps
from urlparse import urlparse
from urllib.request import urlopen, Request
from urllib.error import HTTPError
paambaati / map2json.js
Last active Jan 16, 2019
JSON stringifier that handles ES6 Maps
View map2json.js
// Optional: If any dependency is overriding Map's toJSON function,
// you might want to reset it.
// Why? See
delete Map.prototype.toJSON;
function customStringifier(key, value) {
if (value instanceof Map) {
// Convert Maps to JSON objects.
let obj = Object.create(null);
for (let [k, v] of value) {
paambaati / index.d.ts
Created Jan 7, 2019
Type definitions for chrome-remote-interface
View index.d.ts
// Type definitions for chrome-remote-interface 0.26.1
// Project:
// Definitions by: GP <>
// Definitions:
export = CDP;
declare function CDP(options?: CDP.ChromeRemoteInterfaceOptions): CDP.CDP;
declare namespace CDP {