Skip to content

Instantly share code, notes, and snippets.

@hfs
hfs / amdar.geojson
Last active January 3, 2016 05:49
Convert AMDAR messages in ASCII bulletin format into GeoJSON to get a quick preview.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hfs
hfs / rnd
Created February 23, 2014 20:16
Generate a 4-byte integer random number
#!/bin/sh
od -An -t uL -N4 /dev/random | tr -d ' '
@hfs
hfs / bulletinize-file
Created February 23, 2014 20:35
Script to wrap one bulletin in a minimal WMO message structure
#!/usr/bin/perl -wp
#
# Script to wrap one bulletin in a minimal WMO message structure
#
# Usage:
# bulletinize-file infile > outfile
# or
# bulletinize-file < infile > outfile
BEGIN {
print "\x01\x0D\x0D\n";
@hfs
hfs / .gitignore
Last active May 24, 2024 07:06 — forked from sit/.gitignore
How to keep Jenkins configurations in a git repository. Put .gitignore in Jenkins’ home directory (/var/lib/jenkins). Initialize a git repository and add a remote to push to. Create a new Jenkins job to run e.g. nightly with the content of backup.sh as shell execution build step.
# Non-config file types
*.log
*.log.*
*.tmp
*.old
*.bak
*.jar
*.jpi
*.jpi.pinned
*.json
@hfs
hfs / build.sbt
Created March 12, 2014 11:40
Separate integration tests in a Play! 2.2.2 project
import sbt._
// Enable integration tests:
// - put sources in src/it/java or src/it/scala
// - put resources in src/it/resources
// - run with "play it:test"
lazy val root = Project("root", file("."))
.configs(IntegrationTest)
.settings(Defaults.itSettings : _*)
.settings(libraryDependencies += playTest)
@hfs
hfs / build.sbt
Created March 13, 2014 11:49
sbt-native-packager: Append timestamp to version of Debian package for snapshots
version := "0.2-SNAPSHOT"
// If the version ends with "-SNAPSHOT", let the Debian version end with
// "~SNAPSHOT~yyyyMMddHHmmss". This way updates of the snapshot version can be
// detected by the package manager. Also the tilde "~" sorts before anything
// else when comparing version numbers. This way "1.0" will be regarded newer
// than "1.0~beta".
version in Debian <<= (version) { (v) =>
if (v.endsWith("-SNAPSHOT")) {
val timestampFormat = new java.text.SimpleDateFormat("yyyyMMddHHmmss");
@hfs
hfs / crcrlf.sh
Created March 21, 2014 10:51
Replace \r\r\n with \r\n in text files. \r\r\n happens typically, when an inferior VCS messes up the line endings on Windows
#!/bin/sh
find . -type f | while read each; do
if xxd -p "$each" | tr -d '\n' | grep -q 0d0d0a; then
echo "$each"
sed -i.bak -e 's/\r//' "$each"
fi
done
@hfs
hfs / putty-export.bat
Created March 31, 2014 10:30
PuTTY session configuration export/import from/into the Windows Registry
reg export HKCU\Software\SimonTatham putty.reg
@hfs
hfs / nice-wrapper.sh
Created April 10, 2014 15:00
Wrap a command with 'nice' and 'ionice' to give it lower CPU and IO priority
#!/bin/sh
#
# Start the command "$0.original", i.e. with the same name and ".original"
# appended with nice (lower CPU priority) and ionice (lower IO priority)
#
# Usage: If you want to provide "foo", rename "foo" to "foo.original", then
# link this script in "foo"'s place
nice ionice -c 3 "$0.original" "$@"
@hfs
hfs / README.md
Created April 30, 2014 18:10
Merge two files with common lines using `diff`

First file:

A
B
C
D

Second file:

C