Skip to content

Instantly share code, notes, and snippets.

@Crydust
Crydust / compresspdf.sh
Created June 10, 2025 20:56
Compress pdf with gostscript on linux command line
#!/bin/sh
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress -dNOPAUSE -dQUIET -dBATCH -sOutputFile=compressed.pdf inpu.pdf
@Crydust
Crydust / ConvertPocketCsvExportToBookmarksHtml.java
Created May 31, 2025 14:43
Convert Pocket Csv Export To Bookmarks Html
package be.crydust;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVParser;
import org.apache.commons.csv.CSVRecord;
import org.apache.commons.text.StringEscapeUtils;
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
@Crydust
Crydust / WriteXml.java
Created May 11, 2025 16:18
Read and write xml with whitespace in an attribute.
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.Transformer;
@Crydust
Crydust / ShowGeometry.java
Last active April 17, 2025 21:51
Initialize Graphics2D with highest visual quality and draw jts Geometry objects
private static void show(Geometry... geometries) throws InterruptedException, InvocationTargetException {
ShapeWriter shapeWriter = new ShapeWriter(createPointTransformation(5, 20));
int width = 640, height = 480;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = createGraphics2D(image);
try {
// Draw background
g2d.setColor(Color.WHITE);
@Crydust
Crydust / XmlStax.java
Last active August 30, 2023 14:03
Read xml using stax api in java
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.events.EndElement;

Git worktree

# clone the repo, but switch it to a dummybranch so other worktrees can checkout the main branch
git clone --no-checkout URL_HERE repo.git
cd repo.git
git switch -c dummy

# add a worktree
git worktree add ../repo_main main
@Crydust
Crydust / my-winutil.ps1
Created February 18, 2023 16:44
remove junk from windows 10
Write-Host "Creating Restore Point in case something bad happens"
Enable-ComputerRestore -Drive "$env:SystemDrive"
Checkpoint-Computer -Description "RestorePoint1" -RestorePointType "MODIFY_SETTINGS"
#WPFEssTweaksDVR
If (!(Test-Path "HKCU:\System\GameConfigStore")) {
New-Item -Path "HKCU:\System\GameConfigStore" -Force
}
Set-ItemProperty -Path "HKCU:\System\GameConfigStore" -Name "GameDVR_DXGIHonorFSEWindowsCompatible" -Type DWord -Value 1
Set-ItemProperty -Path "HKCU:\System\GameConfigStore" -Name "GameDVR_HonorUserFSEBehaviorMode" -Type DWord -Value 1
@Crydust
Crydust / transparent-pixel.html
Created February 8, 2023 13:13
transparent pixel
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="/>
@Crydust
Crydust / LogHttpServletRequest.java
Last active February 7, 2023 10:26
log HttpServletRequest
sb.append("*** request.getMethod() = ").append(request.getMethod()).append("\n");
sb.append("*** request.getContextPath() = ").append(request.getContextPath()).append("\n");
sb.append("*** request.getRequestURI() = ").append(request.getRequestURI()).append("\n");
sb.append("*** request.getServletPath() = ").append(request.getServletPath()).append("\n");
sb.append("*** request.getPathInfo() = ").append(request.getPathInfo()).append("\n");
final ArrayList<String> headerNames = Collections.list(request.getHeaderNames());
for (final String headerName : headerNames) {
final ArrayList<String> headers = Collections.list(request.getHeaders(headerName));
for (int i = 0; i < headers.size(); i++) {
final String header = headers.get(i);