Skip to content

Instantly share code, notes, and snippets.

@mheffner
mheffner / fly.toml
Last active September 24, 2023 14:50
Running a Mastodon server on Fly.io (plus some stuff)
app = "mastiff"
primary_region = "iad"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
[build]
image = "tootsuite/mastodon:v3.5.5"
@mheffner
mheffner / gauge.cpp
Created December 14, 2015 20:15
c++ functional interface
#include <functional>
#include <iostream>
class Foo {
public:
Foo(std::function<double()> gauge) {
this->_gauge = gauge;
}
void invoke() {
@mheffner
mheffner / measure.sh
Created February 15, 2015 20:14
USB thermometer to Librato measure
#!/bin/bash
# Submit USB thermometer temperature to Librato
#
# Use with: https://github.com/petechap/usb-thermometer
#
#
# FILL OUT:
#
@mheffner
mheffner / gist:9dd3edf7f5ebbb629730
Last active August 29, 2015 14:09
raid_ephemeral.sh
#!/bin/bash
#
# this script will attempt to detect any ephemeral drives on an EC2 node and create a RAID-0 stripe
# mounted at /mnt. It should be run early on the first boot of the system.
#
# Beware, This script is NOT fully idempotent.
#
METADATA_URL_BASE="http://169.254.169.254/2012-01-12"
@mheffner
mheffner / gist:c3671966d50d69909af1
Created July 19, 2014 16:26
Base packages for ruby on ubuntu
apt-get -y install ruby git xutils-dev ruby-dev make g++ libssl-dev autoconf libsasl2-dev libmysqlclient-dev scons

Hacking a Twine

I got a Twine the other week because I was interested in tracking temperature and moisture readings from my house, particularly to know if something is flooding.

Once setup, the Twine sends periodic readings of its temperature sensor and any external probes (moisture sensor) to the Supermechanical site. I was disappointed to find that there isn't currently a way to access those periodic readings. You can set rules

@mheffner
mheffner / gist:3880063
Created October 12, 2012 16:20
grab platform
#
# This module provides build platform lookup in the form qaweb requires.
#
module BuildPlatform
def self.get_platform(env)
"#{BuildPlatform.get_os}.#{BuildPlatform.get_arch(env)}"
end
def self.get_os
@mheffner
mheffner / README.md
Created October 3, 2012 18:11
Upload Travis CI builds to S3

Upload Travis CI builds to S3

This will demonstrate how to upload build files from Travis CI to S3.

NOTE: Keys have been changed to protect the innocent.

Step 1: Create an S3 policy.

Create an S3 ACL policy, see s3_policy.json for an example.

@mheffner
mheffner / simple ps1
Created September 7, 2012 14:08
My full PS1
# Prompt
export PROMPT_DIRTRIM=3
function getwintitle()
{
case $TERM in
xterm*|rxvt|Eterm|eterm)
# Set icon title
@mheffner
mheffner / gist:1296089
Created October 18, 2011 17:45
Chef roles ruby->json rake task
ROLE_DIR = File.expand_path('../roles', __FILE__)
namespace :roles do
desc "Convert ruby roles from ruby to json, creating/overwriting json files."
task :to_json do
Dir.glob(File.join(ROLE_DIR, '*.rb')) do |rb_file|
role = Chef::Role.new
role.from_file(rb_file)
json_file = rb_file.sub(/\.rb$/,'.json')
File.open(json_file, 'w'){|f| f.write(JSON.pretty_generate(role))}