Skip to content

Instantly share code, notes, and snippets.

View GreatBahram's full-sized avatar
🚀
No STATUS!

Bahram Aghaei GreatBahram

🚀
No STATUS!
View GitHub Profile
@GreatBahram
GreatBahram / codejump.py
Created June 6, 2025 06:16
A CLI tool that opens VS Code at the line where a function/method is defined
#!/usr/bin/env python3
"""
A CLI tool that opens VS Code at the line where a function/method is defined.
Usage: codejump path/to/file.py::[ClassName::]function
For interactive usage with multiple files:
for line in $(cat filename); do codejump $line; read; done
"""
import ast
@GreatBahram
GreatBahram / province_city_national_code_prefix.csv
Last active November 13, 2021 19:45
Here, you can find iranian national code prefix with their corresponding province and city name
prefix province city
169 آذربایجان شرقی آذرشهر
170 آذربایجان شرقی اسکو
149 آذربایجان شرقی اهر
150 آذربایجان شرقی اهر
171 آذربایجان شرقی بستان آباد
168 آذربایجان شرقی بناب
136 آذربایجان شرقی تبریز
137 آذربایجان شرقی تبریز
138 آذربایجان شرقی تبریز
@GreatBahram
GreatBahram / cooccurence.py
Created October 20, 2021 17:14
CoOccurence words
from abc import ABC, abstractmethod
class CoOccurence(ABC):
def __init__(self) -> None:
self._container = None
@abstractmethod
def update(self, line: str) -> None:
...
@GreatBahram
GreatBahram / max_prefix.py
Last active October 8, 2021 19:20
Max Prefix value evaluation problem
from __future__ import annotations
from itertools import product
from typing import Generator
OPERATORS: tuple[str, ...] = ("*", "+", "-", "/")
def iter_variables(
variables: dict[str, tuple[int]]
@GreatBahram
GreatBahram / readme.md
Created July 7, 2021 08:53
markdown image scaling image

``

@GreatBahram
GreatBahram / fourinarow.py
Last active December 24, 2020 10:02
Beyond the basic stuff with Python - Hanoi
"""Four-in-a-Row, by Al Sweigart [email protected] A tile-dropping game to get four-in-a-row, similar to Connect Four."""
import sys
from enum import Enum
from textwrap import dedent
class Cell(str, Enum):
EMPTY = "."
PLAYER_X = "X"
PLAYER_O = "O"
@GreatBahram
GreatBahram / proxy.conf
Created May 12, 2020 05:01
docker-proxy-configuration
# /etc/systemd/system/docker.service.d/proxy.conf
[Service]
Environment="HTTP_PROXY=socks5://127.0.0.1:12345"
@GreatBahram
GreatBahram / tmux.conf.local
Last active June 11, 2020 06:00
Make https://github.com/gpakosz/.tmux compatible with vim key bindings
# My changes
# Change pane control to be Alt+vim arrow keys
bind-key -n M-h select-pane -L
bind-key -n M-l select-pane -R
bind-key -n M-k select-pane -U
bind-key -n M-j select-pane -D
#
# Change window control
bind-key l next-window
bind-key h previous-window
@GreatBahram
GreatBahram / decorators.py
Created March 31, 2020 11:52
Useful decorators
import os
from functools import wraps
def sudo_required(func):
"""Check sudo permission, if it hasn't, it'll exit non-zero."""
@wraps(func)
def wrapper(*args, **kwargs):
if os.getuid() != 0:
@GreatBahram
GreatBahram / main.py
Created February 26, 2020 19:33
Get notified when sanjesh provide ets voucher
import requests
import bs4
import sys
URL_ROOT = "https://ets.sanjesh.org/Register.aspx"
SPECIFIC_TEXT = "موجودي ووچر به پايان رسيده است"
def get_data(url):
req = requests.get(url)