Skip to content

Instantly share code, notes, and snippets.

View Mahyar24's full-sized avatar
🇺🇦

Mahyar Mahyar24

🇺🇦
View GitHub Profile
import time
import pandas as pd
def pretty_time(sec: int) -> str:
return time.strftime("%H:%M:%S", time.gmtime(sec))
import time
import pandas as pd
def pretty_time(sec: int) -> str:
return time.strftime("%H:%M:%S", time.gmtime(sec))
import time
import pandas as pd
def pretty_time(sec: int) -> str:
return time.strftime("%H:%M:%S", time.gmtime(sec))
import time
import pandas as pd
def pretty_time(sec: int) -> str:
return time.strftime("%H:%M:%S", time.gmtime(sec))
import time
import pandas as pd
def pretty_time(sec: int) -> str:
return time.strftime("%H:%M:%S", time.gmtime(sec))
@Mahyar24
Mahyar24 / abnormal.py
Last active December 9, 2022 19:37
Checking Abnormal V2Ray Users
#! /usr/bin/python3.10
"""
This module is used for checking excessive use by V2Ray users.
Install Pandas beforehand via: `pip install pandas`
Sample Command:
$ journalctl -u v2ray --since "72 h ago" | grep email | cut -d " " -f 6,7,8,13 | python abnormal.py -
GitHub: https://github.com/Mahyar24/V2Conf
@Mahyar24
Mahyar24 / pyrallel.py
Created March 10, 2023 20:30
Make things parallel.
import math
from concurrent.futures import ProcessPoolExecutor, as_completed
from typing import Callable
def cut_list(data: list, n: int):
for i in range(1, math.ceil(len(data) / n) + 1):
yield data[(i - 1) * n: i * n]
def parallelize(func: Callable, inputs: list, n: int):
import math
from functools import cache
from typing import Optional
@cache
def is_prime(n: int, primes: tuple[int]) -> bool:
sqrt = math.floor(math.sqrt(n))
for i in primes:
@Mahyar24
Mahyar24 / abnormal_pl.py
Last active April 17, 2024 20:22
Checking Abnormal V2Ray Users (Polars)
#! /usr/bin/env python3.10
"""
This module is used for checking excessive use by V2Ray users.
Install Polars beforehand via: `pip install polars`
Sample Command:
$ journalctl -u v2ray --since "72 h ago" | grep email | cut -d " " -f 6,7,8,13 | python abnormal.py -
GitHub: https://github.com/Mahyar24/V2Conf
Mahyar@Mahyar24.com, Mon 28 Nov 2022
"""
#! /usr/bin/env python3.10
"""
This module is used for checking V2Ray traffic consumption.
Install Pandas beforehand via: `pip install pandas`
Sample Command:
$ xray api statsquery --server="127.0.0.1:10085" -pattern '' | python3 traffic.py -
GitHub: https://github.com/Mahyar24/V2Conf