Skip to content

Instantly share code, notes, and snippets.

@vishaltelangre
vishaltelangre / recurrentlyBackupGoogleSpreadsheet.js
Last active April 12, 2023 13:00
Recurrently backup Google spreadsheets #backup #google #sheet #backupgooglesheet
// Instructions
//
// 1. Open the spreadsheet that you want to backup in Google Drive.
// 2. Go to Extensions -> Apps Script.
// 3. Copy and paste the code below into the editor. Change "Untitled" script name
// to something meaningful
// 4. Save and run the script. You will have to authorize access.
// 5. Go to the spreadsheet's parent folder in Google Drive.
// 6. Make sure that the backup folder and the year folder have been created.
// 7. Go to the year folder and make sure that the backup file has been created.
@vishaltelangre
vishaltelangre / FormikSubmitErrorMiddleware.js
Created September 18, 2020 14:28
Get access to errors on submitting the Formik-powered form and act accordingly anywhere down the Formik children hierarchy #formik
import React, { useEffect } from "react";
import { useFormikContext } from "formik";
const FormikSubmitErrorMiddleware = ({ onSubmitError }) => {
const formikContext = useFormikContext();
const { submitCount, isSubmitting, isValid } = formikContext;
useEffect(() => {
if (
submitCount > 0 &&
@vishaltelangre
vishaltelangre / 100-local-citus.sql
Created August 9, 2020 15:08 — forked from marchelbling/100-local-citus.sql
Local Citus cluster setup — bis
-- user:
CREATE ROLE citus WITH NOSUPERUSER LOGIN IN ROLE pg_monitor;
-- database:
ALTER DATABASE citus SET citus.shard_replication_factor = 1;
ALTER DATABASE citus OWNER TO citus;
-- extensions:
CREATE EXTENSION IF NOT EXISTS "hll";
CREATE EXTENSION IF NOT EXISTS "topn";
@vishaltelangre
vishaltelangre / combine_pdfs_into_one.sh
Created October 3, 2019 11:07
#combine_pdf #merge_pdf #pdf
"/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py" -o "output.pdf" *.pdf
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", github: "rails/rails"
@vishaltelangre
vishaltelangre / left_shift_and_right_shift_operators.md
Last active August 31, 2018 18:01
Left Shift (<<) and Right Shift (>>) Operators

Left Shift (<<) Operator

x << y == x * (2 ^ y)
Examples
1 &lt;&lt; 5 == 1 * (2 ^ 5) == 32
@vishaltelangre
vishaltelangre / Main.elm
Last active October 22, 2017 16:43
Heartbeat animation rendering on HTML5 Canvas in Elm using "evancz/elm-graphics" package. Compatible with Elm v 0.18. This is ported from an old example on http://outreach.mcmaster.ca/tutorials/animation/animation.html which uses old packages like "Signal" and "Graphics.Collage" which no longer exists in new Elm versions now.
module Main exposing (..)
import Html exposing (..)
import Color exposing (..)
import Collage exposing (..)
import Element exposing (..)
import Time exposing (Time)
import AnimationFrame
@vishaltelangre
vishaltelangre / Managing_Data_in_Microservices.md
Last active August 27, 2017 11:05
Managing Data in Microservices - Notes

Link to the talk: https://www.infoq.com/presentations/microservices-data-centric

Notes:

  1. Service for each table
  2. Local/own/isolated database for each service
  3. Cache join query information locally on respective service's DBs on each write to avoid cascaded service calls (aka joins in monolithic/shared DB)
  4. Alternative to ACID transactions is to perform multi-step operations using a state machine which can be rollbacked
  5. Dealing with events
    5.1 At most once delivery - When you don't care about such events, like logging stuff using UDP

Keybase proof

I hereby claim:

  • I am vishaltelangre on github.
  • I am vishaltelangre (https://keybase.io/vishaltelangre) on keybase.
  • I have a public key ASAgnXEmPd6H1DjWLMKbHYF4gOL529tTFVCjGzWvqDRwQQo

To claim this, I am signing this object:

@vishaltelangre
vishaltelangre / mac_locate_big_files.md
Last active February 22, 2022 00:55
Locate big files on macOS #mdfind #find #bigfiles
$ mdfind 'kMDItemFSSize > 200000000' | sed 's| |\\ |g' | xargs du -sch
#                             ^
#                         ~ 200MiB