Random snippets of all sorts of code, mixed with a selection of help and advice.
Why does typeOf Null in javascript always return object [duplicate]
16 May 2026 @ 10:42 am
When I try to use typeOf keyword in ES6 javascript, the output is always object. I want to know deeply why does it work in such way. Is it a bug or just a fact in javascritp?
Problem in submitting code to codeforces on linux [closed]
16 May 2026 @ 10:37 am
Can anyone help, M new to codeforces, m trying to submit a solution but cannot ffigure out the problem, on linux if it matters
Laravel cuccos gyakorlas egyebek
16 May 2026 @ 10:10 am
<?php
namespace App\Http\Controllers;
use App\Models\harvest_logs;
use App\Models\harvest_shifts;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
class HarvestLogController extends Controller
{
/**
* Display a listing of harvest logs with user and shift information.
* GET /api/harvest-logs
*/
public function index(): JsonResponse
{
// Lekérjük az összes szüreti naplót a felhasználó és szüreti időszak adataival
$harvestLogs = harvest_logs::with(['user', 'harvestShift'])
->get()
->map(function ($log) {
return [
'id' => $log->id,
'user_id' => $log->user_id,
'harvest_shift_id' => $log->harvest_shift_id,
'datum' => $log->datum,
'kilogram' => $log->kilogram,
'timestamp' => $log->created_at, // Automatikus time
Understanding older Spring Boot REST API style using @Controller + @ResponseBody
16 May 2026 @ 10:02 am
I recently joined a company project built using Spring Boot 2.x.
The project exposes REST APIs, but instead of modern annotations like:
@RestController
@PostMapping
the code uses older style patterns like this:
@ResponseBody
@RequestMapping(value = "/save", method = RequestMethod.POST, produces = "application/json")
public ResponseEntity<String> save(@RequestBody String input) {
JSONObject response = new JSONObject();
try {
JSONObject request = new JSONObject(input);
if (request.isNull("name")) {
return new ResponseEntity<>("Invalid input", HttpStatus.BAD_REQUEST);
}
JSONObject result = service.save(request);
return new ResponseEntity<>(result.toString(), HttpStatus.OK);
} catch (Exception e) {
response.put("message", e.getMessage());
return new ResponseEntity<>(respons
UNEXPECTED: can be ignored when loading from different task/architecture; not ok if you expect identical arch
16 May 2026 @ 10:02 am
Given the following code snippet:
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model_id = "cross-encoder/nli-deberta-v3-large"
model = AutoModelForSequenceClassification.from_pretrained(model_id)
tokenizer = AutoTokenizer.from_pretrained(model_id)
model.to(device)
I get the following warning:
DebertaV2ForSequenceClassification LOAD REPORT from: cross-encoder/nli-deberta-v3-large
Key | Status | Details
--------------------------------+------------+--------
deberta.embeddings.position_ids | UNEXPECTED |
Notes:
- UNEXPECTED: can be ignored when loading from different task/architecture; not ok if you expect identical arch.
$ pip show transformers
Name: transformers
Version: 5.5.3
Summary: Transformers: the model-definition framework
"name 'T' is not defined" when evaluating annotations on inherited methods using Python 3.12+ type parameter syntax
16 May 2026 @ 9:54 am
I am upgrading a codebase to Python 3.12 and migrating our generic classes to use the new PEP 695 syntax, e.g.:
class Box[T]:
...
instead of:
T = TypeVar('T')
class Box(Generic[T]):
...
Most of it works, but I’ve hit a NameError when attempting to dynamically inspect type hints on a subclass method if that method was wrapped by a custom decorator in the parent class:
from functools import wraps
import typing
# A standard route/event tracking decorator that preserves annotations
def track_event(func):
@wraps(func)
def wrapper(*args, **kwargs):
return func(*args, **kwargs)
# We explicitly sync annotations for an external API generator tool
wrapper.__annotations__ = func.__annotations__
return wrapper
# Parent generic class using Python 3.12+ syntax
class BaseService[T]:
@track_e
WhatsApp Embedded Signup — Tech Provider option missing in Business Manager despite meeting eligibility [closed]
16 May 2026 @ 9:49 am
I'm building a WhatsApp Coexistence integration using the Embedded Signup flow. According to the official docs, a Tech Provider must meet certain thresholds before the onboarding option appears.
My setup:
Embedded Signup implemented and working
WABA connected via Cloud API
Business verified on Meta
The problem:
Even after meeting the documented eligibility criteria, the Tech Provider option does not appear in Business Manager or WhatsApp Manager.
Specific technical questions:
Is there an API endpoint to check Tech Provider eligibility status programmatically?
Does the whatsapp_business_messaging permission need a specific app review approval to unlock this?
Is the Tech Provider UI flag enabled server-side by Meta, or is it tied to a specific app/permission scope?
I've already checked app review status, business portfolio permissions, and embedded signup configuration. Looking for anyone who has debugged this at the API/permission level.
diff v3.12: option --from-file seems to be buggy
16 May 2026 @ 9:30 am
I found an issue with diff v3.12 and option --from-file, system OpenSUSE tumbleweed.
If I use command diff FILE1 FILE2 FILE3 --from-file OTHER-DIR/ (with and without trailing slash), only FILE1 is compared. For the other files I get the message: "diff: OTHER-DIR: No such file or directory". All files exist! If I remove FILE1 from the source list, only FILE2 is compared.
At an old system, this commands works perfect. I use this type of command for decades and had never such issues.
Can you confirm this bug?
Some test code:
# create files
mkdir -p other-dir
for f in {,other-dir/}file{1,2,3}.tmp; do echo "$f" > "$f"; done
# test
diff file{1,2,3}.tmp --from-file other-dir/
diff file{1,2,3}.tmp --to-file other-dir/
# cleanup
rm -r file{1,2,3}.tmp other-dir/
What is the deal with CA1070 "Do not declare event fields as virtual"?
16 May 2026 @ 8:59 am
The official documentation for DotNet Code Analysis Rule CA1070 "Do not declare event fields as virtual" says:
Do not declare virtual events in a base class. Overridden events in a derived class have undefined behavior. The C# compiler does not handle this correctly and it is unpredictable whether a subscriber to the derived event will actually be subscribing to the base class event.
Huh?
The official C# programming guide corroborates this, using very similar wording:
Do not declare virtual events in a base class and override them in a derived class. The C# compiler does not handle these correc
AVR gcc creates intermediate counting variable when not needed
16 May 2026 @ 7:36 am
I am facing an optimisation issue with avr-gcc 14.2 on debian.
I have the following code (I have shortened the code and immediate assembler for better overview):
void function(uint8_t byte){
cli();
uint8_t bit = 0x01;
while (1) {
// for (uint8_t bit = 0x01; bit != 0; bit <<=1) {
if (byte & bit) { // Write high
// do something not using byte or bit variables
} else { // Write low
// do something else not using byte or bit variables
}
bit = bit << 1;
if (bit == 0)
break;
}
sei();
}
The immediate assembler that is being generated by avr gcc (from output.elf.ltrans0.ltrans.s):
cli
; 0 "" 2
/* #NOAPP */
ldi r18,lo8(8) ; ivtmp_65,
ldi r19,0 ; ivtmp_65
; routine.c:93: uint8_t bit = 0x01;
ldi r25,lo8(1) ; bit,
.L42:
;removed code prior to if related to what happens