postgres_learning

https://www.depesz.com/
check this site for first and last

3223. Minimum Length of String After Operations

You are given a string s. You can perform the following process on s any number of times: Choose an index i in the string such that there is at least one character to the left of index i that is equal to s[i], and at least one character to the right that is also equal to s[i]. Delete the closest character to the left of index i that is equal to s[i]. Delete the closest character to the right of index i that is equal to s[i]. Return the minimum length of the final string s that you can achieve.
/**
 * @param {string} s
 * @return {number}
 */
var minimumLength = function(s) {
     // Create an object to count the frequency of each character in the string
    const charObj = {};

    // Iterate through each character in the string
    for (let i = 0; i < s.length; i++) {
        // If the character exists in the object, increment its count, otherwise set it to 1
        charObj[s[i]] = (charObj[s[i]] || 0) + 1;
    }

    // Initialize the answer to 0
    let answer = 0;

    // Iterate

SET default filter

oninit: function () {
    // set default filter on init
    var orderStatus = SSIurlModul.getKey('ORDST');
    if (!orderStatus) {
        SSIurlModul.set("ORDST", "15,17,20,21,30,31,35,40,41,42,43");
    };
},
oncomplete: function () {
  // re-init filter to set default values
    SSI.portal.init();
    //this.load();
    //this.loadStats();
},

vscode task "Delete pycache folders"

{
    "label": "Delete __pycache__ folders",
    "type": "shell",
    "command": "find . -type d -name '__pycache__' -exec rm -r {} +",
    "problemMatcher": []
}

hash_abt.md


# ABT

Think of an ABT as a way to represent code or expressions with variables and bindings (like let x = 5 in x + 2). 

The main functions are hash and hashComponents. hash takes a single ABT as input and produces a Hash as output. This Hash is like a fingerprint of the ABT. hashComponents is designed for situations where you have multiple ABTs that might reference each other (like function definitions in a program). It takes a map of names (like function names) to their corresponding ABTs, a

https://mk.bcgsc.ca/brewer/swatches/brewer.txt

https://mk.bcgsc.ca/brewer/swatches/brewer.txt
# Colors from www.ColorBrewer.org by Cynthia A. Brewer, 
# Geography, Pennsylvania State University. See BREWER for license. 
# See www.colorbrewer.org for details.
# 
# Color names are PALETTE-NUMCOLORS-TYPE-IDX (e.g. reds-3-seq-1)
#
#  PALETTE   palette name (e.g. reds)
#  NUMCOLORS number of colors in the palette (e.g. 3)
#  TYPE      palette type (div, seq, qual)
#  IDX       color index within the palette (e.g. 1)
#
# Another version of the color index is defined where COLORCODE is the
# co

2116. Check if a Parentheses String Can Be Valid

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 a parentheses string s and a string locked, both of length n. locked is a binary string consisting only of '0's and '1's. For each index i of locked, If locked[i] is '1', you cannot change s[i]. But if locked[i] is '0', you can change s[i] to either '(' or ')'. Return true if you can make s a valid parentheses string. Otherwise, return false.
/**
 * @param {string} s
 * @param {string} locked
 * @return {boolean}
 */
var canBeValid = function(s, locked) {
     const n = s.length;
    if (n % 2 !== 0) return false; // If the length of s is odd, it's impossible to balance

    let openCount = 0;
    let flexibleCount = 0;

    // Forward pass
    for (let i = 0; i < n; i++) {
        if (locked[i] === '0') {
            flexibleCount++; // Count positions that can be changed
        } else if (s[i] === '(') {
            openCount++; /

Toggle Between Archive Folders - Outlook

Sub ToggleBetweenMainMailboxAndArchive()
    Dim OutlookApp As Outlook.Application
    Dim ns As Outlook.NameSpace
    Dim CurrentFolder As Outlook.Folder
    Dim ArchiveRoot As Outlook.Folder
    Dim MainMailboxRoot As Outlook.Folder
    Dim TargetFolder As Outlook.Folder
    Dim ArchiveEntryID As String
    Dim MainMailboxEntryID As String
    
    ' Initialize Outlook application and namespace
    Set OutlookApp = Application
    Set ns = OutlookApp.GetNamespace("MAPI")
    Set C

PYODBC - Full process

Here's an example of full process to connect to a cloud-hosted database.

# 1. Install the required dependencies
Let me walk you through the installation process on an Ubuntu-based system in a comprehensive way.

On a Linux system, installing `pyodbc` requires both:
- **Python package management** and 
- **system-level dependencies**. 

Let's go through this step-by-step:

## 1.1. First, let's install the system-level ODBC dependencies. 

These are fundamental components that `pyodbc` needs to c

change style from useState in scss without using inline styles

const elementRef = useRef(null);

useEffect(() => {
  if (elementRef.current) {
    elementRef.current.style.setProperty("--dynamic-color", color);
  }
}, [color]);

return (
  <div ref={elementRef} className="card">
    ...
  </div>
);

Writing Task 1 #1

### **Introduction Phrases**
- The bar graph illustrates the proportion of residents in five Australian cities...
- The chart provides information about...
- The graph shows data on...
- The diagram highlights...
- The figure compares the percentages of...
- The given bar graph illustrates...

### **Overview Phrases**
- Overall, visiting cafés is the most popular activity...
- In general, it can be observed that...
- A clear trend is that...
- The most noticeable feature is that...
- It is evide

Write Task 2 #1

### **Introduction Phrases**  
1. In many parts of the world, people view...
2. This trend reflects...
3. While this preference has its benefits, it also brings challenges...
4. There are various reasons behind this phenomenon, which will be explored in this essay.  
5. This essay will discuss both the causes and implications of this trend.

---

### **Body Paragraph 1 - Presenting Reasons**  
1. One key reason for... is...
2. This is because...
3. In many cultures, [X] is perceived as...
4. Thi

1400. Construct K Palindrome Strings

Given a string s and an integer k, return true if you can use all the characters in s to construct k palindrome strings or false otherwise.
/**
 * @param {string} s
 * @param {number} k
 * @return {boolean}
 */
var canConstruct = function(s, k) {
    // If k is greater than the length of the string, it's impossible to create k palindromes
    if (k > s.length) {
        return false;
    }

    // Create a frequency map to count occurrences of each character
    const charCount = {};
    for (let char of s) {
        charCount[char] = (charCount[char] || 0) + 1;
    }

    // Count how many characters have an odd frequency
    let o

enc

openssl enc -aes-256-cbc -salt -in $(ls -t | head -n 1) -out mongo.enc -pass pass:"YourStrongPassword"
openssl enc -aes-256-cbc -d -in mongo.enc -out mongo.tar.gz -pass pass:"YourStrongPassword"

megatools put $(ls -t | head -n 1) --username hsunnysingh8@gmail.com --password 'Jo^mQ2hBqKwGl!rG'
megatools get /Root/mongo.enc --username hsunnysingh8@gmail.com --password 'Jo^mQ2hBqKwGl!rG'

Apache redirect loop behind a reverse proxy

https://www.reddit.com/r/selfhosted/comments/1gskh05/redirect_loop_apache_behind_reverse_proxy/?tl=fr

Some apache2 cmd

- List Apache vhosts

`$a2query -s`

- List Apache conf

apache2ctl -S