October 23, 2024
Chicago 12, Melborne City, USA
C++

How to determine available physical RAM in a RISC-V OS?

I was recently going through the source code for xv6 (https://github.com/mit-pdos/xv6-riscv), when I recently came across this line: (https://github.com/mit-pdos/xv6-riscv/blob/riscv/kernel/memlayout.h) #define PHYSTOP (KERNBASE + 128*1024*1024) combine this with the Makefile of the project (https://github.com/mit-pdos/xv6-riscv/blob/riscv/Makefile): QEMUOPTS = -machine virt -bios none -kernel $K/kernel -m 128M -smp $(CPUS) -nographic This made me realise that they are just hard

Read More
CSS

CSS-only masonry layout

I want to use CSS to align a series of images like the image shows. 2 columns, and any number of side by side images. No vertical gaps between the images. And all the images are displayed with the same width (whatever their original size), and the heights are adjusted to keep the original aspect

Read More
SQL

sqlplus: how to execute a query spanning multiple lines

I am using Oracle 19c. I can get the following to work: variable max_id number; exec select 41 into :max_id from dual; begin dbms_output.put_line(:max_id); dbms_output.put_line(:max_id+1); end; But splitting the select across multiple lines produces an invalid SQL statement error at the new line: variable max_id number; exec select 41 into :max_id from dual; -- invalid

Read More
python

How do I make caves randomly generate in pygame?

My game is supposed to be like Minecraft using pygame, but 2D. I do not know how to generate caves, and other questions I looked at didn’t really work, like this: Perlin worms for 2D cave generation. That did not explain how to, and I am trying to find out. I heard of perlin noise,

Read More
java

Missed signal in a Java

Can this code ever lead to missed signal? If yes, then how? private Object lock = new Object(); private boolean conditionMet = false; public void waitForCondition() throws InterruptedException { synchronized (lock) { while (!conditionMet) { lock.wait(); } // Proceed when condition is met } } public void signalCondition() { synchronized (lock) { conditionMet = true;

Read More
security

Spring Security Login System

I am building login system using spring security but everytime I login and try to access anonther page, it just redirects me to the Login.html. private UsernamePasswordAuthenticationToken authentication; snippet of my post mapping /logged method: authentication = new UsernamePasswordAuthenticationToken(accountModel, null); SecurityContextHolder.getContext().setAuthentication(authentication); and this is SecurityConfiguration class: import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import

Read More
C#

Nested if statement in C not executing inner if

Struggling (newbie) with a nested if in C, probably doing something stupid. Basically a switch down tester which determines whether just down for a second or longer. void SwitchTest(void) { __delay_ms(3000); // LEDCOM = LED_ON; // Connect Bar Common LED1 = LED_OFF; LED2 = LED_OFF; LED3 = LED_OFF; LED4 = LED_OFF; LED5 = LED_OFF; if

Read More
templates

Pass list of objects as argument in terraform helm_release

I have a variable list of objects tolerations, which I am trying to pass to helm_release terraform resource. The code block below is part of a module and I am importing that module in different place and using tolerations as an input. locals { metabase_namespace = "metabase-test" } resource "helm_release" "metabase-test" { name = "metabase-test"

Read More
PHP

How to create a custom REST API endpoint for publishing posts with specific permalinks in WordPress?

I’m a new with php and I am working on a WordPress project where I need to create a custom REST API endpoint that allows publishing posts with specific permalinks. Here’s what I’m trying to achieve: Create a new REST API endpoint, something like /wp-json/custom/post This endpoint should accept POST requests with the following parameters:

Read More
Android

Failed to resolve some libraries after gradle update

After upgrading Gradle from 7.4 to 8.5, these libraries can’t be resolved. It works fine on 7.4. What could be causing the issue?" From distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip To distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip You need to sign in to view this answers

Read More