Skip to content

Instantly share code, notes, and snippets.

View fnichol's full-sized avatar

Fletcher Nichol fnichol

View GitHub Profile
fnichol / Profile.ps1
Created November 10, 2020 08:35
PowerShell Profile loading Visual Studio 2019
# Thanks to:
$tempFile = [IO.Path]::GetTempFileName()
## Store the output of cmd.exe. We also ask cmd.exe to output
## the environment table after the batch file completes
cmd /c " `"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat`" && set > `"$tempFile`" "
## Go through the environment variables in the temp file.
fnichol /
Last active August 17, 2020 14:41
A Windows/Linux/macOS PowerShell Rustup Install Script

A Windows/Linux/macOS PowerShell Rustup Install Script

On Windows, run

& ([scriptblock]::Create((New-Object System.Net.WebClient).DownloadString('')))

in a PowerShell session. This downloads and runs rustup-init.ps1, which in turn downloads and runs the correct version of the rustup-init executable on

fnichol /
Last active September 26, 2018 18:28
A script that ensures a pre-existing Habitat Studio is safely cleaned up and captures a report on failure
#!/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
fnichol /
Created August 12, 2018 02:52
Simple, blocking, one shot UDP client and server in Rust.
///! 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:
fnichol /
Created July 19, 2018 19:26
Build an initial `hab` binary for the `x86_64-linux-kernel2` package target
# 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:

fnichol /
Created April 8, 2017 16:50
Minimal Development Setup
# shellcheck disable=SC2039
set -eu
if [ -n "${DEBUG:-}" ]; then set -x; fi
main() {
info "Starting setup"
fnichol /
Last active December 30, 2019 08:23
Building a Mac OS X Vagrant box with Bento

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
fnichol /
Created October 23, 2015 17:39
Research/prototype code to talk to a Docker Engine with Rust and Hyper
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;