Skip to content

Instantly share code, notes, and snippets.

Avatar
🌈
Stuck in Async Loop called Life!

Kshitij Purwar kshitijpurwar

🌈
Stuck in Async Loop called Life!
View GitHub Profile
@kshitijpurwar
kshitijpurwar / class.js
Last active Jul 3, 2019
Fake Singleton with Node
View class.js
class Dog {
constructor(name = "default") {
this.name = name;
console.log("My name is ", name);
}
}
module.exports = Dog;
View decorators.js
// This is the decorator function that times our functions
function timer(target, name, descriptor) {
console.log(target, name, descriptor);
let original = descriptor.value;
descriptor.value = function(...args){
console.time('timer');
var result = original.apply(this, args);
console.timeEnd('timer');
return result;
}
@kshitijpurwar
kshitijpurwar / cloudSettings
Created May 19, 2019
Visual Studio Code Settings Sync Gist
View cloudSettings
{"lastUpload":"2019-05-19T17:51:26.031Z","extensionVersion":"v3.2.9"}
@kshitijpurwar
kshitijpurwar / matchingAlgo.js
Last active Sep 5, 2018
Faster and simpler solution to the problem mentioned in the hackernoon article
View matchingAlgo.js
// https://hackernoon.com/how-to-lose-an-it-job-in-10-minutes-3d63213c8370
var city = "Tokyo";
var cities = ['Tokyo', 'London', 'Rome', 'Donlon', 'Kyoto', 'Paris'];
function getScore(s){
var s = s.toLowerCase();
var sum = 0;
for(var i = 0; i < s.length;i++){
View GithubFetch,js
const Card = function(props) {
return (
<div
style={{display: 'flex',
border: "1px solid #f0f0f0",
marginBottom: "10px" ,
alignItems: 'center'}}>
<img
width="150px"
src={props.imageURL} alt=""/>
@kshitijpurwar
kshitijpurwar / timer.js
Created Jun 14, 2017
Timer with 1 second increment, play, pause and reset.
View timer.js
// Just shows the time, taking app state time as input prop
const Timer = function(props) {
return (
<h1>
{props.time}
</h1>
);
};
View DigitalBitCounter.js
class Button extends React.Component{
state = { switch: 0 };
onClickHandle = () => {
if( this.state.switch === 1){
this.props.onclickFunction(-1 * this.props.changeValue);
this.setState({ switch : 0});
}
else{