Skip to content

Instantly share code, notes, and snippets.

View dalehamel's full-sized avatar

Dale Hamel dalehamel

View GitHub Profile
#!/usr/bin/env ruby
require 'aws-sdk'
require 'json'
$stdout.sync = true
conf = JSON.load(File.read(ENV['CONFIG']))['aws']
credentials = Aws::Credentials.new(conf['access_key_id'], conf['secret_access_key'])
@dalehamel
dalehamel / gist:8535ac5b5c1ec1833cd5
Created May 29, 2015 02:39
on demand price scraper
require 'net/http'
require 'json'
def getPrices(path)
uri = URI(path)
res = Net::HTTP.get_response(uri)
data = res.body.match(/.*callback\((.*)\);/).captures[0]
data = data.gsub(/(\w+):/,"\"\\1\":")
d = JSON.parse(data)
# Uncomment to enable HiFiBerry overlay
# NOTE: You must disable the lirc-rpi overlay (or change lirc GPIO pin) for HiFiBerry to work correctly
# dtoverlay=hifiberry-amp
# dtoverlay=hifiberry-dac
# dtoverlay=hifiberry-dacplus
# dtoverlay=hifiberry-digi
@dalehamel
dalehamel / gist:090118571e0227acb11b
Last active September 25, 2015 17:23
Fixes cloudfront so it compiles / doesn't coredump
From 730472d4e7dbd507882563bdc50b85b6151eb0f5 Mon Sep 17 00:00:00 2001
From: Dale Hamel <dale.hamel@shopify.com>
Date: Fri, 25 Sep 2015 13:18:34 -0400
Subject: [PATCH] Fix cloudfront sort of
---
.../resource_aws_cloudfront_web_distribution.go | 90 +++++++++++-----------
1 file changed, 43 insertions(+), 47 deletions(-)
diff --git a/builtin/providers/aws/resource_aws_cloudfront_web_distribution.go b/builtin/providers/aws/resource_aws_cloudfront_web_distribution.go
@dalehamel
dalehamel / resize_root.sh
Last active January 4, 2016 17:47
Live root filesystem expansion in AWS
#!/bin/bash
# This script will resize the root filesystem on an AWS VM.
# When you create an AMI, you snapshot the root filesystem to be a particular size.
# When you actually launch an AMI, you can give it a volume that is actually larger than your filesystem.
# For instance, you can have an AMI with a root filesystem that's 8GB, but you can launch your host on a 40GB volume.
# It's perfectly safe to resize the system live to be the full extend of the volume it was launched on.
# This is done by deleting the primary partition (live), and recreating it to be the fully size of the actual device.
# Once that's done, we just grow the filesystem onto the now available space).
@dalehamel
dalehamel / control.rb
Created January 6, 2016 18:33
Control i3 from ruby
#!/usr/bin/env ruby
require 'json'
$displays={}
$active_display=nil
$max_workspace=-1
outputs=`i3-msg -t get_outputs`
JSON.parse(outputs).each do |output|
<?xml version="1.0" encoding="utf-8"?>
<ContinuousLabel Version="8.0" Units="twips">
<PaperOrientation>Landscape</PaperOrientation>
<Id>Tape6mm</Id>
<PaperName>6mm</PaperName>
<LengthMode>Auto</LengthMode>
<LabelLength>4015.859</LabelLength>
<RootCell>
<Length>2815.859</Length>
<LengthMode>Auto</LengthMode>
@dalehamel
dalehamel / gist:54d8f84d22f68ab40a34
Last active March 1, 2016 16:37
Pure ruby to read ethernet interface data
#!/usr/bin/env ruby
# Get interface information in pure ruby
# Credit to https://github.com/mpalmer/rethtool
#
# Examples:
# Get supported speeds of eth0:
# puts EthernetInterface.new('eth0').supported_speeds
# Determine if eth1 has a link
# puts EthernetInterface.new('eth1').link?
# Determine the current speed of eth1
@dalehamel
dalehamel / dmi.rb
Last active February 5, 2020 07:15
Ruby dmidecode
require 'json'
def standardize_key(k)
k.downcase.gsub(/\s+/,'_')
end
def read_dmi
data=`dmidecode`
dict={}
@dalehamel
dalehamel / .kitchen-docker.yml
Last active June 1, 2016 21:29
docker test kitchen for runit
driver:
name: docker
use_sudo: false # this depends if you need to do `sudo` to run `docker` command or not
disable_upstart: false
run_command: /sbin/init
provisioner:
name: chef_zero
platforms: