Skip to content

Instantly share code, notes, and snippets.

@sathishvj
sathishvj / export_firestore_import_to_bq.sh
Created October 8, 2023 09:39
export collections from firestore and import to bq
#!/bin/bash
function fail {
printf '%s\n' "$1" >&2 ## Send message to stderr.
exit "${2-1}" ## Return a code specified by $2, or 1 by default.
}
projectId=""
bucket=""
dataset=""
@sathishvj
sathishvj / iterm2-multi-cat.bash
Last active August 19, 2023 08:19
iterm2 multi cat chooses to run regular cat or imgcat based on file extension
# iterm2 has some tools that you can install. imgcat displays images on the command line.
# this command will flexibly choose the specific cat cmd to run based on the extension.
# you can add this to your ~/.profile or whichever other file you've configured for your shell.
# run iterm shell integration for each shell. See utilities here: https://iterm2.com/documentation-utilities.html
source ~/.iterm2_shell_integration.bash
# run different cat cmds based on extension. If img then run imgcat (which is installed with iterm2_shell_integration
function cat() {
fullfile="$1"
@sathishvj
sathishvj / ext_change.sh
Created November 14, 2022 15:36
Convert images and videos by extension using imagemagick and ffmpeg
function ffmpeg_ext() { ffmpeg -i "$1" "${1%.*}.$2"; } # ffmpeg_ext a.mp4 gif
function img_ext() { convert "$1" "${1%.*}.$2"; } # img_ext a.png jpeg
@sathishvj
sathishvj / cdd-cdf.sh
Created June 23, 2020 13:56
go into directory containing a file or dir matching a pattern
# go directly into a directory containing a file or directory with a matching pattern.
# use cdf to match a file, use cdd to match a dir
# e.g.
# cdd mydir # will match files of the type .*myfile.*
# cdd myd.subd # will match like .*myd.*subd.*
# cdd myd.subd$ # will match like .*myd.*subd$
# cdf myfile # will match files of the type .*myfile.*
# cdf myfile.txt$ # will match files of the type .*myfile.txt$
# go into dir with a specific file in the subdirectory. Uses regex and substitues . with .*
@sathishvj
sathishvj / open_mac_app.sh
Last active August 4, 2023 05:57
Open MacOS Application from command line based on pattern
# open matching application on MacOS based on part of the pattern
# case insensitive
# errors out if there is less than or more than a single match
# app is forwarded all parameters after pattern
# example usage: a gimp pic.jpeg
function a() {
local app="$1"
# if no dir is specified, then it is the current dir.
if [ -z "$app" ]; then
@sathishvj
sathishvj / svgToPng.sh
Last active April 28, 2020 08:28
shell script to convert svg to pngs in many colors (uses inkscape)
#!/bin/bash
# i had a specific requirement to convert icons at iconmonstr.com to all google colors for my slides for youtube.com/AwesomeGCP
# doing it manually on their site was cumbersome.
# so it is very specific to simple svgs
endSvgRgx="\.svg$"
# for each input file
for file in $*
@sathishvj
sathishvj / CenterSelectionHorizontallyAndVerticallyOnSlide.gs
Created January 10, 2020 18:06
Google Apps Script to Center Selection Horizontally and Vertically on the Slide
/**
* @OnlyCurrentDoc
*/
/**
* Create a open translate menu item.
* @param {Event} event The open event.
*/
function onOpen(event) {
SlidesApp.getUi().createAddonMenu()
https://play.golang.org/p/eBOqfC0V59N - web.go
https://play.golang.org/p/kmZms7FoWss - web_test.go
https://play.golang.org/p/zVDTSq7jCP6 - web_http_test.go
@sathishvj
sathishvj / cdr-cfr.sh
Created January 12, 2019 06:26
# go into dir with a specific file or dir in the subdirectory. Uses regex and substitues . with .*
# usage
# cdr a1.b1
# ... this matches all dirs .*a1.*b1.*
# cdr ^a1.b1$
# ... this matches all dirs ^./a1.*b1$
# go into dir with a specific file in the subdirectory. Uses regex and substitues . with .*
function cfr() {
pat=$1
#replace . with .* - so we can give multiple parts
@sathishvj
sathishvj / curl-post.go
Last active December 18, 2018 04:35
curl POST written in go (for those who don't have curl)
// sometimes windows people don't have curl.
// This is a simple way to post a curl POST request.
// On newer windows versions, you can also try ...
// Invoke-WebRequest -Body '{"Author":"A", "Title":"B"}' -Method 'POST' -Uri 'http://localhost:8090/books'
package main
import (
"fmt"