Skip to content

Instantly share code, notes, and snippets.

View PranjalAgni's full-sized avatar
💭
24y/o Software Developer ✨ Node, React, GraphQL, Algorithms=💘

beingPranjal PranjalAgni

💭
24y/o Software Developer ✨ Node, React, GraphQL, Algorithms=💘
View GitHub Profile
@PranjalAgni
PranjalAgni / fs.js
Created January 13, 2024 18:44
Playing around Node fs to read bytes and filling it into Buffer for some processing
const fs = require("node:fs");
const fsp = require("node:fs/promises");
const os = require("node:os");
function readInPosition(filename, start, end) {
const readStream = fs.createReadStream(filename, {
start,
end,
});
@PranjalAgni
PranjalAgni / kth-permutation.cpp
Created June 9, 2021 15:07
Finding Kth permutation of string directly using maths
#include <bits/stdc++.h>
using namespace std;
unordered_map<int, int> hashMap;
// assumes 0 based indexing
char getElementByPos(vector<char> alpha, int eltPos) {
int currPos = 0;
for (int idx = 0; idx < alpha.size(); idx++) {
if (hashMap[idx]) continue;
@PranjalAgni
PranjalAgni / pre-commit
Created February 16, 2021 12:20
Alternative shell script to husky works with Windows | Linux | MacOS
#!/bin/sh
RED="\033[1;31m"
GREEN="\033[1;32m"
NC="\033[0m"
linter_exit_code=1
staged_js_files=$(git diff --cached --diff-filter=d --name-only | grep .js$)
./node_modules/.bin/eslint $staged_js_files --quiet --fix
linter_exit_code=$?
git add -f $staged_js_files
if [ $linter_exit_code -ne 0 ]
@PranjalAgni
PranjalAgni / docker-compose.yml
Created January 23, 2021 17:30
Basic docker-compose config for nodejs + postgres
version: "3.7"
services:
postgres:
image: postgres
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- '5432:5432'
volumes:
@PranjalAgni
PranjalAgni / .eslintrc
Last active April 17, 2021 17:17
Setting up NodeJS + Typescript project
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "prettier"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"rules": {
@PranjalAgni
PranjalAgni / cloudSettings
Last active March 21, 2021 16:12
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-03-21T16:12:13.717Z","extensionVersion":"v3.4.3"}
@PranjalAgni
PranjalAgni / .bashrc
Created May 24, 2020 06:07
My bash configuration file
# Path to your oh-my-bash installation.
export OSH=/home/pranjal/.oh-my-bash
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-bash is loaded.
OSH_THEME="standard"
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
@PranjalAgni
PranjalAgni / SpaceshipTravel.java
Last active March 23, 2020 15:36
SpaceshipTravel Graph DFS problem
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.StringTokenizer;
class SpaceshipTravel {
static class Graph {
@PranjalAgni
PranjalAgni / .hyper.default.js
Last active February 12, 2020 19:19
Hyper terminal default settings
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
@PranjalAgni
PranjalAgni / settings.json
Created February 10, 2020 09:34
Personal VS Code user settings
{
"editor.snippetSuggestions": "top",
"workbench.iconTheme": "vscode-icons",
"editor.multiCursorModifier": "ctrlCmd",
"files.autoSave": "onFocusChange",
"editor.tabSize": 2,
"editor.fontSize": 18,
"editor.fontFamily": "Anonymous Pro",
"editor.formatOnPaste": false,
"editor.minimap.enabled": false,