Skip to content

Instantly share code, notes, and snippets.

View danawoodman's full-sized avatar
👨‍🔬
Hacking away...

Dana Woodman danawoodman

👨‍🔬
Hacking away...
View GitHub Profile
@danawoodman
danawoodman / How to build a Golang application for a Raspberry Pi.md
Last active February 7, 2024 00:02
How to build a Golang application for a Raspberry Pi

How to build a Golang application for a Raspberry Pi

Given a binary at cmd/server/main.go, create a binary at bin/server that is built for a Raspberry Pi:

env GOOS=linux GOARCH=arm GOARM=5 go build -o ./bin/server ./cmd/server/main.go
@danawoodman
danawoodman / Using Golang templ with the Echo framework.md
Last active July 15, 2025 09:57
Using Golang templ with the Echo framework

Using Golang templ with the Echo framework

templ is a great view framework but there is no clear documentation (as of writing) showing how to use it with the Echo web framework. This short guide should show you how to set it up:

Install dependencies

Install templ and echo:

go get github.com/a-h/templ
@danawoodman
danawoodman / add-saved-to-list.js
Last active July 17, 2023 22:44
Add your Saved for Later items in your Amazon shopping cart to your first (primary) Wish List
await run();
async function run() {
let loop = 0;
while (true) {
loop++;
console.log("loop:", loop);
const items = get_items();
if (!items.length) break;
@danawoodman
danawoodman / Field.svelte
Created September 16, 2020 15:16
Example of using Svelte (with Typescript) to make a simple login form with basic validation. Lot is missing but shows how a few useful concepts
<script lang="ts">
export let label: string
export let type: string = "text"
export let value: string = ""
export let disabled: boolean = false
export let validate: (val: string) => boolean
export let valid: boolean = false
let id = `field-${Math.floor(Math.random() * 1000)}`

Hello world

This is a test.

  • Foo
  • Bar
  • Baz

Hello

@danawoodman
danawoodman / examples.js
Created March 11, 2019 20:24
Javascript array examples
// Lots of examples here:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
const arr = [ 1, 2, 3 ]
// first item in array:
arr[0]
// last item:
arr[2]
SUBSYSTEM=="input", GROUP="input", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="05df", MODE:="666", GROUP="plugdev"
KERNEL=="hidraw*", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="05df", MODE="0666", GROUP="plugdev"
@danawoodman
danawoodman / relay-improved.js
Created July 19, 2018 04:56
Control a generic USB relay using node-hid. Handles up to 8 relays.
/**
* Control a USB relay board using USB.
*
* This code helped a lot in the understanding of what they boards
* expect for hex inputs:
* https://github.com/jaketeater/Very-Simple-USB-Relay/blob/master/relay.py
*/
const HID = require('node-hid')
const ALL_ON = 0xfe
@danawoodman
danawoodman / relay.js
Last active July 19, 2018 03:28
Turn on a generic USB relay using node-hid, naive approach
/**
* Control a USB relay board using USB.
*
* This code helped a lot in the understanding of what they boards
* expect for hex inputs:
* https://github.com/jaketeater/Very-Simple-USB-Relay/blob/master/relay.py
*/
const HID = require('node-hid')
const ON = 0xfe
@danawoodman
danawoodman / react-router-basic.js
Last active July 3, 2018 05:35
Basic React Router setup with Async
import React, { Component } from "react";
import logo from "./logo.svg";
import "./App.css";
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
const COMPANIES = [
{
id: 1,
name: "Foo",
accounts: [{ id: 4, name: "SubAccount", accounts: [] }]