Skip to content

Instantly share code, notes, and snippets.

View DefProc's full-sized avatar

Patrick Fenner DefProc

View GitHub Profile
@DefProc
DefProc / node-red.service
Created September 23, 2020 13:14
node-red service file
# This script work on any system using systemd as the init process.
# To install (assuming root):
# vim /etc/systemd/system/node-red.service
# paste in the file contents
# systemctl daemon-reload
# systemctl enable node-red
# service node-red start
# service node-red status
@DefProc
DefProc / am102_decoder.js
Last active July 4, 2020 20:18
TTN decoder for AM100/AM102 sensors
function Decoder(bytes, port) {
// Decode an uplink message from a buffer
// (array) of bytes to an object of fields.
var decoded = {};
// for Ursalink AM100/AM102 Payload Structure
// From: https://resource.ursalink.com/document/am100_series_payload_structure.pdf
for (i = 0; i < bytes.length;) {
// BATTERY (%)
if (bytes[i] == 0x01 && bytes[i+1] == 0x75) {
@DefProc
DefProc / Connecting Sensors to the Internet using LoRaWAN Hackday.md
Created July 25, 2017 19:06
Connecting Sensors to the Internet using LoRaWAN Hackday @ttn_liv
@DefProc
DefProc / float_places.ino
Created May 31, 2017 08:31
Pass a second argument to print() or println() to set the number of decimal places in Arduino Serial library
float aNumber = 999;
void setup() {
Serial.begin(115200);
}
void loop() {
/* TIL:
* the second argument in print is the number of decimal
* places printed when passed a float/double
@DefProc
DefProc / scoreboard api.py
Last active June 26, 2023 18:57
get top games
"""
This module provides the application programming interface for the
scoreboard application.
"""
from aniso8601 import parse_datetime
from flask import jsonify, request
from scoreboard import app, db
from scoreboard.models import Game
//This code has the mode select commented out as well as the slider code
//The result is a faster joysticks code. There's a delay function that we use to
// slow the movemement of the arm down.
// Idle is also set at 100 which probably needs adjusting to stop the servos timing out so quickly.
#include <Servo.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
@DefProc
DefProc / gist:c4fcb4d0d89716bac599
Created April 1, 2015 11:18
Working Terms, UK Freelance Maker

Here are the steps we'd expect to go through when you contact us:

  1. talking through your project,
  2. offering tangible outcomes,
  3. accepting the contract and initial payment,
  4. production,
  5. presentation of the result,
  6. final payment.

Talking Through

Keybase proof

I hereby claim:

  • I am defproc on github.
  • I am defproc (https://keybase.io/defproc) on keybase.
  • I have a public key whose fingerprint is 0609 98FA B752 E884 F436 04D8 DBA4 D53D 7172 B870

To claim this, I am signing this object:

@DefProc
DefProc / gist:4f1122d9f591746b554a
Created January 5, 2015 14:43
generate random locally administered MAC address
# choose the leading octet:
echo -en '\x06' | xxd -b
# gives:
# 0000000: 00000110
# where these ↑↑ digits must be 10
# i.e. an octet with the the hex representation x2, x6, xA or xE
# then take the chosen octet and append a random number:
echo -n "06:" ; openssl rand -hex 5 | sed 's/\(..\)/\1:/g; s/.$//'
@DefProc
DefProc / gist:22a3916c25e2fa307e13
Last active August 29, 2015 14:11
command line cheerlights checker
echo '#!/bin/bash
curl http://api.thingspeak.com/channels/1417/field/1/last.txt' > cl
chmod +x cl
./cl