useDefault

Manage state with default values using useDefault. The useDefault hook behaves similar to useState but with one difference – if the state of the hook is undefined or null, useDefault will default the state to a provided default value.
import * as React from "react";

export default function useDefault(initialValue, defaultValue) {
  const [state, setState] = React.useState(initialValue);

  if (typeof state === "undefined" || state === null) {
    return [defaultValue, setState];
  }

  return [state, setState];
}

useDocumentTitle

Dynamically update the title of a webpage with useDocumentTitle. The useDocumentTitle hook is useful for dynamically updating the title of a webpage based on the current state or data. This hook proves beneficial in scenarios where the title needs to be dynamically updated, such as displaying the name of the currently selected item or reflecting changes in application state.
import * as React from "react";

export default function useDocumentTitle(title) {
  React.useEffect(() => {
    document.title = title;
  }, [title]);
}

🐧 BASH - Flags de test

# Référence des flags de test Bash `[[ ]]`

## Tests sur les fichiers

| **Flag** | **Signification** | **Exemple** |
|----------|------------------|-------------|
| `-f` | Fichier régulier existe | `[[ -f file.txt ]]` |
| `-d` | Directory (dossier) existe | `[[ -d /tmp ]]` |
| `-e` | Existe (tout type) | `[[ -e /path ]]` |
| `-s` | Size > 0 (non vide) | `[[ -s file.txt ]]` |
| `-r` | Readable (lisible) | `[[ -r file.txt ]]` |
| `-w` | Writable (écriture) | `[[ -w file.txt ]]` |
| `-

Find heavy dependencies

#!/bin/bash
# package_size_analyzer.sh
# Script pour analyser la taille des packages Python installés
# et identifier lesquels mettre en Lambda Layers

# ========== CONFIGURATION ==========

# Table des mappings bizarres connus
declare -A WEIRD_MAPPINGS=(
    ["beautifulsoup4"]="bs4"
    ["pillow"]="PIL"
    ["pycryptodome"]="Crypto"
    ["scikit-learn"]="sklearn"
    ["python-dateutil"]="dateutil"
    ["msgpack-python"]="msgpack"
    ["opencv-python"]="cv2"
    ["mysqlclient"]="

Sidebar.php

<?php if ( is_active_sidebar( 'logo-right-ad' ) ) : dynamic_sidebar('logo-right-ad'); else: endif ?> 

☁️ Script Auto-Workflow UV + SAM ds CloudShell

# ========== AUTO-SETUP CLOUDSHELL ==========

# Configuration PATH
export PATH="$HOME/.local/bin:$HOME/.cargo/bin:$PATH"

# Installation UV si absent
if [[ ! -f "$HOME/.cargo/bin/uv" ]]; then
  echo "⚙️ Installation UV..."
  curl -LsSf https://astral.sh/uv/install.sh | sh 2>/dev/null
  echo "✅  UUV  installé"

Tầm Quan Trọng Của Cách Bố Trí Phòng Thư Viện Trường Học

# Tầm Quan Trọng Của Cách Bố Trí Phòng Thư Viện Trường Học

Thư viện trong trường học là không gian nuôi dưỡng thói quen đọc, phát triển tư duy, hỗ trợ tài liệu học tập cho học sinh. Tuy nhiên, để phát huy hết vai trò này, việc nghiên cứu **cách bố trí phòng thư viện trường học** trở thành yếu tố quan trọng. Một thư viện được thiết kế hợp lý giúp học sinh cảm thấy hứng thú, đồng thời nâng cao hiệu quả giáo dục.
![Alt Tag](https://vacons.com.vn/wp-content/uploads/2025/03/cach-bo-tri-phong-thu-vie

cleaning my mac

du -sh ~/Desktop ~/Documents ~/Downloads ~/Pictures ~/Movies ~/Music ~/dev ~/projects ~/code 2>/dev/null | sort -hr
ls -lah ~/Movies/ | head -20
ls -lah ~/Movies/Untitled.fcpbundle/
rm -rf ~/Movies/Untitled.fcpbundle/

Formularios en plantilla html en bloque

Si es un checkbox lo estiliza de una manera, si es inputs de otra manera.
    {% for field in form %}        
        {% if field.field.widget.input_type == 'checkbox'  %}
            {{ field }}
        {% else %}
            <div class="mb-3">
                <label for="{{ field.id_for_label }}" class="form-label">
                    {{ field.label }}
                </label>

                {{ field }}
                
                {% if field.errors %}
                    <div class="text-danger small">
                        {{ field.errors }}

Linux

Combines files into one for cert:
cat /home/jtvn/qradar.secureauth.com/2d3e6159dc9eff3c.crt \
    /home/jtvn/qradar.secureauth.com/gd_bundle-g2.crt \
    > /home/jtvn/qradar.secureauth.com/mbll-cert-full.pem
    
Secure Copy
scp -r /Users/jnguyen/Documents/Certificates/qradar.secureauth.com jtvn@10.5.0.102:/home/jtvn/

Replace without vi/vim/nano
sed -i 's|cert-file("/etc/syslog-ng/ssl/4926d3c0cbdbd5e6.pem")|cert-file("/etc/syslog-ng/ssl/mbll-cert.pem")|' /etc/syslog-ng/syslog-ng.conf

1733. Minimum Number of People to Teach

On a social network consisting of m users and some friendships between users, two users can communicate with each other if they know a common language. You are given an integer n, an array languages, and an array friendships where: There are n languages numbered 1 through n, languages[i] is the set of languages the ith user knows, and friendships[i] = [ui, vi] denotes a friendship between the users ui and vi. You can choose one language and teach it to some users so that all friends can communicate with each other. Return the minimum number of users you need to teach. Note that friendships are not transitive, meaning if x is a friend of y and y is a friend of z, this doesn't guarantee that x is a friend of z.
/**
 * @param {number} n
 * @param {number[][]} languages
 * @param {number[][]} friendships
 * @return {number}
 */
var minimumTeachings = function(n, languages, friendships) {
    // 1) Convert each user's language list to a Set for 0(1) checks.
    // We'll store with 1-based alignment: user i => index i (ignore index 0).
    const userLangs = Array(languages.length + 1);
    for (let i = 0; i < languages.length; i++) {
        userLangs[i + 1] = new Set(languages[i]); // users are 1-based
  

JSON Object OR List handling in Deserialization

/// <summary>
/// Custom JSON converter that handles deserialization of a property that can be either:
/// - A single JsonObject
/// - An array of JsonObjects
/// Always returns a List&lt;JsonObject&gt; for consistent handling.
/// </summary>
public class FlexibleJsonObjectListConverter : JsonConverter<List<JsonObject>?>
{
    public override List<JsonObject>? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
    {
        if (reader.TokenType == JsonTokenType.Nu

Export componentes

SELECT 
    comps.type_name,
    comps.name
FROM apex_210200.wwv_flow_appl_export_comps comps
     LEFT JOIN (
        SELECT type_name, id
        FROM apex_210200.wwv_multi_component_export
        WHERE flow_id = 115
     ) sel
       ON comps.type_name = sel.type_name
      AND comps.id        = sel.id
WHERE comps.application_id = 115;



SELECT 
    comps.type_name,
    comps.name
FROM apex_210200.wwv_flow_appl_export_comps comps
     LEFT JOIN (
        SELECT type_name

MultiVisionLab

# my-project > A lightweight, end-to-end PyTorch template for training, evaluating, and deploying vision models on scene understanding datasets (e.g., SUN RGB-D, ADE20K, NYU Depth V2, Places365). ## ✨ Features - Clean project layout with clear entry points (`train.py`, `inference.py`). - Modular components: `model.py`, `dataset.py`, `utils.py`. - Reproducible experiments via config and deterministic seeds. - Mixed precision, gradient clipping, checkpointing, and logging. - Example dataset links and loaders (customizable). ## 📦 Project Structure my-project/ ├── README.md ├── train.py ├── inference.py ├── model.py ├── dataset.py └── utils.py Each Python file is annotated and ~100 lines to serve as a readable template. ## 🧰 Requirements - Python 3.9+ - PyTorch (CPU or CUDA) - torchvision, pillow, numpy, tqdm, pyyaml (optional) Install example: ```bash pip install torch torchvision pillow numpy tqdm pyyaml 🚀 Quickstart Organize your dataset following a typical ImageFolder layout: /path/to/data/ train/ class_a/xxx.jpg class_b/yyy.jpg val/ class_a/zzz.jpg class_b/www.jpg Train: python train.py --data /path/to/data --epochs 20 --batch-size 32 --lr 1e-3 Inference: python inference.py --checkpoint runs/last.pt --image demo.jpg 🧪 Reproducibility We set the same seeds for random, numpy, and torch (see utils.set_seed). Deterministic convolution (opt-in) can slow training but improves reproducibility. 🧱 Datasets (Links) SUN RGB-D: http://rgbd.cs.princeton.edu/ ADE20K (Kaggle mirror): https://www.kaggle.com/datasets/awsaf49/ade20k-dataset?utm_source=chatgpt.com NYU Depth V2: https://cs.nyu.edu/~fergus/datasets/nyu_depth_v2.html Places365: http://places2.csail.mit.edu/ python train.py --config configs/example.yaml CLI always overrides YAML values. Minimal keys: data: "/path/to/data" epochs: 20 batch_size: 32 lr: 0.001 model: "resnet18" num_classes: 2 (You can extend freely.) 🛠 Tips Start small (e.g., 10% subset) to verify the pipeline. Monitor memory (nvidia-smi) if using large images or batch sizes. Use --amp to enable mixed precision on GPUs with Tensor Cores. Save checkpoints frequently and keep best/last separately. 📊 Metrics Accuracy@1 by default. Extend with precision/recall/F1 in utils.py. TensorBoard/CSV logging hooks are easy to add. 🧪 Unit Tests (Optional) Add tests/ with pytest to validate datasets and models. Keep data-independent tests fast. 🤝 Contributing PRs and issues are welcome. Please follow conventional commits and add docstrings. 🙏 Acknowledgements PyTorch team for the beautiful API. Public datasets: SUN RGB-D, ADE20K, NYU Depth V2, Places365. Inspiration from many open-source training templates.
"""
train.py
---------
Entry point for training a classification (or simple segmentation) model.
The script demonstrates a minimal yet robust PyTorch training loop with:
- CLI args & YAML config
- Reproducible seeds
- AMP mixed precision
- Gradient clipping
- Checkpointing (best/last)
- Simple CSV logging

This file is intentionally ~100+ lines with rich comments for readability.
"""
import argparse, os, time, yaml, csv
from typing import Dict, Any
import torch
from torch import

EntityFoundry

# My Project: Sequence Labeling with Neural NER (CoNLL-2003, OntoNotes 5.0, WNUT-17, GMB) This repository provides a clean, production-ready scaffold for training, evaluating, and deploying a Named Entity Recognition (NER) model using modern deep learning tooling. It is designed to be **readable**, **hackable**, and **reproducible**. The code is written in Python and organized to support research workflows (experiments, ablations) as well as practical usage (training, inference). > Highlights - Clear entry points: `train.py` for training, `inference.py` for predictions - Modular components: `model.py`, `dataset.py`, `utils.py` - Reproducible configs via CLI flags and seed control - Supports standard NER datasets and custom TSV/JSONL formats - Typed code, docstrings, and comments for readability --- ## 1) Quickstart ```bash # 1) Create environment python -m venv .venv source .venv/bin/activate # Windows: .venv\Scripts\activate # 2) Install dependencies pip install -U pip pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu pip install transformers==4.42.4 datasets==2.20.0 scikit-learn==1.5.1 rich==13.7.1 pyyaml==6.0.2 # 3) Train (example for CoNLL-style TSV) python train.py \ --train_file data/train.tsv \ --valid_file data/dev.tsv \ --model_name bert-base-cased \ --epochs 5 --batch_size 16 --lr 3e-5 --max_length 128 \ --output_dir runs/exp1 # 4) Inference python inference.py \ --model_path runs/exp1/best.ckpt \ --text "Barack Obama visited Berlin."
```python
"""
model.py
Neural architectures for token-level sequence labeling (NER).
This file defines a simple Transformer-based token classification model
with an optional CRF head interface (stubbed) to keep the scaffold concise.

Design goals:
- Minimal dependencies (Transformers + Torch)
- Clear separation of encoder and classification head
- Strong typing and docstrings for readability
"""

from __future__ import annotations
import math
from dataclasses import dataclass
fro

NER-Foundry

# my-project > A minimal yet practical NER research scaffold with train / eval / inference scripts and clean modules. --- ## 0. Highlights - Clean, modular, **production-friendly** structure. - Works with **PyTorch** + **Hydra-like** configs embedded in argparse. - Plug-and-play **Dataset**, **Model**, **Trainer**, **Inference**. - Clear extension points: metrics, logging, checkpointing, schedulers. --- ## 1. Motivation Named Entity Recognition (NER) is a core NLP task. This repo is a compact baseline to: - Reproduce simple sequence labeling results. - Provide a clear starting point for students and practitioners. - Demonstrate good engineering habits (typing, docstrings, tests entrypoints). --- ## 2. Project Layout my-project/ ├── README.md ├── train.py ├── model.py ├── dataset.py ├── utils.py └── inference.py Each file is self-contained and heavily documented. --- ## 3. Quickstart ### 3.1 Environment - Python >= 3.9 - PyTorch >= 2.0 - tqdm, numpy, scikit-learn, pyyaml (optional), rich (optional) ```bash pip install torch tqdm numpy scikit-learn rich 3.2 Data This scaffold expects a token per line format with blank lines between sentences: EU B-ORG rejects O German B-MISC call O ... You can also point to Hugging Face datasets by writing an adapter in dataset.py. 4. Datasets (with links) We used four widely-used NER datasets: CoNLL-2003 https://www.clips.uantwerpen.be/conll2003/ner/ English newswire; four entity types (PER, LOC, ORG, MISC). OntoNotes 5.0 (LDC—requires license) https://catalog.ldc.upenn.edu/LDC2013T19 Multi-genre, broader label set (DATE, TIME, MONEY, etc.). WNUT-17 (Emerging, noisy entities from social media) https://noisy-text.github.io/2017/emerging-rare-entities.html GMB (Groningen Meaning Bank) https://www.kaggle.com/datasets/abhinavwalia95/entity-annotated-corpus These same links are embedded in dataset.py for convenience.
```python
# model.py
# A simple BiLSTM sequence tagger with optional CRF placeholder.
# Heavy comments to guide extension.

from __future__ import annotations
import math
from typing import List, Tuple, Dict, Optional

import torch
import torch.nn as nn

class SequenceTagger(nn.Module):
    """
    A minimal BiLSTM tagger:
    - token embeddings
    - BiLSTM
    - linear projection to tag space

    Extension hooks:
    - Replace LSTM with TransformerEncoder
    - Add CRF on