Skip to content

Instantly share code, notes, and snippets.

View anushshukla's full-sized avatar
💭
Silently and secretly building awesome applications

Anush Shukla anushshukla

💭
Silently and secretly building awesome applications
View GitHub Profile
@anushshukla
anushshukla / hacker-rank-aws-count-family-login-pairs.ts
Last active July 26, 2022 04:09
Count family login pairs (AWS SDE Assessment Coding Challenge)
function countFamilyLoginsPairs(logins) {
// Write your code here
let familyLoginPairsCount = 0;
const cachedResults = {};
logins.map((login, currentLoginIndex) => {
const possibleLoginPairs = ['', ''];
cachedResults[login] = 0;
if (cachedResults[login]) {
cachedResults[login] += 1;
familyLoginPairsCount++;
@anushshukla
anushshukla / pm2-process-start-reload.sh
Created April 3, 2022 22:25
PM2 process smart start / reload
declare -a processNames=(
"test"
"test2"
"test3"
"test4"
)
## now loop through the above array
for processName in "${processNames[@]}"
do
@anushshukla
anushshukla / process-managers.md
Last active February 22, 2022 03:37
Process managers

What is a process manager? 💻

Basically, a process itself to manage the application processes like cluster, restart / reload the process without downtime, smart restart etc.

Why do we need process managers?

A process managers helps us to scale the application and make the application available which prevents downtime of the application.

What are important features of a process managers?

@anushshukla
anushshukla / .gitconfig
Last active September 25, 2023 19:39
GIT guidelines, global ignore, config, etc. files
[core]
autocrlf = input
whitespace = cr-at-eol
excludesfile = ~/.gitignore
fileMode = false
editor = code
[user]
name = <Name Here>
email = <Email Here>
[color]
@anushshukla
anushshukla / race-condition-problem-stmt-solution.md
Created October 18, 2021 14:28
Race Condition Problem Statement with Solution

Q: What is a race condition?

A: This is the condition which arises when there is race between multiple requests from client to server try to modify or fetch the same resource in the same time of execution

Q: When does race condition arise?

A: When a system is multi-threaded or/and multi-process to handle concurrency or/and parallelism for performance optimisation.

Q: How can race conditions be avoided?

  • cached session management
  • backward compatibility with legacy system
  • inter microservice communication authorisation
  • safe & secured project (audited project dependencies and scrutinised API)
  • maintainable & scalable project (modular codebase and organised DB)
  • config driven authentication (protocols, token structure and design patterns)
@anushshukla
anushshukla / fetch-aws-s3-archived-logs-date-wise.sh
Created April 28, 2021 06:26
Fetch AWS S3 Archived (Date wise) Logs
#!/bin/bash
AWS_S3_LS='s3://<BUCKET-NAME>/<PATH-TO-THE-LOGS>'
SYS_DAY=$(date '+%d')
SYS_MONTH=$(date '+%m')
SYS_YEAR=$(date '+%Y')
DEFAULT_TIME_AFTER="00:00:00"
DEFAULT_TIME_BEFORE="23:59:59"
SORT_DATE=true
LOG_TYPE='out'
@anushshukla
anushshukla / find-highest-buyer-list-store-wise.py
Created April 28, 2021 06:23
Python Quiz -> Fetch Highest Buyer List Store Wise
import sys
def getCleanEntry(line):
entry = line.strip('\n').split(',')
return entry
def getPurchaseDetails(entry):
storeName = entry[1].strip()
customerName = entry[0].strip()
amount = int(entry[4].strip().replace("Rs ", ""))
@anushshukla
anushshukla / i18n.md
Created April 28, 2021 03:31
Internationalisation Guidelines

Table Schema -> User Preferences

  • UserPreferenceId
  • UserId
  • UserPreferredCurrency
  • UserPreferredLanguage
  • UserPreferredTimezone
  • UserPreferredDateFormat
  • UserPreferredTimeFormat
  • UserPreferredNumberFormat