1352. Product of the Last K Numbers

Design an algorithm that accepts a stream of integers and retrieves the product of the last k integers of the stream. Implement the ProductOfNumbers class: ProductOfNumbers() Initializes the object with an empty stream. void add(int num) Appends the integer num to the stream. int getProduct(int k) Returns the product of the last k numbers in the current list. You can assume that always the current list has at least k numbers. The test cases are generated so that, at any time, the product of any contiguous sequence of numbers will fit into a single 32-bit integer without overflowing.

var ProductOfNumbers = function() {
    // Initialize an array to store the prefix products
    this.prefixProduct = [1]; // Start with 1 to handle the empty product case
};

/** 
 * @param {number} num
 * @return {void}
 */
ProductOfNumbers.prototype.add = function(num) {
    if (num === 0) {
        // If a zero is encountered, reset the prefix product array
        this.prefixProduct = [1];
    } else {
        // Append the product of the last element and the new number
        this.prefixP

load an icon from bitmap image resource

// https://medium.com/@ramadan123sayed/comprehensive-guide-to-utilizing-icons-and-images-in-jetpack-compose-with-coil-7fd2686e491e

@Composable
fun TransformedIconDisplayBitmap() {
    Icon(
        bitmap = ImageBitmap.imageResource(R.drawable.baseline_access_alarm_24),
        contentDescription = "Alarm Icon",
        tint = Color.Blue,
        modifier = Modifier
            .size(40.dp)
            .rotate(0f) // The icon remains in its original orientation.
            .scale(3f)  // The i

selectにスタイルをあてる(chrome134以降)

<select>
  <button>
    <selectedcontent></selectedcontent>
  </button>
  <div class="option-wrapper">
    <option value="1">
      <div class="option-container">item1</div>
    </option>
    <option value="2">
      <div class="option-container">item2</div>
    </option>
    <option value="3">
      <div class="option-container">item3</div>
    </option>
  </div>
</select>

typeがdateのカレンダーアイコンのcursorをpointerにする

input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
}

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;