Skip to content

Instantly share code, notes, and snippets.

View SHi-ON's full-sized avatar
🚀
“Dans une grande âme, tout est grand.”

Shawn Azdam SHi-ON

🚀
“Dans une grande âme, tout est grand.”
View GitHub Profile
@SHi-ON
SHi-ON / quit_excel.sh
Created July 19, 2025 19:27
Shell function for macOS to save all open Microsoft Excel workbooks and quit the application safely from the terminal.
# quitExcel.sh
#
# Function: quitExcel
#
# Description:
# Saves all open workbooks in Microsoft Excel and then quits the application,
# using AppleScript. Useful for closing Excel from the terminal and ensuring
# all data is saved.
#
# Usage:
@SHi-ON
SHi-ON / my_activity_safari.sh
Created July 19, 2025 19:13
Quickly preview your recent Safari browsing history (last 50 visits) in macOS using Quick Look, with automatic cleanup for repeat use.
# my_activity_safari.sh
#
# Function: myActivitySafari
#
# Description:
# Preview your 50 most recent Safari browsing history entries on macOS,
# using Quick Look. This function queries Safari’s local SQLite history,
# previews the results, and removes the temporary file so it can be run
# again without file conflicts.
#
@SHi-ON
SHi-ON / restart_pycharm.sh
Last active July 19, 2025 19:13
Gracefully restart PyCharm on macOS from your terminal, with fallback to force quit if needed.
# restart_pycharm.sh
#
# A shell function to gracefully restart PyCharm on macOS.
# Usage: source this file or copy the function into your ~/.zshrc or ~/.bashrc,
# then run `restartPyCharm` from your terminal.
# You may need to verify the Quit PyCharm shortcut key from the menu: Command + Shift + 9
#
# Author: SHi-ON
restartPyCharm() {
### Keybase proof
I hereby claim:
* I am shi-on on github.
* I am azdam (https://keybase.io/azdam) on keybase.
* I have a public key ASDbCk069qRAF9v2CwpJQFr89wJOeq_0JNSqDPsoubzthgo
To claim this, I am signing this object:
WEBVTT
Kind: captions
Language: en
00:00:01.879 --> 00:00:05.660 align:start position:0%
are<00:00:02.879><c> you</c><00:00:03.030><c> done</c><00:00:03.270><c> with</c><00:00:03.449><c> your</c><00:00:03.780><c> chunk</c><00:00:04.650><c> yet</c><00:00:04.890><c> almost</c>
00:00:05.660 --> 00:00:05.670 align:start position:0%
are you done with your chunk yet almost
@SHi-ON
SHi-ON / unfollow-pages.js
Created January 10, 2024 20:27
Unfollow LinkedIn Pages in bulk. Inspired by https://mighil.com/mass-unfollow-linkedin-connections/
(() => {
let count = 0;
function getAllButtons() {
return document.querySelectorAll('button.artdeco-button--2.artdeco-button--secondary') || [];
}
async function unfollowAll() {
const buttons = getAllButtons();
for (let button of buttons) {
if (button){
button.click();
@SHi-ON
SHi-ON / pdf_color_replacement.py
Last active September 17, 2023 16:24
Replace colors in a given PDF file. The original goal was to print a PDF paper using a printer with no black cartridge!
import concurrent.futures
import itertools
import math
import pdf2image # $ brew install poppler
from tqdm import tqdm
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
@SHi-ON
SHi-ON / my_telegram_chats.py
Last active June 12, 2022 17:32
List Telegram chats (including Super Groups and Channels) of your own.
from pyrogram import Client
with Client(CLIENT_NAME, API_ID, API_HASH) as client:
chats = []
for d in client.get_dialogs():
if d.chat.is_creator or \
(d.chat.permissions and d.chat.permissions.can_change_info):
chats.append(d.chat.title)
print(*chats, sep='\n')
print('\t Chat count:', len(chats))
@SHi-ON
SHi-ON / logger.py
Last active June 25, 2025 19:56
Python Logger class to Capture the feed coming from system stderr and stdout and write it to a file on disk and back to their respective buffer as well. Designed as a context manager, you can add the logging functionality and redirection to any Python script by just adding a line of code.
import logging
import pathlib
import sys
from ml.common.const import LOG_DIR_PATH, ML_DIR
def create_log_file_path(file_path, root_dir=ML_DIR, log_dir=LOG_DIR_PATH):
path_parts = list(pathlib.Path(file_path).parts)
relative_path_parts = path_parts[path_parts.index(root_dir) + 1:]
@SHi-ON
SHi-ON / decode_base64.py
Created March 15, 2022 17:01
Decode HTML files with inline Base64 images and store the image files separately.
import base64
import mimetypes
import os
from bs4 import BeautifulSoup
with open('example.html', 'rb') as file_handle: # Read in as a binary file
soup = BeautifulSoup(file_handle)