Skip to content

Instantly share code, notes, and snippets.

Fletcher Nichol fnichol

Block or report user

Report or block fnichol

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@fnichol
fnichol / README.md
Created Mar 12, 2011
Download a cacert.pem for RailsInstaller
View README.md

Why?

There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.

From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?

Installation

The Ruby Way! (Fun)

@fnichol
fnichol / README.md
Last active Sep 18, 2019
Auto-enable Local HTTP Caching in Test Kitchen
View README.md

Auto-enable Local HTTP Caching in Test Kitchen

Note: total experiment and hack, looks nasty, could be awesome:

Setup

  • Drop the kitchen.local.yml into $HOME/.kitchen/config.yml
  • Install polipo (with Mac: brew install polipo, with Ubuntu: apt-get install polipo)
  • Drop polipo-start and polipo-console somewhere useful (perhaps $HOME/bin?)
@fnichol
fnichol / README.md
Created Feb 26, 2012
A Common .ruby-version File For Ruby Projects
View README.md

A Common .ruby-version File For Ruby Projects

Background

I've been using this technique in most of my Ruby projects lately where Ruby versions are required:

  • Create .rbenv-version containing the target Ruby using a definition name defined in ruby-build (example below). These strings are a proper subset of RVM Ruby string names so far...
  • Create .rvmrc (with rvm --create --rvmrc "1.9.3@myapp") and edit the environment_id= line to fetch the Ruby version from .rbenv-version (example below).

Today I learned about another Ruby manager, rbfu, where the author is using a similar technique with .rbfu-version.

@fnichol
fnichol / shell.sh
Created Apr 23, 2013
Test Kitchen with bats - A Lightning Guide
View shell.sh
SUITE_NAME=default
# create a bats subdirectory under your desired suite
mkdir -p test/integration/$SUITE_NAME/bats
# create an initial "canary" bats test file
# more examples at:
# * https://github.com/fnichol/chef-rvm/tree/master/test/integration/rubies/bats
# * https://github.com/fnichol/chef-ruby_build/tree/master/test/integration/alltherubies/bats
# * https://github.com/sstephenson/bats
@fnichol
fnichol / kitchen.yml
Last active Jun 26, 2019
Testing multiple versions of Chef with Test Kitchen
View kitchen.yml
---
driver:
name: vagrant
provisioner:
name: chef_zero
platforms:
- name: ubuntu-12.04-chef-11
driver:
@fnichol
fnichol / README.md
Last active May 29, 2019
A Windows/Linux/macOS PowerShell Rustup Install Script
View README.md

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 / README.md
Last active Feb 25, 2019
Testing on Mac Platforms with Test Kitchen
View README.md

Testing Mac Platforms with Test Kitchen

We'll assume an OS X Mavericks (10.9) box here.

Requirements

You'll need:

  • Vagrant
  • Vagrant's VMware Fusion provider
@fnichol
fnichol / README.md
Last active Jan 20, 2019
(Excellent?) Format Changes to Test Kitchen's kitchen.yml
View README.md

Format Changes to Test Kitchen's kitchen.yml File

This is happening thanks to a refactoring of the data manipulation code formerly in Kitchen::Config.

There are now 3 main configuration blocks that can be placed in the various levels:

  • driver: Configurtation relavent to Kitchen drivers. This is a combination of what was driver_plugin and driver_config. Backwards compatability is guarenteed with the legacy formats for a time, then will be deprecated (with a warning when encountered), then will be removed in a future release.
  • provisioner: Configuration relating to the automation tool being used. Currently supporting "chef_solo" and "chef_zero". Previously several Chef-related config paths were dumped in a Suite block, namely data_path, data_bags_path, environments_path, nodes_path, roles_path, etc. These will be supported for backwards compatability, then will be deprecated (with a warning when encountered), then will be removed in a future release.
  • busser: Configuration rela
@fnichol
fnichol / resolve-studio-teardown.sh
Last active Sep 26, 2018
A script that ensures a pre-existing Habitat Studio is safely cleaned up and captures a report on failure
View resolve-studio-teardown.sh
#!/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 Aug 12, 2018
Simple, blocking, one shot UDP client and server in Rust.
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:
///
You can’t perform that action at this time.