Skip to content

Instantly share code, notes, and snippets.

Working from home

Ganapati V S ganapativs

Working from home
View GitHub Profile
ganapativs / xstate - react signup.jsx
Last active Jun 14, 2021
Signup state machine using xstate
View xstate - react signup.jsx
import React, { useState } from "react";
import { Machine, assign } from "xstate";
import { useMachine } from "@xstate/react";
const signupUser = email =>
new Promise((resolve, reject) => {
setTimeout(() => {
// resolve("You are signed up!");
reject("Unable to sign you up :(");
}, 1000);
View workbox-4.3.1-notes.js
/* globals importScripts, workbox */
if (workbox) {
console.log(`Yay! Workbox is loaded 🎉`);
} else {
# generate a new pgp key: (better to use gpg2 instead of gpg)
gpg --gen-key
# maybe you need some random work in your OS to generate a key. so run this command: `find ./* /home/username -type d | xargs grep some_random_string > /dev/null`
# check current keys:
gpg --list-secret-keys --keyid-format LONG
# export private key in gpg:
gpg --export-secret-key -a "your_username"
ganapativs / 1.js
Created Sep 15, 2018 — forked from getify/1.js
tag function for formatting console.log(..) statements
View 1.js
function logger(strings,...values) {
var str = "";
for (let i = 0; i < strings.length; i++) {
if (i > 0) {
if (values[i-1] && typeof values[i-1] == "object") {
if (values[i-1] instanceof Error) {
if (values[i-1].stack) {
str += values[i-1].stack;

Time Travel Debugging

Time Travel refers to the ability to record a tab and later replay it ([WebReplay][wrr]). The technology is useful for local development, where you might want to:

  • pause and step forwards or backwards
  • pause and rewind to a prior state
  • rewind to the time a console message was logged
  • rewind to the time an element had a certain style or layout
  • rewind to the time a network asset loaded
ganapativs / iTerm2 + oh-my-zsh + Pure theme + zsh plugins
Last active Nov 24, 2021
iTerm2 + oh-my-zsh + Pure theme + zsh plugins setup
View iTerm2 + oh-my-zsh + Pure theme + zsh plugins
ganapativs /
Created Jul 5, 2018
MacOS - Install Node, NPM and Yarn
git clone n --depth=1
cd n
make install
cd ..
rm -rf n
n latest
npm install --global yarn
ganapativs /
Created Feb 12, 2018 — forked from paulirish/
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.


Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
# ----------------------
# Git Aliases
# ----------------------
alias ga='git add'
alias gaa='git add .'
alias gaaa='git add --all'
alias gau='git add --update'
alias gb='git branch'
alias gbd='git branch --delete '
alias gc='git commit'
ganapativs / ip.js
Created Jun 28, 2017 — forked from sviatco/ip.js
Get local external ip address with nodejs
View ip.js
// Local ip address that we're trying to calculate
// Provides a few basic operating-system related utility functions (built-in)
,os = require('os')
// Network interfaces
,ifaces = os.networkInterfaces();
// Iterate over interfaces ...