Skip to content

Instantly share code, notes, and snippets.

View ganapativs's full-sized avatar
🎯
Focusing

Ganapati V S ganapativs

🎯
Focusing
View GitHub Profile
@ganapativs
ganapativs / xstate - react signup.jsx
Last active July 20, 2022 19:16
Signup state machine using xstate
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);
@ganapativs
ganapativs / workbox-4.3.1-notes.js
Created June 19, 2019 06:01
Workbox - 4.3.1 - Notes
/* globals importScripts, workbox */
// https://developers.google.com/web/fundamentals/primers/service-workers/
// https://developers.google.com/web/fundamentals/primers/service-workers/high-performance-loading
// https://developers.google.com/web/tools/workbox/modules/workbox-sw#using_workbox_sw_via_cdn
importScripts('https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js');
if (workbox) {
console.log(`Yay! Workbox is loaded 🎉`);
} else {
@ganapativs
ganapativs / git-auto-sign-commits.sh
Created October 19, 2018 11:34 — forked from mort3za/git-auto-sign-commits.sh
Auto sign your git commits
# 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
ganapativs / 1.js
Created September 15, 2018 08:30 — forked from getify/1.js
tag function for formatting console.log(..) statements
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;
continue;
}

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
ganapativs / iTerm2 + oh-my-zsh + Pure theme + zsh plugins setup.md
Last active November 15, 2024 18:18
iTerm2 + oh-my-zsh + Pure theme + zsh plugins setup
@ganapativs
ganapativs / install-node-npm-yarn.sh
Created July 5, 2018 11:25
MacOS - Install Node, NPM and Yarn
git clone https://github.com/tj/n.git n --depth=1
cd n
make install
cd ..
rm -rf n
n latest
npm install --global yarn
@ganapativs
ganapativs / what-forces-layout.md
Created February 12, 2018 09:19 — forked from paulirish/what-forces-layout.md
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.

Element

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
ganapativs / ip.js
Created June 28, 2017 08:30 — forked from szalishchuk/ip.js
Get local external ip address with nodejs
var
// Local ip address that we're trying to calculate
address
// Provides a few basic operating-system related utility functions (built-in)
,os = require('os')
// Network interfaces
,ifaces = os.networkInterfaces();
// Iterate over interfaces ...