Skip to content

Instantly share code, notes, and snippets.

View khpatel4991's full-sized avatar
😄

Kashyap Patel khpatel4991

😄
View GitHub Profile
OS=`echo \`uname\` | tr '[:upper:]' '[:lower:]'`
AURL="https://gist.githubusercontent.com/hightemp/5071909/raw/"
ANAME=".bash_aliases"
TMPAPATH="/tmp/$ANAME"
HOMEAPATH="~/$ANAME"
[ "$OS" = "windowsnt" ] && OS_WIN="yes"
[ "$OS" = "darwin" ] && OS_MAC="yes"
[ "$OS" = "linux" ] && OS_LIN="yes"
@khpatel4991
khpatel4991 / माहेश्वराणि सूत्राणि.txt
Created September 26, 2022 03:49
संस्कृतम् अक्षरा:
अइउण्
ऋऌक्
एओङ्
ऐऔच्
हयवरट्
लण्
ञमङणनम्
झभञ्
घढधष्
जबगडदश्
@khpatel4991
khpatel4991 / prettyPrintProgress.ts
Last active July 1, 2019 23:22
Inline progress bar
import * as readline from 'readline'
import { performance } from 'perf_hooks';
const delay = <T>(ms: number, returnValue: T = undefined): Promise<T> =>
new Promise(resolve => setTimeout(() => resolve(returnValue), ms));
const showPercentage = (percentage: string) => {
readline.cursorTo(process.stdout, 0, null);
let text = `working ... ${percentage}%`
@khpatel4991
khpatel4991 / getDescendants.js
Last active July 10, 2019 23:15
Dom traversal
function overlayEl(rect) {
const el = document.createElement('div');
el.style.backgroundColor = 'rgba(255, 0, 0, 0.5)';
el.style.position = 'absolute';
el.style.transform = `translate(${rect.left}px, ${rect.top}px)`;
el.style.left = `${window.pageXOffset}px`;
el.style.top = `${window.pageYOffset}px`;
el.style.width = `${rect.width}px`;
el.style.height = `${rect.height}px`;
return el;
@khpatel4991
khpatel4991 / transducers.ts
Created May 29, 2019 05:48
Sample Execution of Transducers
const ELEMENTS = 1000000;
const add10 = (a: number) => a + 10;
const isEven = (a: number) => a % 2 === 0;
const getInitial = (): number[] => [];
const combine = (acc: number[], elem: number) => (acc.push(elem), acc);
const compose = (...fns: Function[]) => (x: number) => fns.reduceRight<number>((acc, fn) => fn(acc), x);
const ip = Array.from(Array(ELEMENTS), (_, i) => i);
@khpatel4991
khpatel4991 / cs.json
Last active March 14, 2019 11:42
D3.json
{
"name": "flare",
"children": [
{
"name": "analytics",
"children": [
{
"name": "cluster",
"children": [
{"name": "AgglomerativeCluster", "value": 3938},
def is_prime(num)
i = 2
while(i <= Math.sqrt(num))
return false if num % i === 0
i = i + 1
end
true
end
def print_table(num)
const prices = [10, 7, 5, 12, 1, 89];
const initialState = {
maxProfit: 0,
bestBuyPrice: prices[0],
};
const bestProfit$ = Rx
.Observable
.from(prices)
@khpatel4991
khpatel4991 / cloudSettings
Last active August 14, 2018 15:18
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-08-14T15:18:49.176Z","extensionVersion":"v3.0.0"}
@khpatel4991
khpatel4991 / max_profit.rb
Created February 17, 2017 15:34
Max Profit Indices from array of stock prices
class Profit
attr_accessor :bp, :sp, :bp_index, :sp_index
def initialize(bp_index=-1, bp=0, sp_index=-1, sp=0)
@bp_index = bp_index || -1
@bp = bp || 0
@sp_index = sp_index || -1
@sp = sp || 0
end