Instantly share code, notes, and snippets.

View main.rs
///! 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:
///
View build-bootstrap-hab-x86_64-linux-kernel2.sh
# 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
View keybase.md

Keybase proof

I hereby claim:

  • I am fnichol on github.
  • I am fnichol (https://keybase.io/fnichol) on keybase.
  • I have a public key ASA2PW1FW2eqANMPo6CweZrD7BL4Quf2hR1ypMcblTODlwo

To claim this, I am signing this object:

View dev-setup-minimal.sh
#!/bin/sh
# shellcheck disable=SC2039
set -eu
if [ -n "${DEBUG:-}" ]; then set -x; fi
main() {
init
ensure_root
info "Starting setup"
View README.md

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 prepare_iso.sh program to produce the disk image.

git clone https://github.com/timsutton/osx-vm-templates.git
cd osx-vm-templates
sudo prepare_iso/prepare_iso.sh "/Applications/Install OS X El Capitan.app" out
View README.md

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

export CHEF_DOCKER_PATH=/path/to/docker/cookbook
chef-apply docka.rb
View docker_talk.rs
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;
View README.md

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/chefdk-update-app.sh test-kitchen -r v1.4.0
View README.md

Benchmarking Remote CMD and Powershell Invocations with WinRM in Test Kitchen

Notes

  • 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.

Observations

View ruby-install-prof.sh
# Build an MRI Ruby version ready for ruby-prof (https://github.com/ruby-prof/ruby-prof)
VERSION=2.2.0
ruby-install \
--install-dir ~/.rubies/ruby-prof-$VERSION \
-p https://raw.githubusercontent.com/skaes/rvm-patchsets/master/patches/ruby/$VERSION/railsexpress/01-zero-broken-tests.patch \
-p https://raw.githubusercontent.com/skaes/rvm-patchsets/master/patches/ruby/$VERSION/railsexpress/02-improve-gc-stats.patch \
-p https://raw.githubusercontent.com/skaes/rvm-patchsets/master/patches/ruby/$VERSION/railsexpress/03-display-more-detailed-stack-trace.patch \
-p https://raw.githubusercontent.com/skaes/rvm-patchsets/master/patches/ruby/$VERSION/railsexpress/04-backport-401c8bb.patch \