Creating Airgapped keys for Yubikey

Introduction

Before you begin, it would probably be a good idea to have three flash drives and a Yubikey.

  1. Your first USB stick will be a Live USB that will boot the airgapped system.
  2. The second will store the packages that you will need to install on the newly booted …
more ...

Restricting rsync access with SSH

DateTagsssh / rsync

SSH public keys can be added to ~/.ssh/authorized_keys on a typical system to allow the holder of the private key to access the system. Sometimes however you might want to restrict the access a particular key has.

In my case, I wanted my CI system to be able to …

more ...

Getting better feedback from sinon stubs

Sinon is an extremely powerful tools for writting unit tests. It helps to create standalone spies, stubs and mocks to isolate functionallity.

Setting up Sinon

The documentation suggests you can, for example, create a spy like so:

it('calls the original function', function () {
    var callback = sinon.spy();
    var proxy = once …
more ...

Extending Supertest

I have an express app running behind an Apache reverse proxy with mod_auth_mellon used to authenticate users via SAML.

As a result of relying on headers for auth, I have lots of mocha tests that look like:

it("should add a comment with a user", (done) => {
    let expectedUser = "a User …
more ...

View git diff by word

DateTagsgit

By default, git diff will highlight differences by line.

Differences highlighted word by word:

$ git diff --word-diff

Differences highlighted character by character:

$ git diff --word-diff-regex=.

Differences highlighted word by word without extra characters:

$ git diff --color-words

Differences highlighted character by character without extra characters:

$ git diff --color-words=.

More information can …

more ...

Pretty printing of git commit history

DateTagsgit

Helpful git logging aliases

Helpful aliases for viewing git commit history: logg, logga, loggs, loggsa, logd, logda, logdr, and logdra.

The aliases combine to utilize the same set of flags in different combinations:

--color:show colored
--graph:text-based graphical representation of the commit history
--date-order:show no parents before all …
more ...

Pretty Printing from the Commmand Line

JSON

The python standard library provides a json library that can be used to pretty print json.

$  echo '{"this": ["that"]}' | python -m json.tool
{
  "this": [
      "that"
  ]
}

XML

$  echo '<root><foo a="b">lorem</foo><bar value="ipsum" /></root>' | xmllint --format -
<?xml version="1.0"?>
<root>
  <foo a="b">lorem</foo …
more ...

Safely force pushing with Git

DateTagsgit

I want to modify the most recent commit but its already been pushed to origin. Using the --force-with-lease flag I can "more safely" push to origin and overwrite the existing data.

The --force-with-lease flag checks to make sure the remote repo matches the local cache. In other words, it ensures …

more ...

Rescue a missing git stash

DateTagsgit

I lost a git stash the other day mysteriously. Here is the process I used to recover a lost stash.

Where is my Stash?

Lets assume you have a git stash:

$ git stash
Saved working directory and index state WIP on master: 1f96501 Unmark two old posts as drafts, check …
more ...