This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
offset = min(offset, len(VIDEO_NAMES_KEYS) - 1) | |
v_key = VIDEO_NAMES_KEYS[offset] | |
next_video = VIDEO_NAMES[v_key] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -- 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_hash(fpath: Path): | |
""" | |
/home/username/templates/001.mp4 -> c7b24d9dd0533a378f2fd379d4f1b8a1 | |
""" | |
return md5(fpath.as_posix().replace(BASE_DIR, "").encode("utf-8")).hexdigest() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"74cc24692dac38f0730b81df49c32980": "/home/username/label-bot/templates/1.mp4", | |
"6dfe6bfbf31c7f1dba33e3446abe5aeb": "/home/username/label-bot/templates/102.mp4", | |
"70a07295f7c6c2790778d4df3f0be5c9": "/home/username/label-bot/templates/103.mp4", | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
NewerOlder