Skip to content

Instantly share code, notes, and snippets.

View olegkhomenko's full-sized avatar
🪩
--

oleg olegkhomenko

🪩
--
View GitHub Profile
@olegkhomenko
olegkhomenko / temp_ufw_allow.sh
Created February 15, 2024 13:53
How to temporary Open port using UFW
# please run this script with sudo
PORT=8883
SLEEP=3600 # 60 * 60
ufw allow $PORT && \
sleep $SLEEP && \
for NUM in $(ufw status numbered | grep $PORT | awk -F"[][]" '{print $2}' | tr --delete [:blank:] | sort -rn); do
yes | ufw delete $NUM
done
@olegkhomenko
olegkhomenko / styles.css
Created June 28, 2023 13:00
betterhacker.news_styles.css
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
}
.container {
display: flex; justify-content: space-between;
flex-wrap: wrap; max-width: 1200px;
margin: 0 auto; background-color: #fff;
@olegkhomenko
olegkhomenko / index.html
Created June 28, 2023 12:57
betterhacker.news_index.html
<!DOCTYPE html>
<html>
<head>
<title>betterhacker.news</title>
<link rel="icon" type="image/x-icon" href="static/favicon.ico">
<link rel="stylesheet" href="static/styles.css">
<meta property="og:title" content="betterhacker.news">
<meta property="og:description" content="It is like hackernews, but better">
<meta property="og:type" content="website">
<meta property="og:url" content="https://betterhacker.news">
@olegkhomenko
olegkhomenko / 2023-06-26_articles.json
Last active June 28, 2023 12:23
2023-06-26_articles.json
{
"A proto-pizza emerges from a fresco on a Pompeii wall":{
"url":"http://pompeiisites.org/en/comunicati/pompeii-a-still-life-discovered-by-the-new-excavations-of-regio-ix/",
"score":93,
"topic":"news"
},
"The hidden cost of air quality monitoring":{
"url":"https://www.airgradient.com/blog/hidden-costs-of-air-quality-monitoring/",
"score":395,
"topic":"news"
@olegkhomenko
olegkhomenko / medium_tg_lbl_bot_next_video.py
Created September 20, 2022 17:11
medium_tg_lbl_bot_next_video
offset = min(offset, len(VIDEO_NAMES_KEYS) - 1)
v_key = VIDEO_NAMES_KEYS[offset]
next_video = VIDEO_NAMES[v_key]
@olegkhomenko
olegkhomenko / medium_tg_lbl_bot_start.py
Created August 25, 2022 17:18
medium_tg_lbl_bot_start
logging.basicConfig(filename="label-bot.log", level=logging.DEBUG)
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)
call_back_info = CallbackData("prefix", "text", "video")
scores = {} # we store cursor in-memory
@dp.message_handler(commands="start")
@olegkhomenko
olegkhomenko / medium_tg_lbl_gen_json.py
Last active November 25, 2022 08:50
medium_tg_lbl_gen_json
# -- Processing video names
def get_hash(fpath: Path, base_dir: str = "/home/username/templates/"):
"""/home/username/templates/001.mp4 -> c7b24d9dd0533a378f2fd379d4f1b8a1"""
return md5(fpath.as_posix().replace(base_dir, "").encode("utf-8")).hexdigest()
VIDEOS = sorted(list(Path(BASE_DIR).rglob("**/*.mp4")))
VIDEO_NAMES = {get_hash(p): p.as_posix() for p in VIDEOS}
VIDEO_NAMES_KEYS = list(VIDEO_NAMES)
def get_hash(fpath: Path):
"""
/home/username/templates/001.mp4 -> c7b24d9dd0533a378f2fd379d4f1b8a1
"""
return md5(fpath.as_posix().replace(BASE_DIR, "").encode("utf-8")).hexdigest()
@olegkhomenko
olegkhomenko / medium_tg_lbl_json.json
Last active August 23, 2022 14:38
medium_tg_lbl_json
{
"74cc24692dac38f0730b81df49c32980": "/home/username/label-bot/templates/1.mp4",
"6dfe6bfbf31c7f1dba33e3446abe5aeb": "/home/username/label-bot/templates/102.mp4",
"70a07295f7c6c2790778d4df3f0be5c9": "/home/username/label-bot/templates/103.mp4",
}
@olegkhomenko
olegkhomenko / predictor_clip_03.py
Last active May 3, 2022 11:03
predictor_clip_03
# Configuration
@dataclass
class ConfigGlobal:
BASE_PATH: Path = Path("./photos/")
LOG_FILENAME: str = "AttractiveMeter.log"
def analyze_photo(predictor_clip: PredictorCLIP, image_path: str):
fname = str(uuid.uuid4()) # we will store all photos which were process
fpath = Path(ConfigGlobal.BASE_PATH, fname + ".jpg").as_posix()
img, score, caption = predictor_clip.predict(image_path)