Skip to content

Instantly share code, notes, and snippets.

View vsbabu's full-sized avatar

Satheesh Vattekkat vsbabu

View GitHub Profile
@vsbabu
vsbabu / phonepe_pdftxt2csv.py
Last active August 27, 2024 06:22
Convert PhonePe PDF mailed statement to CSV
"""
PhonePe mails a PDF wih name PhonePe_Transaction_Statement.pdf. Open, Copy-all
and paste it into a text file.
Now call the script with input files listed out or with shell wildcards.
python %s PhonePe_Text_File_1.txt PhonePe_Text_File_2.txt ...
For each input file, a corresponding .psv file will be created. The content of these
have the following format.
ts|payee|txnid|utr|source|kind|currency|amount
@vsbabu
vsbabu / phonepe_pdf2txt.sh
Last active August 26, 2024 06:06
Convert PhonePe PDF mailed statement to CSV
#### this has some bugs w.r.t statement wrapping on long amounts, credits, HH24 etc. Use pure Python3 version below instead.
### https://gist.github.com/vsbabu/37275c9e45b8a496ed987e801950991a
#### retaining this for memory and not for use
############### DEPRECATED ##################################
# You need gnu awk and standard unix text tools
# PhonePe mails a PDF wih name PhonePe_Transaction_Statement.pdf. Open, Copy-all and paste it into a text file PhonePe_Transaction_Statement.txt
# If you are doing this in Windows, convert line endings first by running
# dos2unix PhonePe_Transaction_Statement.txt
# Output of the script is a pipe separated file
# timestamp|payee|txnid|utr|source|amount
@vsbabu
vsbabu / leo_install.sh
Created October 14, 2023 12:55
Installing Leo Outliner in Windows 11
# This is how I got Leo Outliner (https://leo-editor.github.io/leo-editor/) installed and usable in Windows 11, with dependencies.
### Step 1 - Anaconda
# install anaconda from https://www.anaconda.com/download
# Start -> Anaconda Powershell prompt
### Step 2 - get Leo
# get leo git repository into apps/leo-editor home directory
# if you don't have git, download from URL below as zip and extract
cd $HOME
@vsbabu
vsbabu / gpg_encrypt.sh
Created January 31, 2022 05:29
Wrapper for GPG and PGP files
#!/bin/bash
for f in "$@"
do
inp="$f"
oup=`echo "$inp".gpg`
gpg -e -r "CHANGE_MY_KEY_NAME" "$inp"
echo "$inp -> $oup"
done
exit 0
@vsbabu
vsbabu / gitup.sh
Created January 31, 2022 05:26
Pull all git repos
#!/bin/bash
cd ~/code
for d in `find . -type d -name '.git' -exec dirname {} \;`;
do
cd $d && pwd
git fetch --all && git pull && git gc
cd -
done
fi
@vsbabu
vsbabu / smartmerge.py
Created January 18, 2022 09:31
Smart merge and overwrite : csv
#!/usr/bin/env python3
"""
Pure python3 implementation to merge two csv files. Useful for getting incremental data
and updating existing large file.
Arguments:
Mandatory:
old file
new file
field separator: default is ,. Quoting is not handled.
@vsbabu
vsbabu / split_and_run.sh
Last active January 18, 2022 09:29
Use NQ to split an input file and run multiple queues on the chunks
#!/bin/bash
###########################################
#
# 1. adjust MAXQ and MAXFS below.
# 2. Adjust process inside process_one_file.sh
# here is an example file to simulate sleep and a CPU intensive processing
# #!/bin/bash
# sleep $[ ( $RANDOM % 10 ) + 1 ]s
# bzip2 $1
@vsbabu
vsbabu / sendhtmlmail_andattacment.sh
Created July 2, 2021 10:13
Send an HTML mail with a CSV attachment, in a default Ubuntu installation
MAIL_PARTBOUNDARY="`tr -dc A-Za-z0-9 </dev/urandom | head -c 16`"
/usr/sbin/sendmail -t <<EOF
From: ${MAIL_FROM}
To: ${MAIL_TO}
Cc: ${MAIL_CC}
Subject: ${MAIL_SUBJECT}
Content-Type:multipart/mixed; boundary="${MAIL_PARTBOUNDARY}"
--${MAIL_PARTBOUNDARY}
Content-Type: text/html
@vsbabu
vsbabu / working_days_since.py
Last active June 24, 2020 04:05
Python3 - calculate working days considering a holiday calendar
#!/usr/bin/env python3
import numpy as np
import datetime as dt
import sys
HOLIDAYS = [
"2020-01-01",
"2020-02-21",
"2020-04-10",
"2020-05-01",
@vsbabu
vsbabu / gitlab-flow-ex.sh
Created May 27, 2020 12:07
Gitlab flow example
#!/usr/bin/env bash
# This assumes it is being run inside tmux
# Demo is at https://youtu.be/Kc7wJkg1mlI
NOTETHIS() {
#tmux send-keys -t .1 C-z 'clear && git log --graph --decorate --date=relative --oneline --all' Enter
set +x
tmux send-keys -t .2 'R'
#tmux send-keys -t .1 C-z 'clear && git viz' Enter
tmux send-keys -t .0 C-z "clear && toilet -f wideterm $@ --gay" Enter
echo ">>> $@"