Skip to content

Instantly share code, notes, and snippets.

View fnichol's full-sized avatar

Fletcher Nichol fnichol

View GitHub Profile
@fnichol
fnichol / Profile.ps1
Created November 10, 2020 08:35
PowerShell Profile loading Visual Studio 2019
# Thanks to: https://gist.github.com/justinian/81a2e55c89e8301a8a96
$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
fnichol / README.md
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('https://gist.github.com/fnichol/699d3c2930649a9932f71bab8a315b31/raw/rustup-init.ps1')))

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
fnichol / resolve-studio-teardown.sh
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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@fnichol
fnichol / main.rs
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
fnichol / build-bootstrap-hab-x86_64-linux-kernel2.sh
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 (https://keybase.io/fnichol) on keybase.
  • I have a public key ASA2PW1FW2eqANMPo6CweZrD7BL4Quf2hR1ypMcblTODlwo

To claim this, I am signing this object:

@fnichol
fnichol / dev-setup-minimal.sh
Created April 8, 2017 16:50
Minimal Development Setup
#!/bin/sh
# shellcheck disable=SC2039
set -eu
if [ -n "${DEBUG:-}" ]; then set -x; fi
main() {
init
ensure_root
info "Starting setup"
@fnichol
fnichol / README.md
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 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

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

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