Skip to content

Instantly share code, notes, and snippets.

View sanishkr's full-sized avatar
🍹
always high

Sanish sanishkr

🍹
always high
View GitHub Profile
import React, { Component } from "react";
import VideoPlayer from "./VideoPlayer";
class App extends Component {
constructor(props) {
super(props);
this.createVisualization = this.createVisualization.bind(this);
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
if(!Array.prototype.filter){
Array.prototype.filter = (fn) => {
let res = []
let length = this.length
for(let i=0; i < length; i++) {
if(fn(this[i])) {
res.push(this[i])
}
}
return res;
const throttle = (fn, delay) => {
let lastRan;
let timerId;
return function() {
const ctx = this;
const args = arguments;
if(!lastRan){
fn.apply(ctx, args)
lastRan = Date.now();
} else {
const debounced = (fn, delay) => {
let timerId = null;
return function() {
const args = arguments;
const ctx = this;
console.log("Trying....")
clearTimeout(timerId)
timerId = setTimeout(() => {
fn.apply(ctx, args)
}, delay)
// Main Memoize function
const memo = fn => {
const cache = {}
return function () {
const key = JSON.stringify(arguments);
if(key in cache){
return cache[key]
} else {
cache[key] = fn.apply(this, arguments);
return cache[key]
const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]
function getRandomInt(max) {
return Math.floor(Math.random() * Math.floor(max));
}
console.log("Initial Array", arr);
for(let i = (arr.length - 1); i > 0; i--){
const randI = getRandomInt(i);
@sanishkr
sanishkr / Image.js
Last active January 19, 2021 08:41
import React from 'react';
import ProgressiveImage from 'react-progressive-graceful-image';
import styled from 'styled-components';
const PlcHolder = styled.img`
background: linear-gradient(
to right,
rgb(246, 247, 248) 0%,
rgb(237, 238, 241) 20%,
rgb(246, 247, 248) 40%,
@sanishkr
sanishkr / cloudSettings
Last active November 17, 2020 10:07
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-11-17T10:07:07.220Z","extensionVersion":"v3.4.3"}