RTL admin helpers for list display & forms

# /common/admin_helpers.py
# RTL admin helpers for list display & forms

"""
# Example usage in admin.py

from common.admin_helpers import rtl_list_field, rtl_form_field


class NotificationTypeAdminForm(forms.ModelForm):
    class Meta:
        model = NotificationType
        fields = "__all__"

        widgets = {
            "field1": rtl_form_field(), # default is text input
            "field2": rtl_form_field(forms.Textarea, rows=5), # change to textarea
            "fiel

1614. Maximum Nesting Depth of the Parentheses

Given a valid parentheses string s, return the nesting depth of s. The nesting depth is the maximum number of nested parentheses.
/**
 * @param {string} s
 * @return {number}
 */
var maxDepth = function(s) {
    let currentDepth = 0;
    let maxDepth = 0;

    for (const char of s) {
        if (char === '(') {
            // Entering a deeper level of nesting
            currentDepth++;

            // Record the maximum depth seen so far
            maxDepth = Math.max(maxDepth, currentDepth);
        } else if (char === ')') {
            // Leaving the current nesting level
            currentDepth--;
        }
    }

# ContrastiveGradientLow

# ContrastiveGradientLow An attention-based predictive framework for respondent-level health-information-seeking prediction from heterogeneous population-health survey data. ## Overview ContrastiveGradientLow is a structured tabular learning framework designed to predict whether an individual reports seeking health or medical information. The framework is developed for population-health survey data containing heterogeneous numerical, ordinal, categorical, and missing-value features. The model combines: - **Feature-Level Attention** to construct respondent-specific representations from heterogeneous predictors. - **Supervised Contrastive Learning** to organize latent representations according to the observed behavioral outcome. - **Gradient Stabilization** to control unstable parameter updates during joint optimization. - **Low-Rank Structure Mapping** to reduce redundant latent dimensions while retaining prediction-relevant information. - **Constraint-Driven Regularization** to preserve ordinal measurement structure, encourage coverage of theoretically relevant health-information features, and improve robustness to alternative representations of missing responses. The framework is intended for predictive modeling and does **not** estimate causal effects of education, language proficiency, health literacy, or communication interventions. ## Prediction Task Given respondent-level characteristics, the model estimates the probability that a respondent reports having looked for health or medical information. The predictors include harmonized variables related to: - Health communication - Health literacy and information comprehension - Education and language-related characteristics - Demographic and socioeconomic characteristics - Contextual health-information variables The prediction target is binary health-information-seeking behavior. ## Dataset Experiments use four independent public-use cohorts from the **Health Information National Trends Survey (HINTS 5)** administered by the U.S. National Cancer Institute: | Cohort | Year | Respondents | | --- | ---: | ---: | | HINTS 5 Cycle 1 | 2017 | 3,285 | | HINTS 5 Cycle 2 | 2018 | 3,504 | | HINTS 5 Cycle 3 | 2019 | 5,438 | | HINTS 5 Cycle 4 | 2020 | 3,865 | Each survey cycle is modeled independently rather than concatenated or treated as longitudinal observations. Official HINTS public-use data, questionnaires, codebooks, and methodology documentation are available from the National Cancer Institute HINTS website. ## Architecture The main modeling pipeline is: ```text Structured HINTS Survey Data | v Feature Encoding | v Feature-Level Attention | v Respondent Representation / \ v v Supervised Low-Rank Contrastive Mapping Learning \ / v v Binary Classifier | v Probability of Health-Information-Seeking ``` Three survey-oriented soft constraints are incorporated during training: 1. **Ordinal-Scale Preservation** — encourages learned representations of ordinal response categories to preserve their known ordering. 2. **Theory-Guided Attention Coverage** — discourages the model from systematically ignoring prespecified health-information-related feature groups. 3. **Missing-Response Consistency** — reduces prediction sensitivity to alternative representations of non-substantive missing survey responses. ## Training Objective The complete objective combines classification, supervised contrastive learning, low-rank reconstruction, and domain-constraint regularization: ```text L_total = L_cls + beta * L_con + mu * L_lr + eta * L_c ``` where: - `L_cls` is the binary classification loss. - `L_con` is the supervised contrastive loss. - `L_lr` is the low-rank reconstruction loss. - `L_c` is the survey-oriented constraint penalty. Gradient stabilization is applied separately through global gradient-norm clipping. ## Experimental Setup The reported experimental configuration uses: | Setting | Value | | --- | --- | | Train / Validation / Test | 70% / 15% / 15% | | Repeated Runs | 5 | | Feature Latent Dimension | 64 | | Contrastive Projection Dimension | 32 | | Low-Rank Dimension | 16 | | Contrastive Temperature | 0.10 | | Optimizer | AdamW | | Initial Learning Rate | 1e-3 | | Weight Decay | 1e-4 | | Learning-Rate Schedule | Cosine decay | | Batch Size | 128 | | Maximum Epochs | 100 | | Early-Stopping Patience | 15 epochs | | Gradient Clipping Threshold | 1.0 | | Model-Selection Metric | Validation ROC-AUC | All preprocessing and model-selection operations are fitted using training or validation data only. Test labels are not used for preprocessing, hyperparameter selection, early stopping, or threshold determination. ## Benchmarks ContrastiveGradientLow is evaluated against six tabular classification baselines: - Logistic Regression - Random Forest - XGBoost - Multilayer Perceptron - TabNet - FT-Transformer All methods use the same respondent-level partitions and a common evaluation protocol. ## Results Across the four HINTS 5 cohorts, ContrastiveGradientLow achieved mean ROC-AUC values between **81.57 and 82.21**. | Cohort | ContrastiveGradientLow ROC-AUC | FT-Transformer ROC-AUC | | --- | ---: | ---: | | Cycle 1 (2017) | 81.86 | 80.17 | | Cycle 2 (2018) | 82.03 | 80.36 | | Cycle 3 (2019) | 81.57 | 80.02 | | Cycle 4 (2020) | 82.21 | 80.48 | Component-wise ablation experiments showed reduced mean predictive performance when feature-level attention, contrastive structure matching, gradient stabilization, low-rank mapping, or constraint-driven learning was removed. ## Evaluation Metrics The project evaluates predictive performance using: - Accuracy - Precision - Recall - F1-score - ROC-AUC ROC-AUC is used as the primary model-selection metric. Pairwise ROC-AUC differences are evaluated with paired bootstrap resampling and Holm adjustment for multiple comparisons. ## Installation Repository code and dependency files will be added here. A typical setup will look like: ```bash git clone <repository-url> cd ContrastiveGradientLow python -m venv .venv source .venv/bin/activate pip install -r requirements.txt ``` On Windows: ```bash .venv\Scripts\activate ``` ## Usage Training and evaluation scripts will be documented once the implementation is added to the repository. A future command-line workflow may follow this structure: ```bash python train.py --config configs/default.yaml python evaluate.py --checkpoint <checkpoint-path> ``` The exact commands should be updated to match the final repository structure. ## Reproducibility The experimental design uses five predefined random seeds. For each seed, the proposed model and all comparison methods use the same stratified train, validation, and test partitions. To reproduce the reported experiments, the repository should include: - Data preparation and harmonization scripts - Model implementation - Baseline implementations or wrappers - Training configuration files - Fixed random seeds - Evaluation scripts - Ablation configurations - Hyperparameter sensitivity configurations ## Data Availability The study uses publicly available, de-identified HINTS data from the U.S. National Cancer Institute. Users should obtain the original public-use datasets and accompanying documentation directly from the official HINTS repository and comply with the applicable HINTS data-use and confidentiality provisions. This repository should not redistribute source data unless redistribution is explicitly permitted by the corresponding data license and terms of use. ## Important Scope Note ContrastiveGradientLow learns predictive associations from observational, cross-sectional survey data. Model outputs and attention weights must not be interpreted as causal effects or evidence that changing a predictor will change health-information-seeking behavior. Before operational public-health use, additional external validation, calibration analysis, subgroup performance assessment, and evaluation in prospective or intervention-specific datasets are required. ## Citation If you use this project in academic work, please cite the associated paper: ```bibtex @article{hu_contrastivegradientlow, title = {Predicting Health-Information-Seeking Behavior from Population Health Survey Data Using Attention-Based Contrastive Representation Learning}, author = {Hu, Chunyan}, note = {Citation details to be updated upon publication} } ``` ## License A license has not yet been specified. Before publishing the repository, add an appropriate `LICENSE` file and update this section accordingly. ## Acknowledgments This project uses data from the Health Information National Trends Survey (HINTS), administered by the U.S. National Cancer Institute.
"""
ContrastiveGradientLow
======================

PyTorch implementation of the model described in:

"Predicting Health-Information-Seeking Behavior from Population Health Survey
Data Using Attention-Based Contrastive Representation Learning"

This implementation follows the paper's model structure:
- Feature-specific encoding for numerical, ordinal, and categorical variables
- Feature-level attention
- Supervised contrastive learning
- Low-rank structure mapping
- Binary classification
- Ordin

Organizational Deep Learning Capability and Manufacturing Quality Intelligence — Questionnaire and Analysis Specification

# Questionnaire and analysis specification

Associated manuscript: Organizational Deep Learning Capability and Manufacturing Quality Intelligence in Integrated Circuit Manufacturing

This document describes the measurement items and analysis plan reported in the manuscript. It does not contain individual-level survey responses, simulated responses, or executable analysis code.

## Study design

The study used a cross-sectional electronic questionnaire of professionals working in integrat

unique patient count

WITH
date_range AS (
    SELECT
        DATE '2026-09-01' AS start_date,
        DATE '2026-09-30' AS end_date
),

anc_dedup AS (
    SELECT base_entity_id, MIN(date_created) AS anc_date
    FROM report.anc_register
    GROUP BY base_entity_id
),

ncd_regi_dedup AS (
    SELECT base_entity_id, MIN(date_created) AS ncd_regi_date
    FROM report.ncd_package
    GROUP BY base_entity_id
),

ncd_service_dedup AS (
    SELECT
        po.base_entity_id,
        MIN(po.date_created

merged script MPR July_Anc_Money Receipt

WITH date_range AS (
    SELECT
        DATE '2026-07-01' AS start_date,
        DATE '2026-07-31' AS end_date
),
 
-- 1. Pregnant Mothers
pregnant_mothers AS (
    SELECT
        b.id AS branch_id,
        b.name AS branch_name,
        COALESCE(COUNT(DISTINCT poa.base_entity_id), 0) AS pregnant_mothers
    FROM core.branch b
    LEFT JOIN report.anc_register poa
        ON poa.branch_id::int = b.id
       AND poa.date_created BETWEEN (SELECT start_date FROM date_range)
                        

refered patient

WITH date_range AS (
    SELECT DATE '2026-08-01' AS start_date,
           DATE '2026-08-31' AS end_date
),

base AS (
    SELECT
        rl.id AS refer_id,
        rl.base_entity_id,
        m.first_name AS patient_name,
        m.patient_phone_number AS mobile_number,
        TRIM(TO_CHAR(rl.date_created, 'Month')) AS month,
        DATE(rl.date_created) AS refer_date,
        rl.date_created,

        CASE
            WHEN rl.provider_id = 'FA_Threads_Palashbari_3' THEN 'Sham

Threads Calculated with refund amonut

WITH
-- ============================================================
-- CHANGE THE REPORT DATE RANGE HERE ONLY -- everything below
-- (Part A and Part B) reads from this single place.
-- ============================================================
date_range AS (
    SELECT
        DATE '2026-06-01' AS start_date,
        DATE '2026-08-31' AS end_date
),

anc_dedup AS (
    SELECT base_entity_id, MIN(date_created) AS anc_date
    FROM report.anc_register
    GROUP BY base_entity_id

Refered and Service Patient Details

WITH
-- ============================================================
-- CHANGE THE REPORT DATE RANGE HERE ONLY -- applies to BOTH
-- the referral side and the service side.
-- ============================================================
date_range AS (
    SELECT DATE '2026-08-01' AS start_date,
           DATE '2026-08-31' AS end_date
),

-- ============================================================
-- REFERRAL SIDE
-- ============================================================

Refered and Service query for email

WITH
date_range AS (
    SELECT DATE '2026-09-01' AS start_date,
           DATE '2026-09-30' AS end_date
),

referral_events AS (
    SELECT
        rl.base_entity_id,
        DATE(rl.date_created) AS refer_date
    FROM report.refer_list rl
    WHERE rl.provider_id IN (
            'FA_Threads_Palashbari_3','FA_Threads_Palashbari_4','FA_Threads_Palashbari_5',
            'FA_Threads_Ashulia_1','FA_Threads_Ashulia_3','FA_Threads_Ashulia_4',
            'FA_Threads_Ashulia_5','FA_Threads_Palashb

1807. Evaluate the Bracket Pairs of a String

You are given a string s that contains some bracket pairs, with each pair containing a non-empty key. For example, in the string "(name)is(age)yearsold", there are two bracket pairs that contain the keys "name" and "age". You know the values of a wide range of keys. This is represented by a 2D string array knowledge where each knowledge[i] = [keyi, valuei] indicates that key keyi has a value of valuei. You are tasked to evaluate all of the bracket pairs. When you evaluate a bracket pair that contains some key keyi, you will: Replace keyi and the bracket pair with the key's corresponding valuei. If you do not know the value of the key, you will replace keyi and the bracket pair with a question mark "?" (without the quotation marks). Each key will appear at most once in your knowledge. There will not be any nested brackets in s. Return the resulting string after evaluating all of the bracket pairs.
/**
 * @param {string} s
 * @param {string[][]} knowledge
 * @return {string}
 */
var evaluate = function(s, knowledge) {
    // Convert knowledge into a Map:
    // [["name", "bob"], ["age", "two"]]
    // becomes:
    // name -> bob
    // age  -> two
    const map = new Map(knowledge);

    const result = [];
    let i = 0;

    while (i < s.length) {

        // If we find an opening bracket,
        // we need to extract the key inside it.
        if (s[i] === "(") {
            let j = i +

Disable Visual Tab Wordpress

add_filter('wp_editor_settings', function ($settings) {
    $settings['quicktags'] = true;
    $settings['tinymce'] = false;
    return $settings;
});

1096. Brace Expansion II

Under the grammar given below, strings can represent a set of lowercase words. Let R(expr) denote the set of words the expression represents. The grammar can best be understood through simple examples: Single letters represent a singleton set containing that word. R("a") = {"a"} R("w") = {"w"} When we take a comma-delimited list of two or more expressions, we take the union of possibilities. R("{a,b,c}") = {"a","b","c"} R("{{a,b},{b,c}}") = {"a","b","c"} (notice the final set only contains each word at most once) When we concatenate two expressions, we take the set of possible concatenations between two words where the first word comes from the first expression and the second word comes from the second expression. R("{a,b}{c,d}") = {"ac","ad","bc","bd"} R("a{b,c}{d,e}f{g,h}") = {"abdfg", "abdfh", "abefg", "abefh", "acdfg", "acdfh", "acefg", "acefh"} Formally, the three rules for our grammar: For every lowercase letter x, we have R(x) = {x}. For expressions e1, e2, ... , ek with k >= 2, we have R({e1, e2, ...}) = R(e1) ∪ R(e2) ∪ ... For expressions e1 and e2, we have R(e1 + e2) = {a + b for (a, b) in R(e1) × R(e2)}, where + denotes concatenation, and × denotes the cartesian product. Given an expression representing a set of words under the given grammar, return the sorted list of words that the expression represents.
/**
 * @param {string} expression
 * @return {string[]}
 */
var braceExpansionII = function(expression) {

    // Helper: concatenates two sets of strings (cartesian product)
    function concat(set1, set2) {
        // If one side is empty, concatenation behaves like the other side
        if (set1.size === 0) return set2;
        if (set2.size === 0) return set1;

        const res = new Set();
        for (let a of set1) {
            for (let b of set2) {
                res.add(a + b); // c

Rename a Branch locally and globally

git checkout x
git branch -m y
git push -u origin y
git push origin --delete x
git fetch --prune

Transfer uncommited changes from one Branch to another

# On branch x
git stash
# Switch to target branch
git checkout y
# Apply saved changes
git stash pop
git add .
git commit -m"x to y"

gistfile1.txt

gist -P