Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠

GP paambaati

🏠
View GitHub Profile
@paambaati
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
paambaati / README.md
Last active Nov 24, 2021
Generate yarn resolutions for audit-ci fixes
View README.md

How to use this

node auditResolutions.js

This will print some output that looks like this –

{"css-select@npm:2.1.0/nth-check":">=2.0.1"}
@paambaati
paambaati / upload_demo_html.html
Last active Mar 28, 2021
Uploading files using NodeJS and Express 4
View upload_demo_html.html
<html>
<body>
<form action="/upload" enctype="multipart/form-data" method="post">
<input type="text" name="title">
<input type="file" name="file">
<input type="submit" value="Upload">
</form>
</body>
</html>
@paambaati
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') {
Router.push('/login');
}
};
@paambaati
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 (
<Controller
View node-liftbridge-grpc-trace.txt
GRPC_VERBOSITY=DEBUG GRPC_TRACE=all yarn run debug
yarn run v1.17.3
$ ts-node src/debug.ts
D0908 08:17:51.870543000 4400821696 dns_resolver.cc:294] Using native dns resolver
I0908 08:17:51.870996000 4400821696 timer_manager.cc:85] Spawn timer thread
I0908 08:17:51.871014000 4400821696 init.cc:163] grpc_init(void)
I0908 08:17:51.871060000 123145562341376 timer_manager.cc:246] timers not checked: expect another thread to
I0908 08:17:51.871069000 123145562341376 timer_manager.cc:194] sleep until kicked
I0908 08:17:51.871329000 4400821696 completion_queue.cc:504] 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
paambaati / marathon_migrate.py
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.
View marathon_migrate.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
from os import environ
from json import load, loads, dumps
from urlparse import urlparse
try:
from urllib.request import urlopen, Request
from urllib.error import HTTPError
@paambaati
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 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#toJSON()_behavior
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
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: https://github.com/cyrus-and/chrome-remote-interface
// Definitions by: GP <https://github.com/paambaati>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = CDP;
declare function CDP(options?: CDP.ChromeRemoteInterfaceOptions): CDP.CDP;
declare namespace CDP {