Skip to content

Instantly share code, notes, and snippets.

View sushant-at-nitor's full-sized avatar
🖖
Focusing µS

Sushant Kulkarni sushant-at-nitor

🖖
Focusing µS
View GitHub Profile
import React from "react";
import {
SafeAreaProvider,
Metrics,
initialWindowMetrics as defaultInitialWindowMetrics,
} from "react-native-safe-area-context";
import { theme as defaultTheme, ITheme } from "native-base/src/theme";
import type { IColorModeProviderProps } from "native-base/src/core/color-mode";
import HybridProvider from "native-base/src/core/hybrid-overlay/HybridProvider";
import { OverlayProvider } from "@react-native-aria/overlays";
@sushant-at-nitor
sushant-at-nitor / failed-queue.js
Created August 25, 2022 10:24
failed-queue.js
/**
* 1. Create a state management / centralized store
* 2. Create a generic service which will be used by all the reducers / slices of the state management
* 3. On service call failures, add the payload and action to the reprocess queue
* 4. Create an EvenStream which would listen to the failure events receiving from the base service
* 5. Send the event as telemetry to the server - either retry sending to the same endpoint / send to common log collector service
* 6. After notifying remove the even from the stream
*/
const apiEvent = {
@sushant-at-nitor
sushant-at-nitor / mongo-aggregate.js
Created August 24, 2022 03:36
MongoDB / Mongo aggregate example - mapReduce, aggregate query
db.getCollection('routes').aggregate([
{
$match: {city: 'Pune', transport: 'subway'}
},
{
$project: {emit: {key: {city: '$city', transport: '$transport'}, features: '$featureCollection.features'}}
},
{
$group: {
_id: "$emit.key",
@sushant-at-nitor
sushant-at-nitor / example.js
Last active August 19, 2022 14:19
tsv-to-json, tsv2json, tsvtojson in javascript / typescript, nodejs, node
const tsv = `
@PageTotal:120 @PageNow:1 @Num:599 @NumReturn:5
ID Name Image Countries Domains CommissionRate Category
39 Mothercare http://my-rewards.com/img/adv_logo/id-12639481.png "in" "mothercare.in" 4.41%~10.00% "Children","Costumes","Green & Eco","Menswear","Womenswear","Fashion","Activewear","Lingerie","Men","Women","Other","Shopping"
168 Droom http://my-rewards.com/img/adv_logo/in-867168490.jpeg "in" "droom.in" other "Travel","Travel"
169 IGP.com http://my-rewards.com/img/adv_logo/igp.png "global" "indiangiftsportal.com" 4.55% "Travel","Transportation"
211 Acer http://my-rewards.com/img/adv_logo/us-220211666.png "in" "store.acer.com" 2.45%~3.00% "Accessories","Computers","Computers","Hardware","Electronics"
865 Domino's Pizza http://my-rewards.com/img/adv_logo/us-535865648.jpeg "in" "pizzaonline.dominos.co.in","m.dominos.co.in" INR20.00 "Food & Drink","Restaurant","Gourmet","Food & Drink"
`;
@sushant-at-nitor
sushant-at-nitor / watchman-wsl.sh
Created January 17, 2022 04:10
install watchman on WSL Ubuntu distro
# install watchman on WSL Ubuntu distro
sudo apt-get install -y autoconf automake build-essential python2-dev pkg-config libtool
cd ~
git clone https://github.com/facebook/watchman.git -b v4.9.0 --depth 1
cd watchman
./autogen.sh
./configure --enable-lenient
make
REM List the running distros
wsl --list -v
REM Shutdown all distros
wsl --shutdown
REM create a directory on a different drive (not necessary) to move the data
mkdir e:\system\docker\wsl-{distro}\
REM export the distro data to tar
interface Tree {
[index: string]: number | Tree;
}
const getUniqueSortedNumbers = (tree: Tree, items: number[] = []): number[] => {
Object.keys(tree).map((key: string) =>
typeof tree[key] === 'object'
? getUniqueSortedNumbers(tree[key] as Tree, items)
: items.indexOf(tree[key] as number) <= 0 && items.push(tree[key] as number)
@sushant-at-nitor
sushant-at-nitor / windows-terminal-settings.json
Created September 10, 2020 04:31
My Windows Terminal Config
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}",
"copyOnSelect": false,
"copyFormatting": false,
"alwaysShowTabs": true,
"profiles": {
"defaults": {
"colorScheme": "UbuntuLegit",
"backgroundImage": "C:\\Users\\<default-user>\\Pictures\\<picture-file>.jpg",
@sushant-at-nitor
sushant-at-nitor / android-wsl-setup.sh
Created April 1, 2020 14:27 — forked from jjvillavicencio/setup.sh
Install Android SDK on Windows Bash (WSL)
cd /home/<user>/
sudo apt-get install unzip
wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
unzip sdk-tools-linux-4333796.zip -d Android
rm sdk-tools-linux-4333796.zip
sudo apt-get install -y lib32z1 openjdk-8-jdk
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$PATH:$JAVA_HOME/bin
printf "\n\nexport JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64\nexport PATH=\$PATH:\$JAVA_HOME/bin" >> ~/.bashrc
cd Android/tools/bin
@sushant-at-nitor
sushant-at-nitor / get-install-packages.sh
Created January 15, 2020 15:16
List VSCode and Chocolaty packages to install later
## get list of vscode packages, which you can use to install later
code --list-extensions | % { "code --install-extension $_" }
## get list of choco packages, which you can use to install later
choco list --local-only | % { $_.split(' ')[0] } | % { "choco install -y $_" }