Skip to content

Instantly share code, notes, and snippets.

View dixitk13's full-sized avatar
> Java > Javascript > ...

Dixit Keshavbhai Patel dixitk13

> Java > Javascript > ...
View GitHub Profile
au FileType gitcommit setlocal tw=72
{
"files.autoSave": "onFocusChange",
"editor.formatOnSave": true,
"workbench.activityBar.visible": false,
"editor.quickSuggestions": {
"other": false,
"comments": false,
"strings": false,
},
"window.openFoldersInNewWindow": "on",
package leet.unionfind;
import java.util.*;
public class EvaluateDivision {
public double[] calcEquation(List<List<String>> equations,
double[] values, List<List<String>> queries) {
// <node, parent of the node>
Map<String, String> parent = new HashMap<>();
import React, { Fragment, useState, useEffect } from 'react'
const Timer = ({ minutes, classNames }) => {
if (!minutes) return null
const [seconds, setSeconds] = useState(minutes * 60)
useEffect(() => {
let timeout = setInterval(() => {
setSeconds(seconds - 1)
@dixitk13
dixitk13 / .bash_profile
Created March 6, 2019 14:22
bash_profile
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
if [ -f "$(brew --prefix)/opt/bash-git-prompt/share/gitprompt.sh" ]; then
__GIT_PROMPT_DIR=$(brew --prefix)/opt/bash-git-prompt/share
GIT_PROMPT_ONLY_IN_REPO=1
source "$(brew --prefix)/opt/bash-git-prompt/share/gitprompt.sh"
fi
@dixitk13
dixitk13 / .gitconfig
Last active May 15, 2020 08:54
helpful git aliases
[alias]
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
myrebase = !git add -A && git commit --amend --no-edit
mycommit = "!git add -A && git commit -m "
myrank = "shortlog -n -s --no-merges"
pullm = "pull origin master"
[color]
branch = auto
diff = auto
status = auto
function makeAPIRequest(url, timeout = 2000, headers) {
// Some code to fetch data
console.log('url ', url)
console.log('timeout ', timeout)
console.log('headers ', headers)
}
makeAPIRequest("/api", undefined, {"head": "ers"})
// url /api
/*
ref: https://scotch.io/@devGson/understanding-iterators-and-iterables-in-javascript
*/
let obj = {
start : 1,
end : 5
};
//for..of initially calls this method
// 1. constructor invocation pattern
// uses the new operator to create instance
function Person(name, gender) {
this.name = name;
this.gender = gender;
};
const adam = new Person('Adam', 'male');
console.log(adam); // Person { name: 'Adam', gender: 'male' }
function Foo(y) {
this.x = 10;
this.y = y;
this.calculate = function(z) {
// console.log(this); // prints the Foo instance
return this.x + this.y + z;
}
}
let fooIns = new Foo(20)