Skip to content

Instantly share code, notes, and snippets.

View cnmoro's full-sized avatar
🎯
Focusing

Carlo Moro cnmoro

🎯
Focusing
View GitHub Profile
@cnmoro
cnmoro / activate_zswap.sh
Created December 22, 2025 20:56
Activate and Configure ZSWAP Automatically
#!/bin/bash
# zswap Setup Script
# Example: curl -sL https://gist.githubusercontent.com/cnmoro/f7b8935736150dbac4d754051dc07e4b/raw/6c3489e2d612756acddb5152a136484a816b6528/activate_zswap.sh | sudo bash -s 4
set -e
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "Error: This script must be run as root (use sudo)"
@cnmoro
cnmoro / activate_zram.sh
Created December 22, 2025 20:49
Activate and Configure ZRAM Automatically
#!/bin/bash
# zRAM Setup Script
# Example: curl -sL https://gist.githubusercontent.com/cnmoro/32a898436388e8245fbb67cd7b6bb1e6/raw/98de143fdfe1a9c2d8649a5b5c572835c32b45e1/activate_zram.sh | sudo bash -s 4096M
set -e
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "Error: This script must be run as root (use sudo)"
@cnmoro
cnmoro / Guide.txt
Created October 17, 2025 21:17
Chromebook Linux Remap F-keys to Algr+1,2,3,etc
1 - Identificar o device
cat /proc/bus/input/devices
Look for something that says "keyboard" in the N: Name= line. In this example, it's "AT Translated Set 2 keyboard". The important part is the Handlers= line—it shows event1, which means the device is /dev/input/event1.
2 - Validar o dispositivo
sudo evtest
3 - Atualizar o código C com o device
Linha "input_fd = open("/dev/input/event0", O_RDONLY);" - trocar o eventX
@cnmoro
cnmoro / gliclass_onnx_util.py
Last active July 30, 2025 12:51
Gliclass ONNX Conversion and Inference
## Converter Imports
from transformers import AutoTokenizer
from gliclass import GLiClassModel
import torch
## Quantizer Imports
from onnxruntime.quantization import quantize_dynamic, QuantType
## Inference imports
from tokenizers import Tokenizer
@cnmoro
cnmoro / sequence_mining_analysis.py
Created April 30, 2025 19:42
Sequence Mining Analysis
import pandas as pd
def sequence_mining_analysis(df, id_col, date_col, cat_col):
if not pd.api.types.is_datetime64_any_dtype(df[date_col]):
raise TypeError(f"Column '{date_col}' must be datetime.")
df = (df[[id_col, date_col, cat_col]]
.sort_values([id_col, date_col]))
grp = df.groupby(id_col)[cat_col]
@cnmoro
cnmoro / log_exception.py
Created March 11, 2025 19:20
log_exception
import traceback, inspect, re, datetime
def log_exception(e, custom_msg=None):
# Get the frame of the caller (the function where the exception was caught)
frame = inspect.currentframe().f_back
func_name = frame.f_code.co_name
filename = frame.f_code.co_filename
line_no = frame.f_lineno
@cnmoro
cnmoro / antelopev2-face-features.py
Created March 7, 2025 14:00
antelopev2-face-features.py
# pip install -U insightface mxnet onnx onnxruntime
# Initialize the FaceAnalysis app with the Antelope model
from insightface.app import FaceAnalysis
app = FaceAnalysis(name='antelopev2', root='./', providers=['CPUExecutionProvider'])
# Remove nested folder from download if needed
app.prepare(ctx_id=-1, det_size=(640, 640))
from PIL import Image
img = Image.open('82.png')
@cnmoro
cnmoro / SemanticDiffusionEncoder.py
Created January 8, 2025 04:01
SemanticDiffusionEncoder
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import DataLoader, Dataset
from torchtext.vocab import build_vocab_from_iterator
@cnmoro
cnmoro / SpatioTemporalGraphEncoding.py
Created January 8, 2025 03:59
SpatioTemporalGraphEncoding
import numpy as np
import torch
from torch.utils.data import DataLoader, Dataset
from collections import defaultdict
class WordGraph:
@cnmoro
cnmoro / GraphWalkEncoder.py
Created January 8, 2025 03:57
GraphWalkEncoder
import numpy as np
import random
from collections import defaultdict
class GraphWalkEncoder:
def __init__(self, vocab_size, vector_size=64, walk_length=5):