Skip to content

Instantly share code, notes, and snippets.

View danhigham's full-sized avatar

Dan Higham danhigham

  • ZScaler
  • Portland, OR
View GitHub Profile
@danhigham
danhigham / container_devices
Created March 18, 2016 23:44
Function to allow access to host devices from a container
function permit_device_control() {
local devices_mount_info=$(cat /proc/self/cgroup | grep devices)
local devices_subsytems=$(echo $devices_mount_info | cut -d: -f2)
local devices_subdir=$(echo $devices_mount_info | cut -d: -f3)
if [ ! -e /tmp/devices-cgroup ]; then
mkdir /tmp/devices-cgroup
mount -t cgroup -o $devices_subsytems none /tmp/devices-cgroup
fi
@danhigham
danhigham / fsm_dc.ino
Last active June 8, 2017 13:55
Dust collection with an Arduino
#include <Fsm.h>
#include "EmonLib.h"
#define RELAY1_PIN 7
#define LED_PIN 13
#define ON 1
#define OFF 0
#define THRESHOLD 4
@danhigham
danhigham / main.go
Last active June 9, 2017 20:27
Go app to display images on a Pi based photo frame
package main
import (
"encoding/json"
"os"
"os/exec"
"io"
"io/ioutil"
"log"
"net/http"
@danhigham
danhigham / Hello.rb
Created July 26, 2017 15:47
Test gist
require 'rubygems'
@danhigham
danhigham / index.md
Created September 28, 2017 14:29
Pushing with multiple buildpacks

Manifest looks like this;

---
name: ssas
memory: 256MB
instances: 1

If I want to push the app with multiple buildpacks, I do this;

@danhigham
danhigham / response.json
Created November 13, 2017 00:05
Response from GMusic
{
"response": {
"card": {
"image": {
"largeImageUrl": "https://lh3.googleusercontent.com/53cYhGcuBl6tJh4NAsrkxHW2dYReUv27bwrA1nb_KNCrgIKeGjhfl-NmUzsu6mJGoyg1UBuvpDM",
"smallImageUrl": "https://lh3.googleusercontent.com/53cYhGcuBl6tJh4NAsrkxHW2dYReUv27bwrA1nb_KNCrgIKeGjhfl-NmUzsu6mJGoyg1UBuvpDM"
},
"text": "",
"title": "Playing top tracks by Radiohead",
"type": "Standard"
@danhigham
danhigham / xmas_leds.ino
Created December 23, 2017 04:45
xmas_leds.ino
#include <bitswap.h>
#include <chipsets.h>
#include <color.h>
#include <colorpalettes.h>
#include <colorutils.h>
#include <controller.h>
#include <cpp_compat.h>
#include <dmx.h>
#include <FastLED.h>
#include <fastled_config.h>
@danhigham
danhigham / uap-ac-lite-openwrt.txt
Created January 27, 2018 04:47 — forked from lg/uap-ac-lite-openwrt.txt
making the ubnt wifi awesome (uap ac lite) w/ openwrt
making the ubnt wifi awesome (uap ac lite) w/ lede (openwrt)
the reasons you would do this:
- you get 802.11r
- you get better roaming
- you get access to some new 5ghz channels
I AM NOT TO BE HELD RESPONSIBLE FOR ANYTHING IN HERE. DO AT YOUR OWN RISK. THANK YOU AND HAVE A LOVELY DAY.
** note that though we're using Lede, it's essentially openwrt minus the drama
@danhigham
danhigham / cf_dump.py
Created June 25, 2018 04:37
Dump CF Meta
#!/usr/bin/python
import json, subprocess
def cf_curl_json(cmd):
return json.loads(subprocess.Popen(("cf curl %s | jq '.resources[].entity' | jq --slurp '.'" % cmd),
stdout=subprocess.PIPE, shell=True).communicate()[0])
ORGS_SPACEURLS = [ (str(org['name']), str(org['spaces_url'])) for org in cf_curl_json("/v2/organizations") ]
for org, spaces_url in ORGS_SPACEURLS:
ORG_SPACE_APPURLS = [ (org, str(space['name']), str(space['apps_url'])) for space in cf_curl_json(spaces_url) ]
for org, space, app_url in ORG_SPACE_APPURLS:
@danhigham
danhigham / main.go
Last active December 13, 2018 00:27
Hall of shame, cf memory consumption
package main
import (
"bufio"
"fmt"
"os"
"sort"
"strings"
"syscall"