Posts

Sending email via command line

Requirements: sudo apt install mailutils sudo apt-get install ssmtp cat /etc/ssmtp/ssmtp.conf mailhub=email.firm.com:25 <smpt server> Then there are multiple ways to it  cat temp To: harshal.patil@adyne.com  Subject: Some Notifying Email  MIME-Version: 1.0  Content-Type: text/plain  Body of your email goes here. Hello world cat temp | sendmail -i -t OR  echo -e "To: harshal.patil@firm.com\nSubject: Subject\nContent-type: text/html" | cat - /stage/qspc/projects/sas/tools/sas_slippage_outliers.html | sendmail -i -t OR 52 07 * * 1-5 echo "To: harshal.patil@firm.com, harshal.patil@firm.com \nSubject: Slippage Outliers $(date +\%F) \nContent-type: text/html\n\n" > /tmp/email_body.txt;cat /stage/qspc/projects/sas/tools/sas_slippage_outliers.html >> /tmp/email_body.txt;cat /tmp/email_body.txt | /usr/sbin/sendmail -i -t > /stage/qspc/logs/sendmail/$(date +\%d).log 2>&1 If wanted to attach as a file (when html contains graphs):  (cat /...

Python / pandas last_bday

import pandas as pd from pandas.tseries.offsets import BDay today = pd.to_datetime('today') last_bday = today - BDay(1) 

Python groupby

 There are 2 ways to normal results: use agg function grp_df = df.groupby(['BookLevel4','Symbol','Direction','OrderId'], as_index=False).agg({'TxTime':['min','max','count'], 'FillQuantity':['sum']}) grp_df.columns = [''.join(col).strip() for col in grp_df.columns.values] use apply function  In case you use more than 1 column Wont have to normalize multi-level columns grp_df = df.groupby(['BookLevel4','Symbol','Direction','OrderId'], as_index=False).apply(         lambda s: pd.Series({             "TxTimemin": s["TxTime"].min(),             "TxTimemax": s["TxTime"].max(),             "TxTimecount": s["TxTime"].count(),             "FillQuantitysum": s["FillQuantity"].sum(),             "FillVWAP": (s['FillPrice'] * s['FillQuantity']).sum() / s['FillQuantity...

my .bcrc

 scale=6

my .screenrc

All possible variables are listed here: https://www.gnu.org/software/screen/manual/html_node/String-Escapes.html#String-Escapes  Here are the contents of my screenrc: # Change default scrollback value for new windows defscrollback 10000 # default: 100 # no welcome message startup_message off # advertise hardstatus support to $TERMCAP termcapinfo  * '' 'hs:ts=\E_:fs=\E\\:ds=\E_\E\\' termcapinfo xterm* ti@:te@ vbell "off" bindkey "^[OR" prev bindkey "^[OS" next hardstatus alwayslastline hardstatus string '%{= kG}[%{G}%H%? %1`%?%{g}][%= %{= kw}%-w%{+b yk} %n*%t%?(%u)%? %{-}%+w %=%{g}][%{B}%m/%d %{W}%C%A%{g}]' screen -t notebook  screen -t local

Docker commands

 Was trying to create a docker for android. Here are the commands I used: * sudo apt-get install qemu-kvm * curl -fsSL https://get.docker.com -o get-docker.sh * sh ./get-docker.sh *docker run -d -p 6080:6080 -e EMULATOR_DEVICE="Samsung Galaxy S10" -e WEB_VNC=true --device /dev/kvm budtmo/docker-android:emulator_13.0 * sudo chmod 666 /var/run/docker.sock  (if permission denied in previous step) * docker ps * docker stop <NAME>

Date conversion in MySQL

With recent release, MySQL throws error when inserting dates. This is because, by default "strict mode" is enabled. To get rid of the errors, we need to do something as follows: SHOW VARIABLES LIKE 'sql_mode' ; set sql_mode= '' ;