Random snippets of all sorts of code, mixed with a selection of help and advice.
Why it returns garbage value
21 December 2024 @ 10:06 am
I have a very simple custom error_category like below. I just want it to be encapsulated with "exception". Therefore I wrote a custom exception class for it. But when I run the code, I get garbage values(I get different values every time I run it.). Since the error code is defined globally in the exception class, there should not be a problem. What is the reason for this?
#include <string>
#include <system_error>
#include <iostream>
#include <stdexcept>
enum class FlightsErrc {
// no 0
NonexistentLocations = 10, // requested airport doesn't exist
DatesInThePast, // booking flight for yesterday
InvertedDates, // returning before departure
NoFlightsFound = 20, // did not find any combination
ProtocolViolation = 30, // e.g., bad XML
ConnectionError, // could not connect to server
ResourceError, // service run short of resources
Timeout, // d
java.lang.ExceptionInInitializerError: Please Call PESDK.init() in Application onCreate - How to Fix?
21 December 2024 @ 10:03 am
I'm facing a crash in my Android app using the Video SDK (VESDK). The error occurs when launching an activity that extends ImgLyActivity. Below is the stack trace:
at ly.img.android.pesdk.ui.activity.ImgLyActivity.setTheme(ImgLyActivity.java:153)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4129)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4322)
...
Caused by java.lang.RuntimeException: Please Call PESDK.init() in Application onCreate
at ly.img.android.e.b(:9)
at ly.img.android.PESDK.getAppContext()
...
The issue seems to be related to the PESDK.init() method not being called during app initialization. I have tried the following:
Adding PESDK.init(this) in the onCreate method of my Application class.
Ensuring the Application class is correctly declared in the AndroidManifest.xml.
However, the crash still occurs.
My Que
Does Intel SGX SDK check invalid memory access from untrusted app to enclave in simulation mode? If not, any alternative method to check?
21 December 2024 @ 10:03 am
I saw this answer to a similar question.
However, I am still wondering if the SDK in simulation mode will recognize invalid access from untrusted app to the enclave memory and report such an incident.
It would be frustrating if the simulation mode works ok, but the code actually cannot run on SGX-supported hardware, because of mistakenly implemented invalid access from untrusted code to enclave memory.
I encounter this confusion when implementing some simple data access ocalls.
The ocall in EDL file:
void ocall_get_data3([user_check]unsigned char** data_buffer, size_t data_size, uint64_t pk);
The handling code in untrusted app:
void ocall_get_data3(unsigned char** data_buffer, size_t data_size, uint64_t pk) {
printf("ptr %p %p\n", data_buffer, *data_buffer);
*data_buffer = data_map[pk];
printf("ptr %p %p\n", data_buffer, *dat
Neural Network - Image Classification: from single to multi-modal data
21 December 2024 @ 10:03 am
this is my first post so don't hesitate to tell me if I did sth wrong.
I am currently working on a DL solution to classify aerial images of roofs between 6 categories of vegetated rooftops.
The images, once preprocessed, are 6 layers thick: NIR, R, G, B, NDVI, LUMINOSITY
Until now, I have only been extracting information from the image itself, using the following pipeline:
enter image description here
The pipeline is made of 3 blocks:
A backbone, made of a serie of convolutional layers and maxpools
The Atrous Spatial Pyramid Pooling (ASPP) block, that I have taken from the DeepLabV3 model
A Residual MLP to convert the signal into the prediction.
It works fine but I wanted to try to go a bit further and also add global statistics to the model (min,max,mean,median,std for each layer = vector of 30 features)
In order to process also
Incorrect routing by Dashboard Layout - Material UI?
21 December 2024 @ 10:03 am
I'm integrating the Material-UI DashboardLayout into my React project, but I'm running into a routing issue. When I define a segment like "/dashboard/review-files" in the navigation, it routes to the literal path "/dashboard/review-files" instead of resolving dynamically to something like http://localhost:3080/mentor/dashboard/review-files.
I've ensured that my React Router setup in App.js matches the paths defined in the navigation and there are no other errors in the application. I have gone through Material-UI documentation and other resources, but I still can't figure out why this is happening.
My goal is for the navigation to properly route to full URLs, like http://localhost:3080/mentor/dashboard/review-files , when clicked.
I’d appreciate any guidance on how to make this work. Thanks in advance!
Code Snippets:
//App.js (Simplified):
co
java.time.format.DateTimeParseException is raised only when my code is executed in Windows 10
21 December 2024 @ 10:02 am
The following code throws a java.time.format.DateTimeParseException only when it's executed in a Windows 10 environment (Version Version 10.0.19045.5247). I tested it using two different JVMs, Graal JDK 17.0.2 and Eclipse Adoptium 11.0.15.10-hotspot, from two different IDEs (IntelliJ IDEA 2024.1.7 Ultimate and VS Code 1.96.2):
package com.xxx
import java.io.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
public static void main(String[] args) {
final File FILE = new File("C:\\Users\\xxx\\Downloads\\alarms.csv");
// example date: Dec 19, 2024 5:20:53 PM
final String DATE_PATTERN_REGEX = "\"([a-zA-Z]{3} [0-9]{1,2}, 2024 [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2} PM)\"";
final Pattern PATTERN = Pattern.compile(DATE_PATTERN_REGEX);
final Str
Link directory recursively to separate location
21 December 2024 @ 10:01 am
I want to link all contents of /folderA to /folderB (while maintaining same recursive folder structure). I don't want the files to be copied, because I don't want to double the disk space the files take up. But here's the catch - I want to be able to delete files in /folderB and not have that reflected in folderA.
I've tried hard links, but that doesn't work on directories. I've also tried symlinks, but that will delete the file in folderA.
Why doesn't `UniqueElementsValidator` use `collection instanceof Set` to determine whether it contains duplicate elements?
21 December 2024 @ 9:58 am
I noticed that the implementation of UniqueElementsValidator does not use collection instanceof Set to check if all elements are unique. Why is that?
public boolean isValid(Collection collection, ConstraintValidatorContext constraintValidatorContext) {
if ( collection == null || collection.size() < 2 ) { // why not use `collection instanceof Set`
return true;
}
List<Object> duplicates = findDuplicates( collection );
if ( duplicates.isEmpty() ) {
return true;
}
if ( constraintValidatorContext instanceof HibernateConstraintValidatorContext ) {
constraintValidatorContext.unwrap( HibernateConstraintValidatorContext.class )
.addMessageParameter
How to test for existance of globbed file before moving it in zsh?
21 December 2024 @ 9:58 am
I use to photograph with raw-files and develop to jpg with raw therapee later. For the slideshow I also mix the photos with the ones from the iPhone of my wife and the ones of my Pixel.
To have them in the right order I prepend the filename with YYYYMMDD-HH-MM-SS_ from the creation date.
Because they are developed later, the jpg-files have a different creation date than the NEF-files.
Therefore I wrote a short zsh-script to get the name of a jpg-file without date-time (OZ8_xxxx.JPG),look up the corresponding YYYYMMDD-HH-MM-SS_OZ8xxxx.NEF and change the date-time-part of the jpg to the one of the NEF-file.
This worked - partly.
I run into an error if the NEF-file was deleted or moved.
So I tried this and some slightly different qualifiers like (#qN):
if [[ -n *${nummer}.NEF(NY1) ]]; then
This improved the script - partly.
For unknown reason, sometimes the script moves the jpg to a file named ".JPG" instead YYYYMMDD-HH-MM-SS_OS8_xxxx.JPG. If this happens
Given member definitions starting with `with` are no longer supported
21 December 2024 @ 9:55 am
Given the following code (pun not intended):
trait Display[A]:
def display(value: A): String
object Display:
given stringDisplay: Display[String] with
def display(input: String) = input
IntelliJ displays the following warning:
Given member definitions starting with with are no longer supported; use {...} or : followed by newline instead
This is odd because the official documentation still shows given...with, and I can't find anything corresponding to this message online.
Furthermore, I don't know how to apply the suggestion, because none of the following compiles:
given stringDisplay: Display[String] {
def display(input: String) = input
}