Skip to content

Instantly share code, notes, and snippets.

View dhruv9499's full-sized avatar
🏠
Working from home

Dhruv Barot dhruv9499

🏠
Working from home
View GitHub Profile
@dhruv9499
dhruv9499 / automatic_invoice.gs
Created June 4, 2023 14:16 — forked from automagictv/automatic_invoice.gs
Apps Script code to automatically replace template variables in your invoice document.
///////////////////////////////////////////////////////////////////////////////////////////////
// BEGIN EDITS ////////////////////////////////////////////////////////////////////////////////
const TEMPLATE_FILE_ID = 'YOUR_TEMPLATE_FILE_ID_HERE';
const DESTINATION_FOLDER_ID = 'YOUR_DESTINATION_FOLDER_ID_HERE';
const CURRENCY_SIGN = '$';
// END EDITS //////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
// WARNING: EDITING ANYTHING BELOW THIS LINE WILL CHANGE THE BEHAVIOR OF THE SCRIPT. //////////
@dhruv9499
dhruv9499 / usereducer-gist.tsc
Created August 9, 2021 09:43
React Typescript Use Reducer gist example
const initialState = { count: 0 };
type ACTIONTYPE =
| { type: "increment"; payload: number }
| { type: "decrement"; payload: string };
function reducer(state: typeof initialState, action: ACTIONTYPE) {
switch (action.type) {
case "increment":
return { count: state.count + action.payload };
import React from "react";
export function createCtx<StateType, ActionType>(
reducer: React.Reducer<StateType, ActionType>,
initialState: StateType
) {
const defaultDispatch: React.Dispatch<ActionType> = () => initialState; // we never actually use this
const ctx = React.createContext({
state: initialState,
dispatch: defaultDispatch, // just to mock out the dispatch type and make it not optioanl
@dhruv9499
dhruv9499 / node_nginx_ssl.md
Created November 18, 2020 12:30 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user