Skip to content

Instantly share code, notes, and snippets.

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

Talha Asghar iamtalhaasghar

🇵🇰
Working From Home
  • Pakistan
  • 17:11 (UTC +05:00)
View GitHub Profile
@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 <talhaasghar.contact@simplelogin.fr>' --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 <talhaasghar.contact@simplelogin.fr>' --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)) {
@iamtalhaasghar
iamtalhaasghar / withdraw_calculations.py
Created January 13, 2021 10:02
A simple program to calculate actual withdraw amount of payoneer after deduction of 2% charges from USD to YOUR_NATIVE_CURRENCY
# A simple program to calculate actual withdraw amount of payoneer
payoneerCut = 2
rate = int(input('Enter currency rate of USD -> YOUR_NATIVE_CURRENCY : '))
amount = int(input('Enter amount to withdraw (in YOUR_NATIVE_CURRENCY): '))
rate = (rate - ((payoneerCut / 100) * (rate)))
print('New Rate of USD -> YOUR_NATIVE_CURRENCY : %.2f' % (rate))
print("You`ll recieve: %.2f (in YOUR_NATIVE_CURRENCY)" % (rate * amount))
@iamtalhaasghar
iamtalhaasghar / zipper.py
Created January 13, 2021 09:58
A python module which creates .zip & .rar archives of subfolders of a given path
# A python module which creates .zip & .rar archives of subfolders of a given path
def subFolders(folder_path):
'Returns list of subfolders of given path'
import os
foldersList = list()
print('Looking for subfolder of : %s' % (folder_path))
for i in os.listdir(folder_path):
if(os.path.isdir(i)):
print('%s' % (i), end=', ')
@iamtalhaasghar
iamtalhaasghar / renamer.py
Last active January 13, 2021 09:58
A simple script to prettify pdf file names
# A simple script to prettify pdf file names
def listAllPdfFiles(dirPath):
'Return list of all pdf files of provided path'
import os
pdfFiles = list()
print('Looking for pdf files...')
for f in os.listdir():
if(os.path.isfile(f) and f.endswith('.pdf')):
print('%s' % f, end=", ")
@iamtalhaasghar
iamtalhaasghar / email_scraper_from_google_forms_analytics_page.js
Last active December 9, 2020 11:03
A simple javascript code snippet to scrap emails from a Google Forms Page (View other Responses Page). Just open up the Google Form in a new tab. Go to Console, paste the code and boom!!! ProTip: Copy the console log to clipboard and then paste the clipboard contents to a newly created .txt file. You will have your required data in a nice format.
/*
It only scraps first 100 emails because other emails are not visible.
Whenever I will have time, i will try to work around this problem
Tested on Firefox 80.0.1
Not sure about other browsers, (theoretically it should work)
*/
// xpath of div containing emails in a google form
allDivs = $x("//*[contains(text(),'Email') and @class='freebirdAnalyticsViewQuestionTitle']/ancestor::div[@class='freebirdAnalyticsViewAnalyticsHover']")
// get innerText which is essentially emails of all correspondents and also contains some other irrelevant text
uglyData = allDivs[0].innerText.split('\n')