Skip to content

Instantly share code, notes, and snippets.

@lucko
lucko / java-stack-thread-dump.md
Created February 19, 2021 13:53
Generate a stack trace / thread dump for a Java program

Step 1: Find the process id for the application

Before you can create a stack dump, you need to know (or find out) the process id of the application.

You can use the jps command (or any other approach) to find the process for all running Java programs on the system.

e.g.

➜  jps
<scheme name="luck-theme" version="142" parent_scheme="Default">
<option name="FONT_SCALE" value="1.0" />
<metaInfo>
<property name="created">2021-05-06T21:13:30</property>
<property name="ide">idea</property>
<property name="ideVersion">2021.1.0.0</property>
<property name="modified">2021-05-06T21:13:38</property>
<property name="originalScheme">luck-theme</property>
</metaInfo>
<option name="LINE_SPACING" value="1.0" />
/*
* This file is part of factions-relation-tab, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Scoreboard scoreboard = GlobalScoreboard.get();
ScoreboardObjective objective = scoreboard.createObjective("big scoreboard", DisplaySlot.SIDEBAR);
ScoreboardTeam team = scoreboard.createTeam("test-team");
String p1 = "hi there. this i", p2 = "s a 72 character long scoreboard line. p", p3 = "retty cool huh?!";
team.setPrefix(p1);
team.setSuffix(p3);
team.addPlayer(p2);

~/.minttyrc

BoldAsFont=-1
Font=DejaVu Sans Mono
FontHeight=10
BoldAsColour=yes
Locale=C
Charset=UTF-8
FontSmoothing=partial
FontWeight=400
MetadataKey<AtomicInteger> AFK_TIME_KEY = MetadataKey.create("afk", AtomicInteger.class);
MetadataKey<Direction> AFK_DIRECTION_KEY = MetadataKey.create("afk-direction", Direction.class);
Scheduler.runTaskRepeatingSync(() -> {
for (Player player : Bukkit.getOnlinePlayers()) {
MetadataMap metadata = Metadata.provideForPlayer(player);
Direction prev = metadata.getOrNull(AFK_DIRECTION_KEY);
Direction now = Direction.from(player.getLocation());
#!/bin/sh
rm BuildTools.jar
wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
java -jar BuildTools.jar
@lucko
lucko / auto-sign-commits-mac.md
Last active April 15, 2024 08:26
Auto-sign commits with IntelliJ on MacOS

Run:

  • brew install gnupg pinentry-mac
  • git config --global user.signingkey <key>
  • git config --global commit.gpgsign true
  • git config --global gpg.program gpg

Then add the following line to ~/.gnupg/gpg-agent.conf:

pinentry-program /usr/local/bin/pinentry-mac

Keybase proof

I hereby claim:

  • I am lucko on github.
  • I am luck (https://keybase.io/luck) on keybase.
  • I have a public key ASAH5CNWnXC6nvyISaX2JQOymOFzDmwsR9FpUSJTrw-5vQo

To claim this, I am signing this object:

package me.lucko.chatinject;
import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.util.ChatComponentText;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;