Skip to content

Instantly share code, notes, and snippets.

View iamtalhaasghar's full-sized avatar
🇵🇰
Working From Home

Talha Asghar iamtalhaasghar

🇵🇰
Working From Home
View GitHub Profile
@iamtalhaasghar
iamtalhaasghar / dockerwatch.sh
Last active October 13, 2024 14:37
a script to check docker containers status and if anyone is stopped then start it
#!/bin/bash
# a script to check docker containers status and if anyone is stopped then start it
# Author: Talha Asghar <[email protected]>
# Co-author: chatgpt.com
# 13th-October-2024
log_file='/var/log/dockerwatch.log'
log() {
local message="$1"
local timestamp=$(date "+%Y-%m-%d %H:%M:%S")
@iamtalhaasghar
iamtalhaasghar / .screenrc
Last active August 16, 2024 11:12 — forked from joaopizani/.screenrc
A killer GNU Screen Config
# the following two lines give a two-line status, with the current window highlighted
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}]'
# huge scrollback buffer
defscrollback 5000
# no welcome message
startup_message off
@iamtalhaasghar
iamtalhaasghar / monitor.py
Created August 9, 2024 18:35
map directive not found while enabling sliding sync for synapse matrix server
import os
import time
import shutil
path = '/path/to/file'
dst = '/path/to/dst'
while True:
time.sleep(10/1000) # 10 milli seconds
if os.path.exists(path):
shutil.copy(path, dst)
@iamtalhaasghar
iamtalhaasghar / convert_mp4_mp3.py
Created May 11, 2024 11:47
A script to convert all .mp4 files in a dir to .mp3 audio files using ffmpeg.
#!/usr/bin/env python
import os
from glob import glob
import time
import logging
import sys
import shutil
import requests
from sha256sum import sha256sum
@iamtalhaasghar
iamtalhaasghar / matrix_server_notice.sh
Created February 25, 2024 09:30
Send server notice msg as an admin to any user in your synapse / matrix homeserver
# Prompts by https://gist.github.com/iamtalhaasghar
# Written by Chatgpt
# 25-Feb-2024
curl -X POST \
-H "Authorization: Bearer <your_access_token>" \
-H "Content-Type: application/json" \
-d '{
"user_id": "@<target_user>:<server_domain>",
"content": {
@iamtalhaasghar
iamtalhaasghar / research_time.py
Created February 27, 2023 19:57
a script to check time taken by a student to complete his/her thesis in my university by scraping data through emails i've received from thesis manager.
import imaplib
import re
import time
from dotenv import load_dotenv
import os
import email
load_dotenv()
imap_ssl_host = 'imap.gmail.com'
imap_ssl_port = 993
@iamtalhaasghar
iamtalhaasghar / install_lazy_git.sh
Last active August 16, 2022 06:24
A simple shell script to install go and lazygit on a linux system.
wget -v https://go.dev/dl/go1.18.5.linux-amd64.tar.gz
rm -rvf /usr/local/go && tar -C /usr/local -xvzf go1.18.5.linux-amd64.tar.gz
cd /opt
git clone https://github.com/jesseduffield/lazygit.git
cd lazygit
/usr/local/go/bin/go install
echo "alias lg='$HOME/go/bin/lazygit'" >> ~/.bashrc
$HOME/go/bin/lazygit --version
import pandas as pd
data = pd.read_csv('emails.csv')
data = data.set_index('Roll')
data.to_html('emails.html')
#data = data.drop('Name',axis=1)
#data.to_excel('emails.xlsx',sheet_name='Sheet1')
@iamtalhaasghar
iamtalhaasghar / github-cleansing.sh
Created August 1, 2021 05:35
Some commands which help you to clean your git commit history.
# Sign all previous commits
git rebase --root --exec "git commit --amend --author='Talha Asghar <[email protected]>' --no-edit --allow-empty"
git rebase --committer-date-is-author-date --root
git push -f
# Sign all commits to-date but dont touch commits before this point in history .i.e. commit hash "SHA256HASHEXAMPLE0000"
# Replace "SHA256HASHEXAMPLE0000" with your commit hash
git rebase SHA256HASHEXAMPLE0000 --exec "git commit --amend --author='Talha Asghar <[email protected]>' --no-edit --allow-empty"
git rebase --committer-date-is-author-date SHA256HASHEXAMPLE0000
git push -f
@iamtalhaasghar
iamtalhaasghar / google_drive_image_files_to_pdf.js
Created February 4, 2021 15:42
This script can be very helpful to download pdf/image files from Google Drive if for someone reason the owner has disabled the download option. Just paste the script in the console, press Enter and boom.
let jspdf = document.createElement("script");
jspdf.onload = function () {
let pdf = new jsPDF();
let elements = document.getElementsByTagName("img");
for (let i in elements) {
let img = elements[i];
console.log("add img ", img);
if (!/^blob:/.test(img.src)) {