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"

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 / 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 / readtsc.c
Created May 13, 2011 19:21
Report gettimeofday, TSC and getrusage(self) periodically while performing I/O workload.
/*
* Dumps the value of gettimeofday(), the TSC, and
* getrusage(RUSAGE_SELF) every two seconds while performing some fake
* I/O workload on a /tmp file.
*
* Build: gcc -o readtsc readtsc.c -lrt
*/
#include <stdio.h>
@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 / 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 / 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))}
@mheffner
mheffner / emspawn.rb
Created October 18, 2011 00:01
How to spawn sub-procs with EM and capture all output (stdout and stderr)
module Spawner
class SpawnedJob < EventMachine::Connection
def initialize(params)
@output = ""
@dfr = params[:deferrable]
super
end
def notify_readable
begin
@mheffner
mheffner / gist:1211868
Created September 12, 2011 17:39
Setting Monitoring Tags with Passenger and Librato Silverline
# See this article for how to tag processes:
# http://support.silverline.librato.com/kb/monitoring-tags/using-monitoring-tags
#
####
# Apache config option:
# See: http://www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerRuby
#
PassengerRuby /path/to/ruby_wrapper.sh