Posts

Showing posts from February, 2025

Sending email from Python

 Can setup SMTP inside python itself but for better protection, setup sendmail with SMTP as in other post and then: More focused module :  def send_mail ( email , subject , body = "" , dataframe_dict = {}):     html_content = ""     for name , df in dataframe_dict .items():         html_content += f "<h3> { name } </h3>"         html_content += df .to_html( escape = False , classes = 'table table-striped' , table_id = 'dataframe' )         html_content += "<br><br>"     styled_html = f """     <html>     <body>         { body }         <br><br><br><br>         { html_content }     </body>     </html>     """     # Send HTML email using mail command     process = subprocess...

Bloomberg BQL

 BQL is not part of daily limit. So we can use those to get the data even when limit is hit: =@BQL.QUERY("get(" & TEXTJOIN(",", TRUE, B1:E1) & ") for(members('RAY Index'))","cols=7;rows=5919") where cells B1 to E1 have fields as follows: market_cap px_volume 30_day_average_volume_at_time factor_expected_daily_volume

Python Selenium Webdriver sample program

 this is a sample program using selenium to click a button: from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager import time # Set up Chrome options chrome_options = webdriver.ChromeOptions() chrome_options.add_argument("--headless")  # Run in headless mode (no UI) chrome_options.add_argument("--disable-gpu")  # Disable GPU acceleration for headless mode chrome_options.add_argument("--no-sandbox")  # Disable sandboxing for headless mode chrome_options.add_argument("--disable-dev-shm-usage")  # Fix shared memory issues # Set up ChromeDriver using Service (Selenium 4) service = Service(ChromeDriverManager().install()) # Initialize WebDriver (Chrome) with the path to your ChromeDriver driver = webdriver.Chrome(service=service, options=chrome_options) try:     # Open the website     driver.get("http://omsprodapp:99...

logger.sh

  #!/bin/bash source /home/ $LOGNAME /.env # Ensure at least two arguments are provided if [ " $# " -lt 2 ]; then     echo "Usage: $0 <command> <file_path> [additional_args...]"     exit 1 fi # Extract filename from the second argument filename = $( basename " $2 " ) # Define log directory and log file path log_dir = "/stage/ $LOGNAME /logs/ $filename " log_file = " $log_dir /$( date +%d).log" # Create log directory if it doesn't exist mkdir -p " $log_dir " # Redirect STDOUT and STDERR to the log file (no output on terminal) exec >> " $log_file " 2>&1 echo "Executing " $@ " at ` date `" # Execute the provided command eval " $@ "

Windows 11 Pro cannot grab window when maximized

 Win + R -> "control access.cpl" Make the mouse easier to use UnCheck "Prevent windows from being automatically arranged"

Loading env file in bash

 If you want to load .env file before running a command in bash, we can use following utility. (Can use the just the command as well.) 14:54:00 harshal@HP:~$ set -a; source ~/.env; set +a; CMD or 14:55:42 harshal@HP:~$ cat ~/load_dot_env.sh set -a; source ~/.env; set +a 14:55:47 harshal@HP:~$ source ~/load_dot_env.sh  14:55:49 harshal@HP:~$   

Citrix workspace on Ubuntu 2404

Typically, we start Citrix with this command: /opt/Citrix/ICAClient/selfservice But I was getting this error : harsshal@HP:~$ /opt/Citrix/ICAClient/selfservice  /opt/Citrix/ICAClient/selfservice: error while loading shared libraries: libwebkit2gtk-4.0.so.37: cannot open shared object file: No such file or directory But followed these steps and then it worked: sudo add-apt-repository -y "deb http://gb.archive.ubuntu.com/ubuntu jammy main" sudo apt update sudo apt install libwebkit2gtk-4.0-dev To enable middle click, Change the configuration file  : sudo vim /opt/Citrix/ICAClient/config/All_Regions.ini: MouseSendsControlV=False 

AutoHotKey programs

volume.ahk #Requires AutoHotkey v2.0 Volume_Down::SoundSetVolume "-10" Volume_Up::SoundSetVolume "+10" Volume_Mute::SoundSetMute "-1" mouse.ahk #Requires AutoHotkey v2.0 waitTime := 5 ; Number of minutes to wait Loop {     Sleep waitTime * 60 * 1000     MouseMove 10, 0, 20, "R"     MouseMove -10, 0, 20, "R" } blotter.ahk #Requires AutoHotkey v2.0  ; Ensure the script runs with AutoHotkey v2 SetTimer RunCommand, 3600000  ; Set a timer to run every 1 hour (3600000 milliseconds) RunCommand() {     currentTime := FormatTime("HH")  ; Corrected FormatTime call     if ((currentTime >= 7 and currentTime <= 15) or currentTime = 17)  ; Check if it's between 7 AM - 3 PM or exactly 5 PM     {         Run("C:/Users/hpatil/AppData/Local/Microsoft/WindowsApps/python.exe c:/Users/hpatil/webdr.py")     } } or  #Requires AutoHotkey v2.0  ; Ensure the script runs with AutoHotkey v2...