Skip to content

Instantly share code, notes, and snippets.

View anroopak's full-sized avatar
🤓
Building my dreamz

Roopak A N anroopak

🤓
Building my dreamz
  • Airbase Inc
  • Kannur
View GitHub Profile
@anroopak
anroopak / Code.gs
Last active December 6, 2021 03:55
Google App Script - Email cleanup
CUTOFF_IN_DAYS = 7
function cleanEmail() {
const searchQueries = [
"bigrock.com",
"instahyre.com",
"accounts.google.com",
]
searchQueries.forEach(searchText => {
const search = "from:"+searchText + " older_than:"+CUTOFF_IN_DAYS+"d"
ARGS_TEXT="""
Usage: mkcdaliases {folder alias name} {folder to reach}
Eg: mkcdaliases myfolder ./my-folder
This creates a command -> cdmyfolder which navigates to my-folder
"""
_mkcdaliases() {
folder_alias=$1
folder=$2
@anroopak
anroopak / .zshextensions.sh
Created May 23, 2020 13:25
My personal Zsh Extensions
alias reloadzshrc="source ~/.zshrc"
# Python aliases
alias activatevenv="source venv/bin/activate"
@anroopak
anroopak / merge_csv.sh
Created May 24, 2019 13:09
Script to merge small CSVs
csvheader=`head -1 small_0.csv`
ls small_*.csv | xargs sed -i '1d'
echo $csvheader > merged.csv
cat small_*.csv >> merged.csv
@anroopak
anroopak / decimal_to_base.py
Created May 7, 2019 09:01
Convert a Decimal to a base and back.
import string
def int_to_str_base(decimal: int, base: int) -> str:
other_base = ""
while decimal != 0:
other_base = ALPHANUMERIC_CHARS[decimal % base] + other_base
decimal = int(decimal / base)
if other_base == "":
other_base = "0"
return other_base
@anroopak
anroopak / run_jobs_parallel.sh
Created January 18, 2019 05:58
Running Jobs in Parallel
# Runs the run_job function in parallel
run_job() {
/path/to/script.ext <args(optional)> $1 > "logs/$1.log" 2>&1
}
export -f run_job
# limits.txt file has the args for the run_job function.
# -j4 => run 4 threads at max in parallel
# --eta => print the eta of the jobs on the console
@anroopak
anroopak / split_csv.sh
Last active January 18, 2019 05:55
Script to split CSV files to small chunks
# Credit: https://stackoverflow.com/a/53269966/2594980
csvheader=`head -1 bigfile.csv`
split -d -l10000 bigfile.csv smallfile_
find .|grep smallfile_ | xargs sed -i "1s/^/$csvheader\n/"
sed -i '1d' smallfile_00
@anroopak
anroopak / compare_lists_of_dicts_wo_order.py
Created December 14, 2018 08:05
Compare 2 lists of dicts without order
# https://stackoverflow.com/questions/12813633/how-to-assert-two-list-contain-the-same-elements-in-python/31832447
list_1 = [{'unique_id':'001', 'key1':'AAA', 'key2':'BBB', 'key3':'EEE'},
{'unique_id':'002', 'key1':'AAA', 'key2':'CCC', 'key3':'FFF'}]
list_2 = [{'unique_id':'001', 'key1':'AAA', 'key2':'DDD', 'key3':'EEE'},
{'unique_id':'002', 'key1':'AAA', 'key2':'CCC', 'key3':'FFF'}]
def compare_list_of_dicts(list_1, list_2):
pairs = zip(list_1, list_2)
return any(x != y for x, y in pairs)