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 / eight-queens-attack-check.js
Last active March 23, 2026 03:33
Eight Queens Attack Check
const getParsedQueenPosition = queenPosition => queenPosition.replace('(', '').replace(')', '').split(',');
const getDiagnolAttackPositions = ({ position: queenPosition, rowIncrement, colIncrement }) => {
const diagnolAttackPositions = {}
const position = getParsedQueenPosition(queenPosition);
const reviseRowPosition = currPosition => parseInt(currPosition) + (rowIncrement ? 1 : -1)
const reviseColPosition = currPosition => parseInt(currPosition) + (colIncrement ? 1 : -1)
let nextRowPosition = reviseRowPosition(position[0]);
let nextColPosition = reviseColPosition(position[1]);
isValidPosition = (rowPosition, colPosition) => {
@anushshukla
anushshukla / math-expression-str-evaluate.js
Created January 12, 2021 11:04
Mathematical Expression String Evaluation
const calculate = (num1, operator, num2) => {
switch (operator) {
case '+': return num1 + num2;
case '-': return num1 - num2;
case '*': return num1 * num2;
case '/': return num1 / num2;
}
}
const isOperator = str => ['+','-', '*', '/'].includes(str);
@anushshukla
anushshukla / regex-count-age-json-string.js
Created January 13, 2021 09:05
JSON string response find count of age > 50
const https = require('https');
const callback = response => {
let str = '';
response.on('data', function (chunk) {
str += chunk;
});
response.on('end', function () {
@anushshukla
anushshukla / time-convert.js
Created January 26, 2021 05:43
Conver minutes into hours and minutes
const TimeConvert = num => `${Math.floor(num/60)}:${num%60}`;
@anushshukla
anushshukla / LRU-cache.ts
Last active March 1, 2023 19:56
LRU Cache with pre-defined size having O(1) complexity for all operations
interface HashItem {
value: string
next: null | string
}
interface Hash {
[key: string]: HashItem
}
interface ListConfig {
package main
import (
"testing"
)
const bookCost int = 8
type purchasedBooksStruct struct {
potterBooksList map[string]int
@anushshukla
anushshukla / code-defects-prevention.md
Created April 6, 2021 21:56
How to avoid code defects
  • TDD
  • Branch merge allowed via pull requests only
  • Before branch merge: Linter check
  • Before branch merge: Prettier check
  • Before branch merge: Code Quality check
  • Before branch merge: Test Coverage Check of Dev Unit Test + QA functional / integrated test automation
  • Working code demo evidence
  • Before branch merge: Code Review
  • Before branch merge: Code Approval from concerned Product / Engineering Managers / QA
@anushshukla
anushshukla / vowel-charac-encoding-fix.md
Last active March 23, 2026 03:33
Vowels character encoding issue fixing (charset)
  • DataBase > Table > Character Set > utf-8
  • DataBase > Table > Collation > utf8_general_ci
  • Response Headers > Content Type > application/json; charset=utf-8
  • [Frontend] Website Application > HTML > charset meta tag > utf-8 => <meta charset="utf-8">
  • Database > Table > Column > Correct value
  • SQL file > Execution > --default-character-set=utf8

DB Charset & Collation Check

@anushshukla
anushshukla / aws-s3-update-objects-acl.js
Last active April 22, 2021 17:42
AWS > S3 > Objects > Update > ACL
import AWS from 'aws-sdk';
import fs from 'fs';
const makeObjectsPrivate = () => {
console.log('====================');
const data = JSON.parse(fs.readFileSync('data.json', 'utf8'));
console.log('data', data);
const {
accessKeyId,
secretAccessKey,