Skip to content

Instantly share code, notes, and snippets.

View anonymouse64's full-sized avatar
🍎
Think Different

Ian Johnson anonymouse64

🍎
Think Different
View GitHub Profile
@anonymouse64
anonymouse64 / mk_usb_swap.sh
Last active April 13, 2018 14:06
How to add usb drive as swap on Ubuntu Core using systemd
# get the usb device's id/info (for me this was /dev/sda1)
sudo blkid
# unmount it if it's currently mounted
sudo umount /dev/sda1
# make the device into swap space
##################################################################################
#### CAUTION THIS WILL ERASE EVERYTHING ON THE DRIVE #######################
#### PLEASE ENSURE THIS IS THE CORRECT DRIVE AND THERE'S #######################
#### NOTHING OF VALUE ON THE USB DRIVE #######################
##################################################################################
@anonymouse64
anonymouse64 / dashboard.js
Created April 17, 2018 15:48
EdgeXFoundry Grafana Device-Virtual dashboard
{
"__inputs": [
{
"name": "DS_EDGEX_INFLUX DATABASE",
"label": "EdgeX Influx database",
"description": "",
"type": "datasource",
"pluginId": "influxdb",
"pluginName": "InfluxDB"
}
@anonymouse64
anonymouse64 / unmarshaller-for-trevor.go
Last active March 8, 2019 05:54
how to unmarshal a custom type in go
package main
import (
"bytes"
"encoding/json"
"fmt"
"log"
"github.com/jinzhu/copier"
)
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
// split a file path into all the elements of the path
func filePathElements(f string) []string {
paths := make([]string, 0)
fTemp := f
lastElem := ""
for fTemp != "" && fTemp != "/" {
fTemp, lastElem = filepath.Split(filepath.Clean(fTemp))
paths = append([]string{lastElem}, paths...)
}
return paths
// singleFileHandler creates a http handler for a single statically specific
// file
// note that this doesn't use the url request path as the file, it uses the
// function argument as what file to serve
func singleFileHandler(f string) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Return a 404 if the file doesn't exist
info, err := os.Stat(f)
if err != nil {
if os.IsNotExist(err) {

Keybase proof

I hereby claim:

  • I am anonymouse64 on github.
  • I am anonymouse64 (https://keybase.io/anonymouse64) on keybase.
  • I have a public key ASDcVensJYOJ8cLQMVpCtfhb0tvE7eqNJiCHoP4MmkPX_Ao

To claim this, I am signing this object:

@anonymouse64
anonymouse64 / test-device-mqtt.sh
Created July 30, 2019 20:12
Test edgex-device-mqtt as a snap
#!/bin/bash -e
# remove any previous snaps
sudo snap remove edgexfoundry edgex-device-mqtt mosquitto
if ! command -v jq > /dev/null; then
sudo snap install jq
fi
# install edgex-device-mqtt, mosquitto, and edgexfoundry
// the user level header printing utility that initializes the recursion vars
// for wrapHeaderImpl
func wrapHeader(w io.Writer, name string, header interface{}, termWidth int) error {
return wrapHeaderImpl(w, name+":\t", false, header, 0, termWidth)
}
// the actual recursion implementation for a single header name + value pair
// intro in the first iteration is "name:", and becomes some combination of map
// keys for maps, whitespace, or "-" for lists in later iterations
1:supertuxkart:try:788629569:2322:1321:1555:1226:2500
1:supertuxkart:xz:589447168:3236:2185:2102:2153:19529
1:supertuxkart:none:759046144:2385:1397:1488:1510:5907
1:supertuxkart:lzo:623824896:13:1956:1774:1435:5771
1:supertuxkart:zstd:601939968:2424:1417:1483:1429:5974
1:chromium:try:620640480:2039:1733:1721:1723:1984
1:chromium:xz:165433344:5757:1546:1487:1522:15055
1:chromium:none:613453824:2292:2164:2083:2153:4809
1:chromium:gzip:213147648:2871:2684:1341:2744:4704
1:chromium:lzo:248094720:2278:2151:2066:1499:3674