Skip to content

Instantly share code, notes, and snippets.

@mmb
mmb / k8s_yaml_stream_parse.go
Created Jun 25, 2021
Parse a stream of kubernetes YAML on stdin into objects for reading
View k8s_yaml_stream_parse.go
package main
import (
"fmt"
"io"
"os"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
@mmb
mmb / gist:6a13776534edc055b4371769fa5dd0d9
Created May 19, 2020
let me know when the internet connection is fixed
View gist:6a13776534edc055b4371769fa5dd0d9
ping -o 8.8.8.8 && say 'internet is back'
@mmb
mmb / Makefile
Created Sep 27, 2018
Makefile for graphviz
View Makefile
SRCS = $(wildcard *.dot)
PDFS = $(patsubst %.dot,%.pdf,$(SRCS))
PNGS = $(patsubst %.dot,%.png,$(SRCS))
all: pdfs pngs
pdfs: $(PDFS)
pngs: $(PNGS)
@mmb
mmb / unencrypted_objects.rb
Created Nov 2, 2017
List objects in an S3 bucket with no server-side encryption
View unencrypted_objects.rb
require 'aws-sdk-s3'
client = Aws::S3::Client.new(region: 'us-west-2')
bucket = 'bucket1'
resp = client.list_objects(bucket: bucket)
resp.contents.each do |object|
metadata = client.head_object(bucket: bucket, key: object.key)
puts object.key unless metadata.server_side_encryption
View keybase.md

Keybase proof

I hereby claim:

  • I am mmb on github.
  • I am mm6 (https://keybase.io/mm6) on keybase.
  • I have a public key ASA-g12R4RPleAWVgxhACKtPPzlJQMkyBK2pupvVXHFCNgo

To claim this, I am signing this object:

View ipsec.conf
config setup
uniqueids=no
charondebug="enc 0, ike 2, knl 0, net 0"
conn ipsec-10.0.16.1/20
leftcert=instance_certificate.pem
auto=route
keyexchange=ike
esp=aes128gcm16!
type=transport
@mmb
mmb / gist:71a6e8a0a1ebb97c502e
Created Dec 6, 2015
javascript current time in beats
View gist:71a6e8a0a1ebb97c502e
<h1 id="time"></h1>
<script>
function toBeats(date) {
return ((date.getTime() / 1000.0) + 3600) % 86400 / 86.4;
}
function formatTime(date) {
return (date.getMonth() + 1) + "/" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes();
}
@mmb
mmb / cf-app-instances.sh
Last active Nov 14, 2015
get instance hosts and ports for a Cloud Foundry app
View cf-app-instances.sh
#!/bin/bash
set -eu
APP_NAME=$1
METADATA_URL=$(
cf curl /v2/apps?q=name:$APP_NAME |
jq -r .resources[0].metadata.url
)
@mmb
mmb / cloudformation_a_record_from_eip.json
Created Sep 29, 2015
creating a route 53 A record pointing to an elastic ip
View cloudformation_a_record_from_eip.json
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"aRecord": {
"Properties": {
"HostedZoneId": {
"Ref": "hostedZone"
},
"Name": "test.mmbtest.com",
"ResourceRecords": [
@mmb
mmb / graphite_grafana.sh
Last active Aug 4, 2017
graphite/statsd/grafana setup on new Amazon Linux instance
View graphite_grafana.sh
# graphite/statsd/grafana setup on new Amazon Linux instance
# add http://graphite/ to grafana as a data source
sudo su
yum update --assumeyes
yum install --assumeyes docker
service docker start
docker \
run \