Skip to content

Instantly share code, notes, and snippets.

@chazcheadle
chazcheadle / getUserRepositories.go
Created September 15, 2016 03:58
Golang go-github example to list a user's public repositories
package main
import (
"fmt"
"github.com/google/go-github/github"
)
func main() {
@chazcheadle
chazcheadle / nvm_test.sh
Created September 8, 2016 20:29
nvm_test.sh
#!/bin/bash
if command -v nvm 1&>2 >/dev/null; then
if [ -f "$HOME/.nvmrc" ]; then
nvm use
echo -n "Using Node: `nvm current`"
else
echo -n "nvm installed but .nvmrc not found."
fi
else
echo -n "nvm not installed"
@chazcheadle
chazcheadle / cameras.yml
Created August 27, 2016 04:12
Publish JSON endpoint to list available camera resources (HTTP 200) loaded from a YAML config file written in Golang
cameras:
Exterior (South):
camera_id: hab_camera-1
url : http://HOST:8091/?action=stream
low_image : http://HOST:8091/low.png
type : mjpeg-streamer
Exterior IR (South):
camera_id: hab_camera-2
url : http://HOST:8090/?action=stream
low_image : http://HOST:8090/low.png
@chazcheadle
chazcheadle / camera_mon.go
Last active September 29, 2022 22:57
Golang/MQTT service to monitor webcam snapshots and send status
package main
import (
"encoding/json"
"io"
"io/ioutil"
"os"
"sort"
"time"
@chazcheadle
chazcheadle / hab_camera-1.sh
Created August 19, 2016 16:29
mjpg_streamer: Out put http and file to custom directory
#!/bin/sh
# Check for image directory and create it if it doesn't exist.
s=${0##*/}
image_dir="/tmp/${s%.*}"
if [ ! -d $image_dir ]
then
mkdir $image_dir
echo "Created $image_dir.";
@chazcheadle
chazcheadle / send_image_mqtt.go
Created August 18, 2016 03:31
Golang: Send image over MQTT
package main
import (
"fmt"
"io/ioutil"
"os"
log "github.com/Sirupsen/logrus"
MQTT "github.com/eclipse/paho.mqtt.golang"
)
@chazcheadle
chazcheadle / server-main.go
Created August 17, 2016 16:18
Golang/MQTT JSON server timestamp
package main
import (
"fmt"
"encoding/json"
"os"
"time"
MQTT "github.com/eclipse/paho.mqtt.golang"
)
@chazcheadle
chazcheadle / mjpg-streamer.service
Created August 2, 2016 15:56
mjpg-steamer.service and script
[Unit]
Description=mjpg-streamer
[Install]
WantedBy=multi-user.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/opt/mjpg-streamer/mjpg-streamer-experimental/mjpg-streamer.sh
@chazcheadle
chazcheadle / mosquitto.service
Created August 2, 2016 15:13
Mosquitto MQTT Broker systemd start up script
[Unit]
Description=Mosquitto MQTT Broker daemon
ConditionPathExists=/etc/mosquitto/mosquitto.conf
After=network.target
Requires=network.target
[Service]
Type=forking
RemainAfterExit=no
StartLimitInterval=0
@chazcheadle
chazcheadle / timerbuttons.ino
Last active April 12, 2016 15:29
Arduino clock source for 6502 with start/stop and step buttons
#define LED 13
#define startButton 2
#define stepButton 3
volatile int ledState;
bool run = false;
int buttonState;
int lastButtonState;