Skip to content

Instantly share code, notes, and snippets.

@MikaelSmith
MikaelSmith / build_cfacter_win.ps1
Last active August 29, 2015 14:06
Build script that downloads dependencies and builds puppetlabs/cfacter.
# Starting from a base Windows Server 2008r2 or 2012r2 installation, install required tools, setup the PATH, and download and build software.
# This script can be run directly from the web using "iex ((new-object net.webclient).DownloadString('<url_to_raw>'))"
### Configuration
## Setup the working directory
$sourceDir=$pwd
## Set the number of cores to use for parallel builds
$cores=2
@MikaelSmith
MikaelSmith / CMakeLists.txt
Last active August 29, 2015 14:07
CFacter SuperProject
cmake_minimum_required(VERSION 2.8.12)
project(CFACTER-BUILD)
set(BOOST_VERSION 1.56.0)
set(YAMLCPP_VERSION 0.5.1)
set(OPENSSL_VERSION 1.0.1i)
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "Defaulting to a release build.")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
@MikaelSmith
MikaelSmith / keybase.md
Created January 22, 2015 22:13
keybase

Keybase proof

I hereby claim:

  • I am mikaelsmith on github.
  • I am michaelsmith (https://keybase.io/michaelsmith) on keybase.
  • I have a public key whose fingerprint is 443C 662C BB7B D4C7 757F FF1D 40F0 3C76 C350 74F9

To claim this, I am signing this object:

@MikaelSmith
MikaelSmith / test.cc
Last active December 7, 2015 18:32
Functional C++14 λ Syntax
#include <iostream>
#include <vector>
template <typename T, typename... TArgs, template <typename...>class C, typename F>
auto fn_map(const C<T,TArgs...>& container, const F& f) {
using resultType = decltype(f(std::declval<T>()));
C<resultType> result;
for (const auto& item : container)
result.push_back(f(item));
return result;
@MikaelSmith
MikaelSmith / main.cc
Last active February 23, 2016 23:23
C++ SSL JSON Prettifier (Boost.asio)
#include <iostream>
#include <cstdint>
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
#include <rapidjson/reader.h>
#include <rapidjson/prettywriter.h>
#include <rapidjson/filewritestream.h>
using namespace std;
using boost::asio::ip::tcp;
@MikaelSmith
MikaelSmith / test.cpp
Created August 26, 2016 17:50
Boost date_time posix_time breaking
#include <limits>
#include <iostream>
#define BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
#include <boost/date_time/posix_time/posix_time.hpp>
using namespace boost::posix_time;
int main(int argc, char** argv)
{
java8 () {
latest=`ls -d /Library/Java/JavaVirtualMachines/jdk1.8.0_*.jdk | sed 's/^.*jdk1\.8\.0_//' | sort -n | tail -1`
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_${latest}Contents/Home
java -version
}
java9 () {
export JAVA_HOME=/Library/Java/Home
java -version
}
@MikaelSmith
MikaelSmith / domain-controller.pp
Last active September 20, 2018 19:31
Windows Bootstrapping
# Requires Powershell 5, Puppet, and the puppetlabs-dsc module.
# These variables may need customization.
$domain_name = 'example.com'
$domain_credential = {
'user' => 'Administrator',
'password' => 'Password1!'
}
$dns_servers = ['10.240.0.10','10.240.1.20']
['AD-Domain-Services','RSAT-AD-PowerShell','RSAT-AD-Tools'].each |String $feature| {
@MikaelSmith
MikaelSmith / transform.pp
Last active April 1, 2022 11:14
Transforming hash in Puppet
$data = [
{
"certname" => "server1",
"parameters" => {
"port" => 1234,
"job" => "job1"
}
},
{
"certname" => "server2",
@MikaelSmith
MikaelSmith / swarm.pp
Last active November 12, 2018 18:57
Install and bootstrap Docker Swarm using Bolt + the Puppet Docker module
plan examples::swarm(TargetSpec $managers, TargetSpec $workers) {
$hosts = [$managers, $workers]
$hosts.apply_prep
apply($hosts) {
include 'docker'
}
# Initialize the swarm on a single manager.
$targets = get_targets($managers)
$master = $targets[0]