Skip to content

Instantly share code, notes, and snippets.

View udayvunnam's full-sized avatar
🤡
What the Fun with JS

Uday Vunnam udayvunnam

🤡
What the Fun with JS
View GitHub Profile
@udayvunnam
udayvunnam / handling_multiple_github_accounts.md
Created May 13, 2023 04:48 — forked from Jonalogy/handling_multiple_github_accounts.md
Handling Multiple Github Accounts on MacOS

Handling Multiple Github Accounts on MacOS

The only way I've succeeded so far is to employ SSH.

Assuming you are new to this like me, first I'd like to share with you that your Mac has a SSH config file in a .ssh directory. The config file is where you draw relations of your SSH keys to each GitHub (or Bitbucket) account, and all your SSH keys generated are saved into .ssh directory by default. You can navigate to it by running cd ~/.ssh within your terminal, open the config file with any editor, and it should look something like this:

Host *
 AddKeysToAgent yes

> UseKeyChain yes

@udayvunnam
udayvunnam / ensure-cert-macos.sh
Created November 28, 2021 01:40 — forked from koop/ensure-cert-macos.sh
Ensures a certificate is in the macOS system keychain.
#!/bin/bash
# Usage
# $ ./install-cert-macos.sh "/path/to/cert"
CERT_PATH="$1"
# First, grab the SHA-1 from the provided SSL cert.
CERT_SHA1=$(openssl x509 -in "$CERT_PATH" -sha1 -noout -fingerprint | cut -d "=" -f2 | sed "s/://g")
# Next, grab the SHA-1s of any standard.dev certs in the keychain.
# Don't return an error code if nothing is found.
@udayvunnam
udayvunnam / memoize.js
Last active July 2, 2019 09:04
Memoization to increase performance and cache function execution
function memoize(fn) {
const cache = {};
return function (...args) {
if (cache[args]) {
return cache[args];
}
const result = fn.apply(this, args);
cache[args] = result;
@udayvunnam
udayvunnam / fibonacci-series.js
Created April 4, 2019 15:27
fibonacci series till provided index
function fibonacci(range){
if(range <2){
return range;
}
return fibonacci(range-1) + fibonacci(range-2);
}
@udayvunnam
udayvunnam / lru-usage.js
Last active June 6, 2021 06:11
LRU cache usage in Javascript
const lruCache = new LRU(3);
lruCache.write('a', 123);
lruCache.write('b', 456);
lruCache.write('c', 789); // lru is 'a'
lruCache.read('a'); // lru is 'b'
// Now max limit 3 is reached. Let's add a new element
lruCache.write('d', 0); // lru 'b' is removed
console.log(lruCache);
@udayvunnam
udayvunnam / lru.js
Last active June 6, 2021 06:10
Least Recently Used cache - Implementing LRU cache in Javascript
class Node {
constructor(key, value, next = null, prev = null) {
this.key = key;
this.value = value;
this.next = next;
this.prev = prev;
}
}
class LRU {