Skip to content

Instantly share code, notes, and snippets.

@SingingBush
SingingBush / deploy-war
Last active June 12, 2020 11:55
This powershell script can be used within TeamCity to deploy a Java web app (war file) to a Tomcat installation on a remote Windows Server
<#
Deployment Script (SingingBush, 9-may-2014)
Usage:
In TeamCity 'Buildstep: Powershell' make sure that script is set to file and
in 'Failure Conditions' the checkbox is ticked for: 'the build process exit code is not zero'.
YOU MUST ENSURE THAT ALL THE FOLLOWING ARGS ARE USED:
@SingingBush
SingingBush / gist:fccd964259f282d85de3c0e8d74f84a8
Created June 13, 2016 14:59
Create a Java 8 Stream of Strings matching a regex on a given String
private Stream<String> regexPatternMatchStream(final String pattern, final String target) {
final Matcher matcher = Pattern.compile(pattern).matcher(target);
final Stream.Builder<String> sb = Stream.builder();
while (matcher.find()) {
sb.add(matcher.group());
}
return sb.build();
}
@SingingBush
SingingBush / gitconfig
Last active September 13, 2017 08:47
The changes I like to use in my global git config
[color]
branch = auto
diff = auto
status = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
@SingingBush
SingingBush / hexPhotos.ps1
Created January 11, 2017 14:55
Export VARBINARY images from a SQL Server query to jpeg files
<#
.SYNOPSIS
Script generating images from HEX values
.DESCRIPTION
Given a CSV dump of id's, usernames, and image data (HEX value of a VARBINARY field in SQL Server), generate a jpeg image for each row of csv data and also create a new csv file that lists the path of each image.
.EXAMPLE
hexPhotos.ps1 -f '.\db-dump.csv'
@SingingBush
SingingBush / PgpEncryption.java
Last active February 8, 2021 12:57
Spring Bean for PGP file encryption
//
// This is a variation of the example found in the Bouncy Castle Java examples on github.
// I'm using a public key provided by 3rd party to encrypt a file before sending to them. They
// have the private key so it's a one-way system, I have no need for a decrypt method. This is
// being used in a Spring Boot app, hence the annotations.
//
import org.bouncycastle.bcpg.CompressionAlgorithmTags;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openpgp.*;
@SingingBush
SingingBush / List-GitRepos.ps1
Created July 3, 2017 11:08
list local git repos using powershell
Function List-GitRepos {
<#
.SYNOPSIS
List local Git repositories
.DESCRIPTION
Use this command to find Git repositories in the specified folder. It is assumed that you have the Git command line tools already installed.
.PARAMETER Path
The top level path to search.
.EXAMPLE
@SingingBush
SingingBush / .bash_profile
Last active December 8, 2017 15:11
bash profile
#
# either ~/.bashrc or ~/.bash_profile
#
#
# User specific aliases and functions
alias du='du -kshc'
alias ls='ls -lhaGF --color'
export GOPATH=$HOME/.go
@SingingBush
SingingBush / godot-fedora.md
Created April 1, 2018 01:25
setting up Godot on Fedora Linux

Godot 3.0.2 (Mono Version)

Get the latest Mono

Godot requires Mono 5.4.x but the Fedora repo is still stuck on an older version. Install the latest directly from the Mono Project (currently 5.10.x).

http://www.mono-project.com/download/stable/#download-lin

rpm --import "http://keyserver.ubuntu.com/pks/lookup?op=get&amp;search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF"
@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
@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;