Skip to content

Instantly share code, notes, and snippets.

View RomanHargrave's full-sized avatar

Roman Hargrave RomanHargrave

  • Cascadia
View GitHub Profile
@RomanHargrave
RomanHargrave / flexgrid.scss
Last active January 26, 2019 05:08
Tiny SCSS Flexbox Grid
/*
* Flexbox grid SCSS library
* Author: Roman Hargrave
* License: ASL 2.0
* The smallest grid system ever designed?
* */
@mixin flex-grid($classname: 'flexg', $columns: 16, $gutter: 0, $col-gutter: 10px) {
$column_name-format: #{$classname}-c-;
@RomanHargrave
RomanHargrave / nullbug.scala
Created January 25, 2015 22:46
JavaConversions API 'null' bug
/*
* This demonstrates a bug that occurs in the collections `JavaConversions` API.
* This is __not__ a bug with the type system.
*
* The conversions API does not consider that it could potentially try to convert a `null` value
* that has been cast as java collection to a scala collection. Being that conversion procedures
* potentially involve calling functions upon the underlying collection __in order__ to achieve conversion
* it is not possible for the caller to simply perform a check against the converted collection to see if it
* is null, as the VM will throw a NullPointerException when any access is attempted to the underlying
* java collection (which is really a null reference)
#!/usr/bin/env fish
# Pathogen Helpers for Fish
# These commands allow for easy management of pathogen (vim) plugins
# Copyright 2015 Roman Hargrave <roman@hargrave.info>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# ASCII Unit separator, purpose is to separate subrecords, etc...
set __assoc_US \31
# Groks name[key] and sets varname and key variables
function assoc._parsename -S -a raw
set -l data (string match -r '(.+)\[(.+)\]' $raw)
if [ (count $data) -lt 3 ]
echo "Invalid assocatiave array specification '$raw'"
return 1
else
#!/usr/bin/env fish
# Pathogen Helpers for Fish
# These commands allow for easy management of pathogen (vim) plugins
# Copyright 2015 Roman Hargrave <roman@hargrave.info>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,

Keybase proof

I hereby claim:

  • I am romanhargrave on github.
  • I am hargrave (https://keybase.io/hargrave) on keybase.
  • I have a public key ASCXs4ru2tie5ymlUDFduNCCkI0S0lqUYfEscwyOVdBlZQo

To claim this, I am signing this object:

Encrypted SWAP hibernation in Debian 9+

It took me about 6 hours to find out all of this, but after reading a ton of man pages, initram scripts, and bug reports, I got a working result that takes about 2' to set up...

The point is to have a SWAP partition encrypted with LUKS, and it should be decypted during boot.

When using SysV, initram hooks and scripts in Debian worked like a charm but then, Systemd came and it's not yet fully implemented so this kind of crap happens. Systemd's cryptsetup doesn't support parameters in /etc/crypttab so using a script there is ignored:

/* Options Debian's crypttab knows we don't:
$!
$! Demo of WTF semantics
$!
$
$! assume that the first line in this file is ' KEY'
$ open/read fh EXAMPLE:[EXAMPLE]FILE.DAT
$
$! this should not reach EOF before finding a match, setting the global symbol 'line' and returning 1
$ call this_always_returns_two fh "KEY"
$
#!/usr/bin/perl
use warnings;
use strict;
use Text::CSV;
use Getopt::Long;
use Data::Dumper;
my $in_file = '-';
@RomanHargrave
RomanHargrave / optware.pl
Last active April 18, 2020 08:28
Optware Collector
#!/usr/bin/perl
use warnings;
use strict;
use Getopt::Long;
use List::Util qw(first);
use File::Basename;
use File::Path qw(make_path remove_tree);
use File::Temp qw(tempdir);