20. Valid Parentheses

Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Every close bracket has a corresponding open bracket of the same type.
/**
 * @param {string} s
 * @return {boolean}
 */
var isValid = function(s) {
    const stack = [];

    // Maps each closing bracket to its matching opening bracket
    const pairs = {
        ')': '(',
        '}': '{',
        ']': '['
    };

    for (const char of s) {
        // Opening bracket: save it for a future match
        if (!(char in pairs)) {
            stack.push(char);
        } else {
            // Closing bracket: must match the most recent opening bracket
            if (

ADMIN > Modifications for 'Subscriber' role || Series CPT content

add_action( 'admin_init', 'redirect_based_on_user_role', 100 );
function redirect_based_on_user_role() {
	if ( current_user_can( 'subscriber' ) ) {
		if (is_admin() AND !wp_doing_ajax()) {
			wp_redirect('/partner-portal/');
			exit;
		}
		/***
		 * CURRENTLY only the above code is being used
		 * The rest below will not be used as we are not allowing wp-admin access
		 * BUT is here for reference...
		 */
		
	}
}


add_action( 'template_redirect', function() {

	if ( is_user_

Get ACF repeater row number

add_shortcode('acf_row_number', function() {
    if ( function_exists('get_row_index') ) {
        return get_row_index(); // Returns 1, 2, 3...
    }
    return '';
});

FRONTEND > disable WordPress search queries and block the search results archive page

/**
 * Disable and block WordPress search queries and the search results archive.
 */
function disable_and_block_wp_search( $query, $error = true ) {
    if ( is_search() && ! is_admin() ) {
        $query->is_search = false;
        $query->query_vars['s'] = false;
        $query->query['s'] = false;
        
        // Block the archive and force a 404 Not Found error
        if ( $error == true ) {
            $query->is_404 = true;
            global $wp_query;
            $wp_q

threads calculated with patient number

WITH
-- ============================================================
-- CHANGE THE REPORT DATE RANGE HERE ONLY
-- ============================================================
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

Link to Next Pagination

<?php
if ( get_previous_posts_link() ) :
    previous_posts_link( 'PREV' );
endif;
?>


<?php 
if ( get_next_posts_link() ) :
    next_posts_link( 'NEXT' ); 
endif; 
?>

Martians log

## View log via dmesg
```bash
dmesg | grep -i martian
```
or 
```bash
dmesg | grep -i rpfilter
```

## View log via journalctl
```bash
journalctl -k | grep -i martian
```
or 
```bash
journalctl -k | grep -i rpfilter
```
## Read log REALTIME
```bash
journalctl -kf | grep -i martian
```
or 
```bash
dmesg -w | grep -i martian
```

Navigation breakpoints for WP Block Theme

From Jakson's Youtube video - https://youtu.be/1M2g4e9vq4w?si=pV5ESugkGk0QrMN_
/* -- Navigation breakpoints -- */
/* 1. Global / Mobile State: Force the hamburger menu by default */
body .wp-block-navigation__responsive-container-open:not(.always-shown) {
	display: block !important;
}
body .wp-block-navigation__responsive-container:not(.hidden-by-default):not(.is-menu-open) {
	display: none !important;
}

/* .wp-block-navigation:not(.has-background) .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay) {
    background-color: var(--wp--prese

1111. Maximum Nesting Depth of Two Valid Parentheses Strings

A string is a valid parentheses string (denoted VPS) if and only if it consists of "(" and ")" characters only, and: It is the empty string, or It can be written as AB (A concatenated with B), where A and B are VPS's, or It can be written as (A), where A is a VPS. We can similarly define the nesting depth depth(S) of any VPS S as follows: depth("") = 0 depth(A + B) = max(depth(A), depth(B)), where A and B are VPS's depth("(" + A + ")") = 1 + depth(A), where A is a VPS. For example, "", "()()", and "()(()())" are VPS's (with nesting depths 0, 1, and 2), and ")(" and "(()" are not VPS's. Given a VPS seq, split it into two disjoint subsequences A and B, such that A and B are VPS's (and A.length + B.length = seq.length). The subsequences may not necessarily be contiguous. For example, for the sequence 123456789, one possible split is: A = {1, 3, 5, 7, 9}, B = {2, 4, 6, 8}. This corresponds to the output [0, 1, 0, 1, 0, 1, 0, 1, 0] where 0 indicates membership in A and 1 indicates membership in B. Now choose any such A and B such that max(depth(A), depth(B)) is the minimum possible value. Return an answer array (of length seq.length) that encodes such a choice of A and B: answer[i] = 0 if seq[i] is part of A, else answer[i] = 1. Note that even though multiple answers may exist, you may return any of them.
/**
 * @param {string} seq
 * @return {number[]}
 */
var maxDepthAfterSplit = function(seq) {
    const ans = [];
    let depth = 0;

    for (const ch of seq) {
        if (ch === '(') {
            // Enter the next nesting level.
            depth++;

            // Alternate levels between A (0) and B (1).
            ans.push(depth % 2);
        } else {
            // Matching ')' belongs to the same group
            // as its corresponding '('.
            ans.push(depth % 2);

         

Bankstatements Knowledge

What are the steps:


Parser formats:
  gts rejections: 
    Leasing: 
      camt 053.001.08
      camt 054.001.02 file is just archived! So the "process" method just returns mono.empty.
    Financing:
      camt 053.001.08
      NO camt54!
  
  gts self-payer:
    Leasing and Financing: camt 053.001.08
    
  gts handling MT940
    Leasing:
      no parsing. Check if not xml, then assume it is MT940. Routing to DIRECT_GTS_TO_ALFA_ROUTE
  
  gps rejections:
    Leasing:
      pain00200103
    Fi

Returns boolean True/False of an environment variable (to be used in settings.py)

def env_to_bool(name, default=False):
    # returns boolean True/False of an environment variable
    # usage examples:
    #   env_to_bool("DEBUG")
    #   env_to_bool("DEBUG", default=True)
    # consider adding more options, like "on", "enabled", "y" etc.
    return os.environ.get(name, str(default)).strip().lower() in (
        "true", "yes", "1"
    )

2267. Check if There Is a Valid Parentheses String Path

A parentheses string is a non-empty string consisting only of '(' and ')'. It is valid if any of the following conditions is true: It is (). It can be written as AB (A concatenated with B), where A and B are valid parentheses strings. It can be written as (A), where A is a valid parentheses string. You are given an m x n matrix of parentheses grid. A valid parentheses string path in the grid is a path satisfying all of the following conditions: The path starts from the upper left cell (0, 0). The path ends at the bottom-right cell (m - 1, n - 1). The path only ever moves down or right. The resulting parentheses string formed by the path is valid. Return true if there exists a valid parentheses string path in the grid. Otherwise, return false.
/**
 * @param {character[][]} grid
 * @return {boolean}
 */
var hasValidPath = function(grid) {
    const m = grid.length;
    const n = grid[0].length;
    
    // 1. Quick initial checks
    if ((m + n - 1) % 2 !== 0) return false;
    if (grid[0][0] === ')' || grid[m - 1][n - 1] === '(') return false;
    
    // Max possible balance k cannot exceed (m + n) / 2
    const maxK = Math.floor((m + n) / 2) + 1;
    
    // Memoization table: memo[i][j][k] initialized to -1
    const memo = Array.f

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