Skip to content

Instantly share code, notes, and snippets.

View kshitijpurwar's full-sized avatar
🎯
Focusing

Kshitij Purwar (KP) kshitijpurwar

🎯
Focusing
View GitHub Profile
@kshitijpurwar
kshitijpurwar / class.js
Last active July 3, 2019 09:12
Fake Singleton with Node
class Dog {
constructor(name = "default") {
this.name = name;
console.log("My name is ", name);
}
}
module.exports = Dog;
// 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 17:51
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-05-19T17:51:26.031Z","extensionVersion":"v3.2.9"}
@kshitijpurwar
kshitijpurwar / matchingAlgo.js
Last active September 5, 2018 05:14
Faster and simpler solution to the problem mentioned in the hackernoon article
// 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++){
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 June 14, 2017 09:10
Timer with 1 second increment, play, pause and reset.
// Just shows the time, taking app state time as input prop
const Timer = function(props) {
return (
<h1>
{props.time}
</h1>
);
};
@kshitijpurwar
kshitijpurwar / DigitalBitCounter.js
Last active June 14, 2017 08:11
Bit counter 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{