Skip to content

Instantly share code, notes, and snippets.

@SingingBush
SingingBush / aws-quick-setup-guide.md
Last active January 20, 2024 20:28
Quick setup guide for configuring a fresh AWS account

AWS quickstart guide

This guide assumes you are setting up AWS for the first time either for personal use of for a small business (couple of users). The steps will also scale to a large organisation but it's likely that you will want to think through a more complex structure for grouping users into accounts and the permissions they have.

Part 1: Be careful not to spend too much (Optional / Recommended Step)

From the top-right drop-down, select Billing and Cost Management, then Budgets, then Create budget. Here you can define a budget or use a premade template. When starting out you may want to try sticking to the Zero spend budget for example.

Part 2: Let's begin by creating an organisation with a few accounts

@SingingBush
SingingBush / Doom 3 modding.md
Last active May 28, 2023 18:20
Developing mods and maps for Doom 3 (dhewm3)

Developing mods and maps for Doom 3 (dhewm3)

Getting Doom 3

It's worth getting Doom 3 from the Steam store as it includes:

  • The original DOOM 3
  • Resurrection of Evil Expansion
  • DOOM 3: BFG Edition
@SingingBush
SingingBush / maven gpg instructions.md
Last active May 8, 2023 17:57
Maven: signing artifacts for release to maven central

These instructions cover the following topics

  • Generating/updating GPG keys
  • Publishing GPG keys
  • Adding GPG keys to GitHub
  • Using GPG keys to sign git commits
  • Using GPG keys to sign maven artifacts
  • Publishing maven artifacts to OSSRH (Open Source Software Repository Hosting)

It's recommended to also read the following documentation

@SingingBush
SingingBush / TestUtils.java
Created May 8, 2023 10:38
Matching json with mockito
import org.mockito.ArgumentMatcher;
// javax.json:javax.json-api
//import javax.json.Json;
//import javax.json.JsonStructure;
//import javax.json.stream.JsonGenerator;
// jakarta.json:jakarta.json-api
import jakarta.json.Json;
import jakarta.json.JsonStructure;
@SingingBush
SingingBush / CloudWatch examples.md
Last active October 26, 2022 16:14
Advanced CloudWatch queries for aggregating and visualising application logs

CloudWatch is really powerful. As well as just searching your logs you can quickly aggregate and visualise data from your logs.

Visualising warnings and errors in a line chart

In this example we use a regex make a capture group for loglevel based on lines such as 2022-10-26T16:00:00.000Z ERROR something bad happened! then count how many times the logs contained a WARN or ERROR in the log file in a 30 minute interval. This query can be used in conjunction with the Visualization tab in CloudWatch (select Line from the dropdown).

With a little editing based on your use case, this query wiil help build an overview of your error rate

@SingingBush
SingingBush / Dockerfile
Created November 27, 2020 16:26
docker image of Amazon Linux with the aws-cli tools and Corretto installed with UK locale
# Amazon Linux with Amazon Corretto and the aws-cli tools for use in the UK (Amazon Linux uses yum)
FROM amazon/aws-cli:latest
# Set the default region for aws-cli
RUN mkdir /root/.aws && echo -e "[default]\nregion = eu-west-1" >> /root/.aws/config
# Set the locale to UK
ENV LANG en_GB.UTF-8
ENV LANGUAGE en_GB:en
ENV LC_ALL en_GB.UTF-8
@SingingBush
SingingBush / post-images-to-api.ps1
Created September 12, 2019 12:05
Iterate images in a directory and make a POST request for each one to an API
$baseUrl = 'http://api.domain.com/some-service/'
Get-ChildItem -Path ".\*.jpg" | Sort-Object Name | % {
$response = try {
Invoke-RestMethod -uri "$baseUrl/image" -Method Post -Infile $_.Name -ContentType 'image/jpeg' -ErrorAction Stop
} catch [System.Net.WebException] {
Write-Error "Media Service returned $($_.Exception.Response.StatusCode.Value__) : $($_.Exception.Message)"
Exit 1;
}
@SingingBush
SingingBush / dlang_version_check.md
Last active January 6, 2023 18:32
a collection of D version checks for compatibility
// https://dlang.org/changelog/2.101.0.html#logger
static if(__traits(compiles, (){ import std.logger; } )) {
    import std.logger;
} else {
    // logger was in 'std.experimental' for a long time but you could optionally check that too
    import std.experimental.logger;
}
@SingingBush
SingingBush / JavaBluetooth.md
Last active April 1, 2024 20:16
A short article about the lack a standard API for Bluetooth in Java SE

Bluetooth (or the lack of) on Java

Java SE has never had support for bluetooth, the closest thing to a standard is JABWT (Java APIs for Bluetooth Wireless Technology) defined in JSR-82 which is actually for Java ME (Micro Edition).

JSR-82 provides the specification for the javax.bluetooth and javax.obex packages and would allow for code somewhat like:

import javax.bluetooth.BluetoothStateException;
import javax.bluetooth.DeviceClass;
@SingingBush
SingingBush / Reviving Dead Code (trying to) - jEnesis Emulator
Created December 20, 2018 02:24
A short story about the difficulties in using unmaintained software (jEnesis)
Today I did a quick google search to see if any emulators had been written in Java. As it urns out there was a Sega Megadrive emulator called [jEnesis](http://www.workingdesign.de/projects/jenesis.php) that was written by Stephan Dittrich and released back in 2006.
Most of the site is just dead links now and I wasn't able to find a working download there but I was able to track down a build of the project else where. Unfortunately however, the build I found was version 0.0.5 from May 2006 so it doesn't include the changes that went into the final v0.1.0 that was supposed to have been built in June 2006 (perhaps it was never made public).
The jEnesis.jar that I downloaded depends on a very old [lwjgl](https://www.lwjgl.org/). The timestamp for the file was December 2005 which would make it [version 0.99](https://sourceforge.net/projects/java-game-lib/files/Official%20Releases/LWJGL%200.99/).
This old lwjgl only supported 32-bit systems, so running `java -cp jEnesis.jar;lwjgl.jar jenesis.Main` would throw a