Skip to content

Instantly share code, notes, and snippets.

View Kinjalrk2k's full-sized avatar
🥱
Bored? Code!

Kinjal Raykarmakar Kinjalrk2k

🥱
Bored? Code!
View GitHub Profile
@Kinjalrk2k
Kinjalrk2k / generate.js
Created January 23, 2022 10:06
JsDoc to Markdown with folder structure
const jsdoc2md = require("jsdoc-to-markdown");
const fs = require("fs");
const path = require("path");
// const dirs = fs.readdirSync(path.resolve("."));
// console.log(dirs);
const glob = require("glob");
glob("**/*.js", { ignore: "node_modules/*/**" }, async (err, files) => {
@Kinjalrk2k
Kinjalrk2k / README.md
Last active September 6, 2021 09:55
My Powershell Oh-my-Posh custom theme

Powershell Customization

image

Installation

Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser
@Kinjalrk2k
Kinjalrk2k / flatToNestedObject.js
Last active May 28, 2021 12:41
Convert a Flat Object to a nested Object in JavaScript
const flatToNestedObject = (obj) => {
let nestedObj = {};
for (let key in obj) {
const value = obj[key];
if (key.indexOf(".") >= 0) {
const nestedKeys = key.split(".");
const parent = nestedKeys.shift();
const child = nestedKeys.join(".");
nestedObj[parent] = { ...nestedObj[parent] };
@Kinjalrk2k
Kinjalrk2k / cleanupMongooseSchema.js
Last active May 28, 2021 11:52
Cleanup a Mongoose Model to a simple object
const cleanupMongooseSchema = (schema) => {
let cleanSchema = {};
for (const field in schema.paths) {
const { path, instance, options } = schema.paths[field];
cleanSchema[path] = { type: instance };
if (schema.paths[field].hasOwnProperty("schema")) {
console.log(schema.paths[field].schema);
const nestedSchema = schema.paths[field].schema;
@Kinjalrk2k
Kinjalrk2k / displayCV2Jupyter.py
Created August 14, 2020 04:01
Display OpenCV Image(s) in Jupyter Notebook using Matplotlib
import math
import cv2
import matplotlib.pyplot as plt
def displayImage(img, title=None, size=(10, 10)):
plt.figure(figsize=size)
plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
plt.title(title)
plt.axis('off')
plt.show()
clc;
clear all;
close all;
a=[1 0 1 1 0 1]
l=length(a);
amp = input('Enter the amplitude of carrier: ')
fc = input('Enter the frequency of carrier: ')
@Kinjalrk2k
Kinjalrk2k / shattak_downloader.py
Created April 12, 2020 12:17
Download PDFs from Shattak at one go!
from bs4 import BeautifulSoup
import urllib
import re
html_page = urllib.request.urlopen("https://www.shattak.com/quordenet/subject?code=APT-101&name=tapas-sir")
soup = BeautifulSoup(html_page)
links = []
for link in soup.find_all('a', href=True):
links.append(link['href'])
@Kinjalrk2k
Kinjalrk2k / 1D parity.py
Last active January 26, 2020 05:12
1D Parity Checker - Includes manual manipulation of the data to illustrate error cases
# EVEN PARITY
import functools, random
# parity = functools.reduce(lambda a, b: a ^ b, list(map(int, list(str(bin(num))[2:]))))
# print(parity)
def parityGenerator(msg):
binary_li = list(map(int, list(msg)))
parity = functools.reduce(lambda a, b: a ^ b, binary_li)
return parity
#include <stdio.h>
#include <math.h>
#define ex 0.01
double foo(double x){
return pow(x,3) - x - 4;
}
double bisection(){
int n = 1, i;
@Kinjalrk2k
Kinjalrk2k / dyarr.c
Created December 13, 2019 18:03
Dynamic Array
#include <stdio.h>
#include <malloc.h>
int main(int argc, char const *argv[])
{
int n, *len_list, **twoD_arr, *oneD_arr;
printf("Enter n: ");
scanf("%d", &n);
len_list = (int *)calloc(n, sizeof(int));