Skip to content

Instantly share code, notes, and snippets.

View technikhil314's full-sized avatar

Nikhil Mehta technikhil314

View GitHub Profile
@technikhil314
technikhil314 / Readmd.MD
Last active April 24, 2024 17:13
Trick to use secondary gmail secondary account as default in PWA on desktop

Issue

  1. Open gmail.com
  2. switch to secondary accuont in gmail
  3. install a Gmail as PWA on desktop as a seperate window
    • make sure the PWA has secondaary account opened in PWA window
  4. Quit the PWA and open it again
  5. Obeserve that
    • the primary account is opened in PWA always no matter how many times you quit and reopen
    • also you cant switch the account in PWA to secondary account
    • if you try to switch to the secondary account then it is opened in browser and not in PWA
@technikhil314
technikhil314 / multiple_ssh_setting.md
Created April 12, 2024 06:46 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
[
{
"id": 342,
"first_name": "Imelda",
"last_name": "Seamark",
"email": "iseamark0@mozilla.org",
"gender": "Agender",
"ip_address": "239.185.36.189"
},
{
@technikhil314
technikhil314 / To Create Karaoke.sh
Created May 15, 2022 07:33
Useful ffmpeg and youtube downloading commands
// download some lytrical video from youtube using youtubelink
yt-dlp "someYoutubeLink" --extractor-args youtube:player_client=android --throttled-rate 100K -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best"
// merge downloaded youtube lyrical video with karaoke audio to create karaoke video trakc
ffmpeg -i someVideo.mp4 -i someAudio.mp3 -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 "Output Karaoke.mp4"
@technikhil314
technikhil314 / minimalHeaviestSetA.js
Created April 23, 2022 03:34
Amazon optimizing box weight
function minimalHeaviestSetA(arr) {
let result = [];
const sum = (arr) => arr.reduce((acc, curr) => acc + curr, 0);
const sortedArr = [...arr].sort((x, y) => x - y > 0 ? -1 : 1);
const n = sortedArr.length;
const target = sum(arr) / 2
for(let i = 0; i < n; i++) {
if(sum(result) > target) {
break
}
@technikhil314
technikhil314 / numberOfItems.js
Created April 23, 2022 02:42
Amazon number of items in container
function numberOfItems(s, startIndices, endIndices) {
// Write your code here
let result = [];
const countArr = {}
let count = 0
for(let i = s.indexOf("|"); i< s.length; i++) {
if(s[i] === "|") {
countArr[i] = count;
} else {
count++;
@technikhil314
technikhil314 / processLogs.js
Created April 22, 2022 16:37
Amazon transaction logs
function processLogs(logs, threshold) {
const n = logs.length;
let transactionCountMap = new Map()
for(let i=0;i<n;i++) {
const log = logs[i];
const [sender, recepient, amount] = log.split(" ");
transactionCountMap.set(sender, (transactionCountMap.get(sender) || 0) + 1)
if(sender !== recepient) {
transactionCountMap.set(recepient, (transactionCountMap.get(recepient) || 0) + 1)
}
@technikhil314
technikhil314 / index.js
Last active April 1, 2022 08:56
Benchmarking of lodash vs _.get
#! /usr/bin/env node
const _ = require('lodash');
const {
performance,
} = require('perf_hooks');
const isValidInput = process.argv[2] !== "" && !isNaN(Number(process.argv[2]));
const size = isValidInput ? Number(process.argv[2]) : 100000;
const arr = new Array(size).fill({
key: {
nestedKey: {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Debounce and throttle simplified</title>
<style>
html {