Skip to content

Instantly share code, notes, and snippets.

View itzg's full-sized avatar

Geoff Bourne itzg

View GitHub Profile
@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'
@itzg
itzg / TrySshKeyEncryptDecrypt.java
Last active August 25, 2023 21:00
Using ssh-keygen generated id_rsa to encrypt/decrypt text
package app;
import com.sshtools.common.publickey.InvalidPassphraseException;
import com.sshtools.common.publickey.SshKeyUtils;
import com.sshtools.common.ssh.SshException;
import com.sshtools.common.ssh.components.SshKeyPair;
import com.sshtools.common.ssh.components.SshPrivateKey;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
C:
\\server\mount
@itzg
itzg / NOTES.md
Last active August 13, 2022 18:52

If you see the following error when opening a gradle project in IntelliJ, especially 2020.2:

Starting Gradle Daemon...
Gradle Daemon started in 851 ms

FAILURE: Build failed with an exception.

* Where:
Initialization script 'C:\Users\user\AppData\Local\Temp\sync.studio.tooling2.gradle'
sudo tcpdump -i $(ip r | awk '/^default/ {print $5}') tcp port 25565