Instantly share code, notes, and snippets.

#!/usr/bin/env bash
# Copyright (c) 2018 Chef Software, Inc. and/or applicable contributors
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
///! Simple, blocking, one shot UDP client and server.
/// This shows a server that recieves one UDP datagram and returns the reversed contents of the
/// source datagram back to the client. There is a short pause on the server side which simulates
/// some expensive work.
/// # Example
/// Create a Cargo project with:
# Change directory to the root of your `habitat-sh/habitat` repo checkout
# cd /path/to/habiatat-sh/habitat
# Cleanup any existing Studio instances--keep it clean to be safe!
hab studio rm
# Enter the studio with the `core` key and prevent a Supervisor from starting
env HAB_ORIGIN=core HAB_STUDIO_SUP=false hab studio enter
# Build a static `hab` CLI for the `x86_64-linux-kernel2` target

Keybase proof

I hereby claim:

  • I am fnichol on github.
  • I am fnichol ( on keybase.
  • I have a public key ASA2PW1FW2eqANMPo6CweZrD7BL4Quf2hR1ypMcblTODlwo

To claim this, I am signing this object:

# shellcheck disable=SC2039
set -eu
if [ -n "${DEBUG:-}" ]; then set -x; fi
main() {
info "Starting setup"

The Mac/Bento templates use Tim Sutton's amazingly awesome os-vm-templates project to prepare a .dmg that can perform an unattended install of Mac OS X 10.7 through to 10.11. You'll need a copy of the Mac OS X .app on locally on disk, so we'll assume that it's installed under /Applications from the App Store.

Clone the os-vm-templates project and run the program to produce the disk image.

git clone
cd osx-vm-templates
sudo prepare_iso/ "/Applications/Install OS X El" out

Docker Cookbook In Chef-Apply? It's easy!

export CHEF_DOCKER_PATH=/path/to/docker/cookbook
chef-apply docka.rb
extern crate hyper;
extern crate openssl;
use hyper::{Client, Url};
use hyper::client::pool::{Config, Pool};
use hyper::http::h1::Http11Protocol;
use hyper::net::{HttpsConnector, Openssl};
use openssl::ssl::{SslContext, SslMethod};
use openssl::x509::X509FileType;
use std::env;

If you're using ChefDK and find you can't wait for the next release to come out (which will out be shortly), you might want to give the chefdk-update-app project a spin to update test-kitchen (follow the setup instructions in the README).

Upgrade test-kitchen

Upgrade test-kitchen with the following for Unix-based workstations:

sudo -E ./bin/ test-kitchen -r v1.4.0

Benchmarking Remote CMD and Powershell Invocations with WinRM in Test Kitchen


  • The executor in the code is a CommandExecutor which sets up and reuses a remote shell session across calls and recyles it before the maxiumum commands-per-shell limit is reached.
  • The vanilla object is a regular WinRM::WinRMWebService instance which sets up and tears down a shell for every CMD and Powershell script invocation.
  • The Powershell script variant is really running a powershell -encodedCommand <ENCODED_SCRIPT> over CMD.
  • The file appending operation isn't very taxing on the Windows host but simulates a chunked file upload and so tries to measure the relative cost of command invocations vs. measuring the time for the commands to execute.