pacman -Syu
pacman -Su
pacman -S --needed base-devel mingw-w64-x86_64-toolchain
René Olsthoorn's techtips
Technical tips for various products and programming languages
dinsdag 23 december 2025
MSYS2 installation
zondag 31 augustus 2025
Sfxr: Basic sound effects for games
Sfxr sound effects can be played with the Soloud library.
zondag 18 mei 2025
PostgreSQL adding a unique GUID column
In PostgreSQL, it is easy to add a GUID column and fill it:
ALTER TABLE public."thetable" ADD aggregateid uuid DEFAULT gen_random_uuid() NOT NULL;
ALTER TABLE public."thetable" ADD CONSTRAINT thetable_unique UNIQUE (aggregateid);
zaterdag 1 maart 2025
Totalcommander: no rename with doubleclick
[Configuration]
InplaceRename=0
vrijdag 31 januari 2025
Copilot / AI werkt heel goed!
Copilot oftewel Artificial Intelligence werkt erg goed tegenwoordig. Ik stel de volgende vraag:
"How to determine the byte position of an element in a C struct"
Vroeger kon je het vergeten dat je antwoord kreeg via Google. Tegenwoordig krijg je het antwoord:
#include <stdio.h>
#include <stddef.h> // For offsetof macro
struct MyStruct {
int a;
float b;
char c;
};
int main() {
// Calculate and print the offset of each member
printf("Offset of 'a': %zu bytes\n", offsetof(struct MyStruct, a));
printf("Offset of 'b': %zu bytes\n", offsetof(struct MyStruct, b));
printf("Offset of 'c': %zu bytes\n", offsetof(struct MyStruct, c));
return 0;
}
En daarmee kon ik mijn oplossing gemakkelijk programmeren:
int theOffset = offsetof(SDL_KeyboardEvent, scancode);
AI werkt goed!
donderdag 30 januari 2025
C#: anonymous lambda using class instance variable
In C#, you can write an anonymous lambda which uses an instance variable of the class you are using:
Hello hello = new Hello();
hello.methodToCall((self) =>
{
Console.WriteLine("hallo " + self.numberToReach);
});
public class Hello
{
public int numberToReach = 3;
public void methodToCall(Action<Hello> operation)
{
operation(this);
}
}
In Kotlin, the Hello instance is bound to this, which is nice (see my trailing lambda's post). In C#, the "this" needs to be transferred using a parameter, in this case called "self".
woensdag 29 januari 2025
Easy pagination with Spring JPA - Hibernate
*****************************
File Main
*****************************
for (theUser in userService.getUsersByClassification("Class 1", pageNr = 0, pageSize = 10)) {
println(theUser.displayName)
}
*****************************
File UserService
*****************************
@Service
class UserService @Autowired constructor(private val userPaging: UserPagingAndSortingRepository) {
fun getUsersByClassification(classification: String, pageNr: Int, pageSize: Int): Page<User> {
val pageable: Pageable = PageRequest.of(pageNr, pageSize)
return userPaging.findByClassification(classificatie, pageable)
}
}
*****************************
File UserPagingAndSortingRepository
The Query annotation is JPQL, but in the case of JPA Hibernate, can also be HQL.
*****************************
interface UserPagingAndSortingRepository : PagingAndSortingRepository<User, Long> {
@Query("SELECT u FROM User u JOIN u.userExtradata um WHERE um.classification = :classification")
fun findByClassification(@Param("classification") classification: String, pageable: Pageable): Page<User>
}
*****************************
File entity.User
*****************************
@Entity
@Table(name = "\"user\"")
class User {
@Id
var id: Long = 0;
@Column (name="display_name")
var displayName: String = ""
@OneToOne(mappedBy = "user", cascade = [CascadeType.ALL], fetch = FetchType.LAZY)
val userExtradata: UserExtradata? = null
}
*****************************
File entity.UserExtradata
*****************************
@Entity
@Table(name = "\"user_extradata\"")
class UserExtradata {
@Id
var user_id: Long = 0;
var classification: String = ""
var phonenumber: String? = ""
@OneToOne
@JoinColumn(name = "user_id", referencedColumnName = "id")
val user: User? = null
}