Skip to content

Instantly share code, notes, and snippets.

View khnshn's full-sized avatar
🎯

Alireza Khanshan khnshn

🎯
View GitHub Profile
@khnshn
khnshn / .vimrc
Created April 20, 2025 17:59
my vimrc
set number
set relativenumber
set cursorline
set cursorcolumn
set colorcolumn=80
syntax on
set hlsearch
set incsearch
set showmatch
set foldmethod=syntax
@khnshn
khnshn / create_gamebus_users.py
Last active March 19, 2024 13:57
A script to create (sign up) GameBus players
import requests
import json
import time
import pandas as pd
import sys
if len(sys.argv) != 2:
print("Invalid arguments")
exit(0)
else:
@khnshn
khnshn / set_date.txt
Created February 11, 2024 21:30
Linux CLI set date to current datetime
sudo date -s "$(wget --method=HEAD -qSO- --max-redirect=0 google.com 2>&1 | sed -n 's/^ *Date: *//p')"
@khnshn
khnshn / bibmerger.py
Last active November 2, 2023 10:48
Search for .bib files in a directory and merge them where the unique id is (entry type, entry label).
import os
import argparse
import bibtexparser
# Create the parser
parser = argparse.ArgumentParser(
description="Search for .bib files in a directory and merge them."
)
# Add the arguments
parser.add_argument("Dir", metavar="dir", type=str, help="the directory to search")
@khnshn
khnshn / confusion_matrix.py
Created July 20, 2023 08:29
TPR, TNR, PPV, NPV, FPR, FNR, FDR, ACC
def perf_measure(y_actual, y_hat):
TP = 0
FP = 0
TN = 0
FN = 0
for i in range(len(y_hat)):
if y_actual[i] == y_hat[i] == 1:
TP += 1
if y_hat[i] == 1 and y_actual[i] != y_hat[i]:
select t2.* from (select json_extract(replace(value, "'",'"'),'$[*]') as arr from rh23_game_session inner join rh23_property_instance on rh23_game_session.id=rh23_property_instance.game_session where property_tk='PPG_LOG') as t1,
JSON_TABLE(cast(t1.arr as NCHAR), '$[*]' COLUMNS (
li INT PATH '$.li', ts BIGINT PATH '$.ts')
) t2
@khnshn
khnshn / remove_git_history.txt
Created December 20, 2022 13:40
Removes the commits history and pushes the current files as the initial commit
git checkout --orphan latest_branch
git add -A
git commit -am "first commit"
git branch -D main
git branch -m main
git push -f origin main
git gc --aggressive --prune=all
@khnshn
khnshn / send_notification.py
Created December 16, 2022 14:40
Sends notification to a list of smartwatches with Tizen OS given the message from the command line
import requests
import json
import time
import pandas as pd
import random
import sys
def send_notif(message):
@khnshn
khnshn / search.py
Created February 1, 2019 14:48
Simple search to look through all your codes for a keyword
import os
import sys
def search(p, s, ff):
try:
dirs = os.listdir(p)
for item in dirs:
if '.' in item:
if item.endswith('.{}'.format(ff)):
import requests
import multiprocessing
import time
import sys
from collections import Counter
def get_uris(uri):
session = requests.Session()
try:
response = str(session.get(uri).status_code)