Skip to content

Instantly share code, notes, and snippets.

Michael Smith MikaelSmith

Block or report user

Report or block MikaelSmith

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
@MikaelSmith
MikaelSmith / goodreads.rb
Last active Jun 11, 2019
Wash External Plugin Example
View goodreads.rb
#!/usr/bin/env ruby
# A script for exploring your Goodreads library with Wash
#
# Requirements:
# - `gem install oauth nokogiri --user-install`
# Note that BitBar runs without shell setup, so it will likely use the system ruby.
# - A developer key/secret from https://www.goodreads.com/api/keys
# stored in GOODREADS_KEY, GOODREADS_SECRET environment variables.
require 'json'
@MikaelSmith
MikaelSmith / active.1m.sh
Last active May 31, 2019
Wash / BitBar Examples
View active.1m.sh
#!/usr/bin/env wash
# Count all and all running EC2 instances
running=`find aws -maxdepth 5 -action exec -meta .State.Name running 2>/dev/null | wc -l | xargs`
total=`find aws -maxdepth 5 -action exec 2>/dev/null | wc -l | xargs`
echo EC2 $running / $total
# Count S3 buckets
buckets=`find aws -maxdepth 4 -path '*/resources/s3/*' 2>/dev/null | wc -l | xargs`
echo S3 $buckets
View Puppetfile
mod 'puppetlabs-stdlib'
mod 'pltraining-dirtree'
mod 'puppetlabs-inifile'
mod 'puppet-archive'
mod 'puppetlabs-java_ks'
mod 'puppet-rundeck'
@MikaelSmith
MikaelSmith / swarm.pp
Last active Nov 12, 2018
Install and bootstrap Docker Swarm using Bolt + the Puppet Docker module
View swarm.pp
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]
@MikaelSmith
MikaelSmith / transform.pp
Last active Oct 1, 2018
Transforming hash in Puppet
View transform.pp
$data = [
{
"certname" => "server1",
"parameters" => {
"port" => 1234,
"job" => "job1"
}
},
{
"certname" => "server2",
@MikaelSmith
MikaelSmith / domain-controller.pp
Last active Sep 20, 2018
Windows Bootstrapping
View domain-controller.pp
# 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| {
View Functions to switch between versions
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 / test.cpp
Created Aug 26, 2016
Boost date_time posix_time breaking
View test.cpp
#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)
{
@MikaelSmith
MikaelSmith / main.cc
Last active Feb 23, 2016
C++ SSL JSON Prettifier (Boost.asio)
View main.cc
#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.cc
Last active Dec 7, 2015
Functional C++14 λ Syntax
View test.cc
#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;
You can’t perform that action at this time.