Random snippets of all sorts of code, mixed with a selection of help and advice.
Azure SQL Database DTU tier change billed for more than 24 hours — how is this calculated?
10 July 2025 @ 12:13 pm
I'm currently reviewing billing details for an Azure SQL Database configured with the DTU-based pricing model.
On several days, I noticed the total billed hours exceeded 24h, even though the database was running continuously. For example, on April 1st, a single database with multiple tier changes (S9 → S7 → S4) was billed for a total of 26.02 hours in a single calendar day.
Here's a simplified breakdown:
Tier Cost (€) Price/hour (€) Estimated billed hours
S9 35.85 2.7554 13.01 h
S7 5.98 1.3777 4.34 h
S4 2.61 0.3445 7.59 h
Total = 24.94 h
At first, I expected Azure to apply hourly rounding per tier like it does for VMs, where any activity (even 5 minutes) results in a full hour charged. But it seems Azure SQL uses fractional hour billing for DTU tier switches, and does not round to the nearest hour.
This behavior isn't clearly documented in Microsoft's official pricing pages.
My questions:
Is this behavior offici
JPEG XS encoder fails to process 4:2:0 10-bit YUV with lossless compression
10 July 2025 @ 12:12 pm
I am trying to losslessly compress a raw YUV file using a JPEG XS encoder, but I'm encountering two main problems.
My Environment:
Encoder: JPEG XS test model (XSM) version 2.0.2-ED2
Input File: Raw YUV video frame
Chroma Subsampling: 4:2:0
Bit Depth: 10-bit (Little Endian)
Resolution: 832x480 (I have also tested with smaller resolutions like 64x64 with the same result)
The Problems:
Incorrect Profile Forcing: The encoder seems to ignore the 4:2:0 nature of my input. The only way I can get it to produce any output is by specifying a 4:2:2 profile, like main422.10. This is fundamentally incorrect for my source file.
Lossless Encoding Failure: My primary requirement is lossless compression. When I add the parameter for lossless encoding (rl=1), the process fails immediately. The error is Unable to allocate encoding context. This happens regardless of the image resolution.
My Question:
How can I correctly encode my 4:2:0 10-bit YUV file in a lossless format?
Pair the iOS Application with Mac Application using WiFi pairing its not working when using Bonjour Services
10 July 2025 @ 12:11 pm
I'm working on an Objective-C project that uses the MYNetwork framework for connection and pairing.
https://github.com/snej/MYNetwork?tab=readme-ov-file
The framework works fine on iOS 16 with Xcode 14, and pairing functions as expected in that environment.
However, when I run the same project on the latest iOS version and Xcode, the pairing no longer works. There are no crashes, but the expected connection and Bonjour service behavior isn't happening.
Can someone please help me identify what might be causing the issue on the newer OS/Xcode versions and how to fix it?
Thanks in advance!
Set color scheme for each chart in column layout individually
10 July 2025 @ 12:11 pm
Consider the following example of a bar plot in horizontal layout. In each chart the y and color channels both encode column "y" of df.
import altair as alt
import numpy as np
import polars as pl
N = 20
df = pl.DataFrame({
'x': np.repeat(range(N), 2),
'y': np.random.randint(0, 100, 2*N),
'class': np.tile(["A", "B"], N)
})
alt.Chart(df).mark_bar().encode(
x='x',
y='y',
column='class',
color=alt.Color('y', scale=alt.Scale(scheme='greens'))
)
How do I set the color scheme individually for each chart? Spltting the whole thing in two seperate charts does not work:
a1 = (alt.Chart(df.filter(pl.col('class')=="A"))
.mark_bar()
.encode(x='x', y='y', color=alt.Color('y', scale=alt.Scale(scheme="greens"))))
a2 = (alt.Chart(df.filter(pl.col('class')=="B"))
.mark_bar()
.encode(x='x', y='y', color=alt.Color(
Building flutter app with local engine build failed
10 July 2025 @ 12:09 pm
Execution failed for task ':app:checkReleaseAarMetadata'.
Could not resolve all files for configuration ':app:releaseRuntimeClasspath'.
Could not resolve io.flutter:arm64_v8a_release:+.
Required by:
project :app
> Failed to list versions for io.flutter:arm64_v8a_release.
> Unable to load Maven meta-data from https://dl.google.com/dl/android/maven2/io/flutter/arm64_v8a_release/maven-metadata.xml.
> Could not GET 'https://dl.google.com/dl/android/maven2/io/flutter/arm64_v8a_release/maven-metadata.xml'.
> Connect to dl.google.com:443 [dl.google.com/114.250.65.33] failed: Connect timed out
I want to use my local built engine(with flutter sdk changed),I configured the mirror source in gradle, but it seems that it will eventually go to Google source or even jcenter. Where is the source reposit
Why is "with torch.cuda.stream()" not asynchronous?
10 July 2025 @ 12:00 pm
Cause
I'm trying to achieve the overlap between the forward and backward passes of two model chunks in dualpipe. I plan to simply implement it using torch.cuda.stream first, as follows:
def overlapped_forward_backward(
module0: torch.nn.Module,
inputs0: List[torch.Tensor],
labels0: Optional[List[torch.Tensor]],
loss_masks0: Optional[List[torch.Tensor]],
loss1: Optional[torch.Tensor],
outputs1: Optional[List[torch.Tensor]],
output_grads1: Optional[List[torch.Tensor]],
forward_step_func: Callable,
is_last_stage0: bool,
) -> tuple[torch.Tensor, Optional[torch.Tensor]]:
"""
You should implement custom forward-backward overlap strategy.
The code below is just an example.
"""
device = inputs0[0].device
if not hasattr(overlapped_forward_backward, 'backward_streams'):
overlapped_forward_backward.backward_streams = {}
if device not in overlapped_forward_backward.ba
Sending emails from the Linux terminal while preserving the fact of sending, but without attachments
10 July 2025 @ 11:59 am
I need to send a letter from Linux terminal to the recipient's mailing address from the terminal. I want the fact of sending the letter, its title and its text to be saved in the sent section of my mailbox (the mailbox is administered by another company). The attachments that I will be sending take up quite a lot of space and I would like them not to be saved on the mail server. It would be great if I didn't have to click to send them as in the script below.
Here is my previous solution, this method saves the attachments and forces me to click.
thunderbird -compose to="${mails}" ,subject="${sub}" ,body="${text}" ,attachment="'${attach},${letter}'";
Bot translator in discord
10 July 2025 @ 11:56 am
I was trying to create a bot in discord that would perform the function of double translation in voice channels, this code is written through the deepseek neural network. I ran into such a problem that when downloading discord.py [voice] discord is not installed.sinks, without which, as I understand it, work is not possible, I cannot find this library separately. And if possible, write down what can be added, corrected, and how best to do it.
import os
import asyncio
import discord
from discord.ext import commands
from discord.sinks import MP3Sink # Импорт из стандартной библиотеки
from transformers import (
WhisperForConditionalGeneration,
WhisperProcessor,
AutoTokenizer,
AutoModelForSeq2SeqLM
)
from gtts import gTTS
from io import BytesIO
import logging
# Настройка логирования
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# Конфигурация (замените н
How to stop reload page in browser to generate random data in Axios and Express?
10 July 2025 @ 11:55 am
I have a button in the EJS file that would generate random data from a selected API link. The problem is that whenever I press refresh the page to return to the original state (not generating anything), it just keeps generating random data despite not being pressed by the button. So far, I haven't tried anything because there was no error, so I don't know what I did wrong. How to stop refresh page in the browser to generate random data?
Here is my index.js file code:
import express from "express";
import axios from "axios";
const app = express();
app.set("view engine", "ejs");
const port = 3000;
const API_URL = "http://www.thecocktaildb.com/api/json/v1/1/random.php";
// const apiKey = "1";
app.use(express.static("public"));
app.get("/", (req, res) => {
res.render("index.ejs");
})
app.post("/", async (req, res) => {
try{
const result = a
DEG analysis in R
10 July 2025 @ 11:54 am
I want to download the GSE203206 Alzheimer's dataset from the GEO website using the R GEOquery package. I want to perform PCA on the raw count with ggplot. Then, I want to perform normalization and DEG analysis with the DESeq2 package. Meanwhile, I want to control rows with 0 gene count and NA values and rows with very low gene counts, delete rows with 0 and NA values, and use the group_by function in tidyverse to filtrate rows with low counts.
I tried this code but I could not get a clear output, could you help me ?
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install(c("GEOquery", "DESeq2", "AnnotationDbi", "org.Hs.eg.db"), ask = FALSE)
install.packages(c("tidyverse", "ggplot2", "pheatmap", "data.table"), dependencies = TRUE)
library(GEOquery)
library(DESeq2)
library(tidyverse)
library(ggplot2)
lib