3066. Minimum Operations to Exceed Threshold Value II

You are given a 0-indexed integer array nums, and an integer k. You are allowed to perform some operations on nums, where in a single operation, you can: Select the two smallest integers x and y from nums. Remove x and y from nums. Insert (min(x, y) * 2 + max(x, y)) at any position in the array. Note that you can only apply the described operation if nums contains at least two elements. Return the minimum number of operations needed so that all elements of the array are greater than or equal to k.
/**
 * @param {number[]} nums
 * @param {number} k
 * @return {number}
 */
var minOperations = function(nums, k) {
     let queue = [], ans = 0, i = 0;

    // Sort nums in descending order
    nums.sort((a, b) => b - a);

    // Process nums and queue until both are empty
    while(nums.length + queue.length > 0){
        let x = 0, y = 0;

        // Check if the smallest elements in nums and queue are both >= k
        if((!nums[nums.length -1 ] || nums[nums.length - 1] >= k) && (!queue[i] ||

read entire text file

// to a single String
File("path/to/file")
  .bufferedReader().use { it.readText() }

// to a List<String>
File("path/to/file")
  .bufferedReader().use { it.readText() }.lines()

write text file

// val writer: BufferedWriter =
//    File("path/to/file").bufferedWriter

File("path/to/file").writeText("text to write")

File("path/to/file").appendText("text to append")

read file line by line

val reader: BufferedReader =
    File("path/to/file").bufferedReader

val reader: BufferedReader =
    BufferedReader(
        InputStreamReader(
            resources.openRawResource(R.raw.z_frases_1_e_2_shuf_1000)
        )
    )
var line = reader.readLine();
while (line != null) {
    phrases.add(line)
    line = reader.readLine();
}
reader.close()

read assets text file from assets dir

package com.example.artspace

private var phrases = mutableListOf<String>()

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
\!h        // must be called from here, within fun onCreate
\!h        readAssetsOrRaw()
        //...
    }
    
\!h    // must create assets dir under app/sr/main (sibling of java and res)
\!h    // and place files there

    private fun readAssetsOrRaw() {
\!h       phrases = 

app icon dimensions

Square 512x512 px
Round inside: 330x330 px

list files in assets dir

package com.example.artspace

private var phrases = mutableListOf<String>()

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
\!h        // must be called from here, within fun onCreate
\!h        readAssetsOrRaw()
        //...
    }
    
\!h    // must create assets dir under app/sr/main (sibling of java and res)
\!h    // and place files there

    private fun readAssetsOrRaw() {
\!h        val asset

read resources text file from res/raw

package com.example.artspace

private var phrases = mutableListOf<String>()

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        readAssetsOrRaw()
        //...
    }

    private fun readAssetsOrRaw() {
\!h       phrases = resources.openRawResource(R.raw.z_frases_1_e_2_shuf_1000)
\!h                    .bufferedReader().use { it.readText() }.lines().toMutableList()
    }
}

Detect when image is done loading

useful for firing a loading animation during the loading time of an image
// image 
$(this).parents('li.single-product').addClass('changing');

$(this).parents('li.single-product').find('.variant-image').attr('src', imgResult.src);
document.querySelector('li.single-product.changing .variant-image').onload = function() {
   // console.log('locked and loaded')
   $(this).parents('li.single-product').removeClass('changing')
} 

FTP to S3 File Sorting

import boto3
import os
import re
import time

s3_client = boto3.client('s3')

# Define the required order of files for processing
FILE_ORDER = ['PLACEMENT', 'UPDATE', 'RECALL', 'RECON']

def extract_timestamp(filename):
  '''
  Extracts the file type and timestamp from the given filename.

  Expected file format:
    UTHDEpicHealthBridge_ACCOUNT_<FILE_TYPE>_<TIMESTAMP>.txt

  Example:
    Filename: UTHDEpicHealthBridge_ACCOUNT_PLACEMENT_202502121234.txt
    Extracted: ('PLACEMENT', '202502121234

パララックス 上からめくれる下からめくれるを制御する

<div class="section" style="background-color: orange">
  <p class="text">sec<br />tion1</p>
</div>
<div class="container">
  <div class="section -has-bottom">
    <div class="top">
      <p class="text">sec<br />tion2</p>
    </div>
    <div class="bottom"><p class="text">bottom</p></div>
  </div>
</div>
<div class="end" style="background-color: orange">
  <p class="text">end</p>
</div>
<div class="end" style="background-color: orange">
  <p class="text">end</p>
</div>
<div class="end" style="ba

choose nvidia driver

ubuntu-drivers list;
sudo ubuntu-drivers install;
# install a specific version from the list:
sudo ubuntu-drivers install nvidia:535;

format fix

import xml.etree.ElementTree as ET


class FixProtocolParser:
    def __init__(self, dictionary_file):
        self.fields = {}  # Holds field definitions from the FIX dictionary
        self.groups = {}  # Holds group definitions for repeated fields
        self.enums = {}  # Holds enum lookups for fields

        # Parse the dictionary XML file
        self.parse_dictionary(dictionary_file)

    def parse_dictionary(self, dictionary_file):
        tree = ET.parse(dictionary_file)

cssで旗

<div class="flag-container">
  <div class="flag" style="--index: 1"></div>
  <div class="flag" style="--index: 2"></div>
  <div class="flag" style="--index: 3"></div>
  <div class="flag" style="--index: 4"></div>
  <div class="flag" style="--index: 5"></div>
  <div class="flag" style="--index: 6"></div>
  <div class="flag" style="--index: 7"></div>
  <div class="flag" style="--index: 8"></div>
  <div class="flag" style="--index: 9"></div>
  <div class="flag" style="--index: 10"></div>
  <div cla

detailsとsummaryのアニメーションを:openで行う

<details>
  <summary>Summary</summary>
  <p>テキスト</p>
  <p>テキスト</p>
</details>

Converter String em boolean

ActiveModel::Type::Boolean.new.cast("true")