Skip to content

Instantly share code, notes, and snippets.

View ivikash's full-sized avatar

Vikash Agrawal ivikash

View GitHub Profile
@ivikash
ivikash / BrowserConsole.ts
Created April 29, 2022 20:34
winston browser console
import { LogEntry } from "winston";
import TransportStream from "winston-transport";
export type LoggerMethodsKeys =
| "error"
| "warn"
| "info"
| "http"
| "verbose"
| "debug"
import { renderHook, act } from "@testing-library/react-hooks";
import { useDebounce } from "@ui/utils/hooks";
describe("useDebounce", () => {
beforeAll(() => {
jest.useFakeTimers();
});
afterEach(() => {
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'jimeh/tmux-themepack'
set -g @themepack 'powerline/double/cyan'
set -g base-index 1
setw -g pane-base-index 1
var flatten = arr =>
arr.reduce(
(acc, val) => acc.concat(Array.isArray(val) ? flatten(val) : val),
[],
);
var o = [];
var p = new Proxy(o, {
set(obj, id, value) {
@ivikash
ivikash / colortest.py
Created March 23, 2018 11:06 — forked from justinabrahms/colortest.py
Small utility to test terminal support for 256-color output.
#!/usr/bin/env python
# Ported to Python from http://www.vim.org/scripts/script.php?script_id=1349
print "Color indexes should be drawn in bold text of the same color."
print
colored = [0] + [0x5f + 40 * n for n in range(0, 5)]
colored_palette = [
"%02x/%02x/%02x" % (r, g, b)
for r in colored
/**
* Debounce is a technique of grouping multiple calls into single call
*
* @param {Function} fn function to be debounce
* @param {Number} delay time is seconds for which fn should be debounce
*/
function debounce(fn, delay = 100) {
let timeout;
@ivikash
ivikash / ClassicalInteritanceVSPrototypalInheritance.md
Created March 18, 2018 17:49
Difference b/w Classical Inheritance and Prototypal Inheritance in Javascript

Inheritance

Classical Inheritance

A class is like a blueprint, a description of objects to be created. Classes inherit from classes and create subclass relationships. Instantiation happens via new operator. The class keyword in Javascript is just a function

Class Foo{}
typeof Foo // 'function'
@ivikash
ivikash / ps4devtools.js
Created November 14, 2017 10:36 — forked from kdzwinel/ps4devtools.js
Gamepad - Chrome DevTools integration
(function(){
let gamepad = null;
let loopInterval = null;
window.addEventListener("gamepadconnected", connectHandler);
window.addEventListener("gamepaddisconnected", disconnectHandler);
function connectHandler(e) {
if (!gamepad) {
@ivikash
ivikash / ps4devtools.js
Created November 14, 2017 10:35 — forked from kdzwinel/ps4devtools.js
Gamepad - Chrome DevTools integration
(function(){
let gamepad = null;
let loopInterval = null;
window.addEventListener("gamepadconnected", connectHandler);
window.addEventListener("gamepaddisconnected", disconnectHandler);
function connectHandler(e) {
if (!gamepad) {
@ivikash
ivikash / unistore.js
Created October 24, 2017 13:59 — forked from developit/unistore.js
dead simple centralized state container ("store"), with preact bindings.
import { h, Component } from 'preact';
/** Creates a new store, which is a tiny evented state container.
* @example
* let store = createStore();
* store.subscribe( state => console.log(state) );
* store.setState({ a: 'b' }); // logs { a: 'b' }
* store.setState({ c: 'd' }); // logs { c: 'd' }
*/