Skip to content

Instantly share code, notes, and snippets.

View itzg's full-sized avatar

Geoff Bourne itzg

View GitHub Profile
@itzg
itzg / ListUIDefaultsKeys.java
Last active June 17, 2025 18:05
Java Swing UIDefaults keys
import java.util.Enumeration;
import java.util.SortedSet;
import java.util.TreeSet;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
public class ListUIDefaultsKeys {
public static void main(String args[]) throws Exception {
UIManager.LookAndFeelInfo looks[] = UIManager
@itzg
itzg / survive.yaml
Last active May 3, 2025 22:14
Example kubernetes deployment of itzg/minecraft-server and itzg/mc-backup and annotation for itzg/mc-router
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
server: survive
name: survive
spec:
accessModes:
- ReadWriteOnce
@itzg
itzg / AppUserProfile.java
Last active April 6, 2025 22:11
Example of using Spring Security @AuthenticationPrincipal with OAuth2 Log In
package me.itzg.tryspringbootoauthlogin.security;
public record AppUserProfile(
String oauthId,
java.net.URL issuer,
String name,
String givenName,
String familyName,
String pictureUrl,
String profileUrl,
@itzg
itzg / README libvirt cloud-init with static networking.md
Last active September 9, 2024 11:45
Configuring a libvirt domain with a static IP address via cloud-init local datasource

Here is how to create a cloud-init disk image and OS disk image suitable for configuring into a libvirt domain file.

In my case I am naming my domain (a.k.a. virtual machine or VM) xenial with a static IP address of 192.168.0.101. The filenames "network-config" and "user-data" files are arbitrary, so they can be named with a prefix for the domain, etc.

First, get the cloud image and convert into QCOW2 format:

qemu-img convert -O qcow2 xenial-server-cloudimg-amd64-disk1.img xenial-server-cloudimg-amd64-disk1.qcow2
@itzg
itzg / SecurityConfig.java
Created March 10, 2024 17:56
Spring Security register a custom PermissionEvaluator for @EnableMethodSecurity
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler;
import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
@Configuration
@EnableMethodSecurity
public class SecurityConfig {
@Bean
@itzg
itzg / info.md
Created March 3, 2024 20:45
Spring Data JDBC SpelEvaluationException property or field cannot be found

There seems to be a typo in the Spring Data JDBC section for @Query since the following custom repository query with the placeholder reference :#{topic.id}:

    @Query("SELECT * FROM activity" +
        " WHERE topic = :#{topic.id}" +
        "  AND lower(name) LIKE lower(:namePattern)" +
        " ORDER BY name")
    List<Activity> findAllNameLikeCaseInsensitive(Topic topic, String namePattern);
@itzg
itzg / info.md
Created March 3, 2024 20:25
With Spring Data JDBC, error "cannot insert a non-DEFAULT value into column"

Problem

With a PostgreSQL table created with a GENERATED ALWAYS AS IDENTITY column:

CREATE TABLE activity
(
    id    BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    topic BIGINT REFERENCES topic (id) ON DELETE CASCADE,
    name  TEXT NOT NULL

Certainly! The itzg/minecraft-server Docker image provides a convenient way to set up a Minecraft Server. Here's how you can get started:

  1. Install Docker:

  2. Pull the itzg/minecraft-server Image:

    • Open a terminal or command prompt.
    • Run the following command to pull the itzg/minecraft-server image:

docker pull itzg/minecraft-server

@itzg
itzg / info.md
Created February 6, 2024 17:44
Convert docker minecraft managed volume to host directory

Assuming the use of a compose file such as the following with a managed volume

services:
  mc:
    # ...
    volumes:
      - mc-data:/data
volumes:
 mc-data: {}
@itzg
itzg / gist:42b033e0b049145f668c99f7436eaf1b
Created February 6, 2024 17:32
Find corrupeted jar file in minecraft container
docker compose run -it --rm --entrypoint bash mc -c 'find . -name "*.jar" -print -not -exec zipinfo -t {} \; -quit'