Skip to content

Instantly share code, notes, and snippets.

Avatar

James Badger openfirmware

View GitHub Profile
@openfirmware
openfirmware / README.md
Created Nov 18, 2019
Ruby tool to update the "Content-Length" in VCR test fixture "cassettes" to match the body length (it skips HEAD requests)
View README.md

VCR Cassette Cleaner

I made this tool to update the Content-Length header to match the bytesize of the body response in VCR cassettes. This is only necessary when the body has been manually edited (usually done to reduce the size of the YAML fixture). While VCR has an option to automatically update the Content-Length header on-the-fly (it doesn't update the cassette itself), the option also affects HEAD requests and sets their Content-Length to 0 (issue). This tool will skip HEAD requests to avoid that.

This tool has only been tested with Ruby 2.6 and VCR 5.0.0.

@openfirmware
openfirmware / README.markdown
Last active May 17, 2019
How to add a mask to a GeoTIFF using Photoshop
View README.markdown

HOW TO CREATE A TRANSPARENT MASK ON A GEOTIFF

This is useful for georeferenced images or GeoTIFF files that have black borders caused by re-projection or warping.

Georeference the image in QGIS, and export to a GeoTIFF (original.tif). Use Photoshop to open the GeoTIFF and select the area you want to mask; in the "Layers" palette switch to the "Channels" tab and select the Alpha channel (create one if it doesn't exist). Fill the masked area with "black" in the Alpha channel, as save as a new TIFF (export.tif). Don't bother with compression when exporting from Photoshop as we are about to convert the image again.

This TIFF won't have geodata, so we will use some command line tools from libgeotiff to fix that.

$ listgeo -no_norm "original.tif" > metadata.geo
@openfirmware
openfirmware / chat-overlay.css
Created Apr 27, 2019
CSS for OBS chat overlay
View chat-overlay.css
/**
* https://www.twitch.tv/popout/openfirmware/chat?darkpopout
*
* General Settings
*/
body {
color: #FFFFFF;
background: rgba(0,0,0,0) !important;
}
@openfirmware
openfirmware / recent.applescript
Created Mar 31, 2019
Open first recent folder (alphabetical sorted) in Finder
View recent.applescript
tell application "System Events" to tell process "Finder"
set frontmost to true
tell menu bar item "Go" of menu bar 1
click
click menu item "Recent Folders" of menu 1
click menu item 1 of menu 1 of menu item "Recent Folders" of menu 1
end tell
end tell
@openfirmware
openfirmware / readme.markdown
Created Mar 28, 2019
ST_MakeValid and other functions on libspatialite/GDAL on MacOS with Homebrew
View readme.markdown
$ brew install liblwgeom
$ export LDFLAGS="-L/usr/local/opt/liblwgeom/lib"
$ export CPPFLAGS="-I/usr/local/opt/liblwgeom/include"
$ brew edit libspatialite
(add --enable-lwgeom to configure)
$ brew reinstall -s libspatialite
$ brew install -s gdal
@openfirmware
openfirmware / recipe.rb
Created Dec 13, 2018
Chef Bash Resource without mangling interpolated variables
View recipe.rb
# Wrong way:
bash "Add Icinga Web 2 User" do
code <<-EOH
/usr/bin/psql -U icingaweb2 -d icingaweb2 -h localhost -p 5432 \
-c "INSERT INTO icingaweb_user (name, active, password_hash) \
VALUES ('#{username}', 1, '#{hash_pw}') ON CONFLICT (name) \
DO UPDATE SET password_hash = '#{hash_pw}' \
WHERE icingaweb_user.name = '#{username}';"
EOH
sensitive true
@openfirmware
openfirmware / Nova.markdown
Last active Nov 14, 2018
Escape Velocity: Nova on MacOS High Sierra
View Nova.markdown

Running EV Nova on MacOS High Sierra

[The game][EV Nova] does not seem to want to work out of the box, but it can still be done.

MacOS Mojave: The patch doesn't work unless you patch it under High Sierra first — see below.

Download EV Nova

Ambrosia SW's servers are still online, version 1.1.1 is the latest for Mac. Install it in /Applications.

@openfirmware
openfirmware / instructions.md
Created Nov 7, 2018
QEMU with Mac OS 9 guest *and working audio*
View instructions.md

QEMU Mac OS 9 Instructions

Here is a short guide on how to build QEMU to run Mac OS 9 with working audio. These instructions work for MacOS High Sierra as the host OS, although with some tweaking they may run under Linux/Windows. You should be comfortable compiling software from source before attempting.

Clone QEMU fork

Adapted from instructions from Cat_7

You may need to install XCode and/or the XCode command line tools. If you do not have them, then this process may prompt you to install them (MacOS will do that).

@openfirmware
openfirmware / README.markdown
Created Feb 20, 2018
TEAM Engine context.xml for Tomcat 9
View README.markdown

TEAM Engine context.xml for Tomcat 9

TEAM Engine has instructions for usage with Tomcat 7, however using it with Tomcat 9 requires some changes to the context.xml file to work. These changes may also work with Tomcat 8/8.5.

Install this file in webapps/teamengine/context.xml.

@openfirmware
openfirmware / td-agent.conf
Created Nov 28, 2017
Fluentd configuration for matching ElasticSearch 1.3 logfiles
View td-agent.conf
# Will match multi-line errors, as the first line will be a timestamp
# and only sometimes will there be additional lines with Java
# stacktraces.
# We use the timekey from the log file and trust it, but discard the
# fractional seconds — they don't parse for me, but that may be due
# to a different version of Ruby.
#
# The following fields will be parsed:
# - time: timestamp
# - loglevel: INFO, WARN, etc.
You can’t perform that action at this time.