Skip to content

Instantly share code, notes, and snippets.

View Shlomigreen's full-sized avatar

Shlomi Green Shlomigreen

View GitHub Profile
@Shlomigreen
Shlomigreen / IAB content taxonomy JSON
Last active December 16, 2024 13:50
IAB Taxonomy - Content JSONs
{
"version": 1.0,
"categories": [
{
"id": "IAB1",
"category": "Arts & Entertainment",
"hierarchy": "Arts & Entertainment"
},
{
"id": "IAB1-1",
@Shlomigreen
Shlomigreen / postprocess.rs
Last active June 16, 2024 16:35
generate public modules from tonic output in rust[object Object]
use std::fs::File;
use std::fs;
use std::io::Write;
pub fn collect_files(dir: &str, ext: &str) -> Vec<String> {
let mut proto_files = Vec::new();
for entry in fs::read_dir(dir).expect("Directory not found") {
let entry = entry.expect("Failed to read directory entry");
let path = entry.path();
if path.is_dir() {
@Shlomigreen
Shlomigreen / main.py
Last active April 15, 2024 08:07
dynamic import files from path
import pathlib
import importlib
modules_dir = pathlib.Path(__file__).parent.absolute()
module_files = [file.stem for file in modules_dir.iterdir() if file.suffix == ".py" and file.stem != "__init__"]
for module_name in module_files:
module = importlib.import_module(f"{module_name}")
@Shlomigreen
Shlomigreen / adjectives.py
Last active March 31, 2024 10:44
100_word_lists
adjectives = [
"quick", "lazy", "sleepy", "noisy", "hungry", "funny", "gorgeous", "grumpy",
"fluffy", "bright", "silly", "messy", "shiny", "cheerful", "fancy", "crafty",
"clever", "friendly", "jolly", "kind", "lively", "lucky", "merry", "neat",
"nice", "polite", "proud", "silly", "thankful", "witty", "wonderful", "zany",
"bouncy", "brave", "calm", "delightful", "eager", "faithful", "gentle", "happy",
"jovial", "kind-hearted", "loving", "optimistic", "peaceful", "quirky", "reliable",
"respectful", "thoughtful", "upbeat", "vivacious", "warm", "xenial", "youthful",
"zealous", "amazing", "beautiful", "charming", "dazzling", "excellent", "fabulous",
"graceful", "handsome", "ideal", "joyful", "magnificent", "novel", "outstanding",
@Shlomigreen
Shlomigreen / python.py
Last active November 21, 2023 15:06
Protobuf
from google.protobuf import json_format
json_format.MessageToJson(message)
json_format.Parse(json_string, my_proto_pb2.MyMessage())
@Shlomigreen
Shlomigreen / check_if_module_exists.py
Created June 27, 2023 13:53
Python Dynamic Import
import importlib.util
import sys
# For illustrative purposes.
name = 'itertools'
if name in sys.modules:
print(f"{name!r} already in sys.modules")
elif (spec := importlib.util.find_spec(name)) is not None:
# If you choose to perform the actual import ...
ssh-add - <<< "<private ssh>"
@Shlomigreen
Shlomigreen / utils.py
Last active January 10, 2023 17:20
Text Processing
from simplified_scrapy.simplified_doc import SimplifiedDoc
import html
_special_chars = {
"base": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "!", "?", ".", ",", "\"", "'"],
"special": {
"serif_bold": ["๐š", "๐›", "๐œ", "๐", "๐ž", "๐Ÿ", "๐ ", "๐ก", "๐ข", "๐ฃ", "๐ค", "๐ฅ", "๐ฆ", "๐ง", "๐จ", "๐ฉ", "๐ช", "๐ซ", "๐ฌ", "๐ญ", "๐ฎ", "๐ฏ", "๐ฐ", "๐ฑ", "๐ฒ", "๐ณ", "๐€", "๐", "๐‚", "๐ƒ", "๐„", "๐…", "๐†", "๐‡", "๐ˆ", "๐‰", "๐Š", "๐‹", "๐Œ", "๐", "๐Ž", "๐", "๐", "๐‘", "๐’", "๐“", "๐”", "๐•", "๐–", "๐—", "๐˜", "๐™", "๐ŸŽ", "๐Ÿ", "๐Ÿ", "๐Ÿ‘", "๐Ÿ’", "๐Ÿ“", "๐Ÿ”", "๐Ÿ•", "๐Ÿ–", "๐Ÿ—", "โ—", "โ“", ".", ",", "\"", "'"],
"serif_italic": ["๐‘Ž", "๐‘", "๐‘", "๐‘‘", "๐‘’", "๐‘“", "๐‘”", "โ„Ž", "๐‘–", "๐‘—", "๐‘˜", "๐‘™", "๐‘š", "๐‘›", "๐‘œ", "๐‘", "๐‘ž", "๐‘Ÿ", "๐‘ ", "๐‘ก", "๐‘ข", "๐‘ฃ", "๐‘ค", "๐‘ฅ", "๐‘ฆ", "๐‘ง", "๐ด", "๐ต", "๐ถ", "๐ท", "๐ธ", "๐น", "๐บ", "๐ป", "
@Shlomigreen
Shlomigreen / import_from_gist.py
Last active January 10, 2023 17:09 — forked from koji-kojiro/import_from_gist.py
[Python] import from Gist
def download_from_gist(gist_id, outdir=None, encoding='utf-8'):
import json, os
from urllib.request import urlopen
gist_api = urlopen("https://api.github.com/gists/" + gist_id)
gist_json = json.load(gist_api)
gist_src = {filename: urlopen(metadata['raw_url']).read().decode(encoding) for filename, metadata in gist_json['files'].items()}
if outdir is None:
from tempfile import mkdtemp
@Shlomigreen
Shlomigreen / cv2.py
Last active May 19, 2021 13:34
Computer Vision #cv #machine-learning #python
# pip install opencv-python
import cv2
img = cv2.imread('hello_kitty.jpeg')
print("Type:",type(img))
print("Shape:", img.shape)
print("Dtype:", img.dtype)
# Converting to RGB
img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)