Skip to content

Instantly share code, notes, and snippets.

View mengstr's full-sized avatar

Mats Engstrom mengstr

View GitHub Profile
@mengstr
mengstr / gist:3ad65f5a3352f26ae63d7a737221deda
Last active March 13, 2024 09:58
How to associate .dig files to Digital in macOS
Normally macOS can't associate and run a specified shell script when you doubleclick on a file, but the macOS Automator can make it work.
Here's the steps:
* Run the Automator app and choose "Create new"
* Drag “Run Shell Script” into grey area
![apptype in automator](https://mengstr.github.io/gist-images/Digital/automator-app-type.png)
@mengstr
mengstr / gist:3461b279518b3e0e31fae7f1c4a2a573
Created June 11, 2023 14:35
WCH trace of USB comms for Read Protection on/off
Info 810d0101 820d0402091200
? 810c020901 820c0101
Info 810d0102 820d050900300500
Protect 81060802f7ffffffffffff 82060102
Reset 810b0101 820b0101
Info 810d01ff 820d01ff
Info 810d0101 820d0402091200
? 810c020901 820c0101
Info 810d0102 820d050900300500
Protect 81060104 82060100
@mengstr
mengstr / gist:0dc45232d109d0b17390746cd5210c58
Created June 2, 2023 08:16
USB Vendor Enumeration on Win11
225.261250 SYNC SETUP
225.271958 Address=0x00 Endpoint=0x00
225.286000 SYNC DATA0
225.296667 bmRequestType=0x80 Data direction=Device to host, Type=Standard, Recipient=Device
225.302042 bRequest=0x06 GET_DESCRIPTOR
225.307375 wValue=0x0100 Descriptor=DEVICE, Index=0x00
225.318000 wIndex=0x0000
225.328708 wLength=0x0040
@mengstr
mengstr / gist:74dbfac2c64dff2dc3c8fe2bd491900d
Last active June 2, 2023 08:17
VUSB Vendor Enumeration MacOS
431017708 SETUP
Address=0x00 Endpoint=0x00
431042417 DATA0
bmRequestType=0x00 Data direction=No data, Type=Standard, Recipient=Device
bRequest=0x05 SET_ADDRESS
wValue=0x0008 Address=0x08
wIndex=0x0000
wLength=0x0000
@mengstr
mengstr / restart.go
Last active June 1, 2022 15:23
golang auto-restart app during development
// "github.com/fsnotify/fsnotify"
watcher, err := fsnotify.NewWatcher()
defer watcher.Close()
go func() {
for {
select {
case event, _ := <-watcher.Events:
fmt.Printf("PID %d, Event %v\n", os.Getpid(), event)
if event.Op&fsnotify.Create == fsnotify.Create || event.Op&fsnotify.Write == fsnotify.Write {
@mengstr
mengstr / setupLAMP.sh
Last active March 15, 2021 11:13
Setup a Azure Ubuntu 18.04 for LAMP development
#
# Setup of LAMP on virgin Azure Ubuntu 18.04
# Run this as root
#
# Version 2021-03-15a
#
SITE=$1
EMAIL=$2
if [[ -z "$SITE" ]] || [[ -z "$EMAIL" ]]; then
@mengstr
mengstr / gist:013a13256eb5ec74dfb962b8f83601b2
Created December 21, 2019 21:49
List of generatable PLL output frequencies
#
# for c in {16000..275000..1}; do f=$(awk "BEGIN {print $c/1000}"); o=$(icepll -i 100 -o $f | grep achieved | tr -c -d 0-9\.); echo $f is $o; done > plltable.txt
# cat plltable.txt | uniq -f 1 | pbcopy
#
16 is 16.016
16.044 is 16.071
16.083 is 16.094
16.12 is 16.146
16.179 is 16.211
@mengstr
mengstr / sorttest.asm
Last active May 7, 2019 18:03
Atari 2600 sorting of 8 byts of data
;
; Results for sorting 8 bytes
;
; First value is the number of scanlines required for pre-sorted data, second is
; for data that is fully reverse order.
;
; Yellow 3.0 - 7.5 (369 bytes) Continous Unrolled
; Orange 7.5 - 12.0 (262 bytes) Continous Subroutined
; Red 4.0 - 9.0 (138 bytes) Continous Fallthrough
; Blue 2.4 - 29.9 ( 51 bytes) Bubblesort
curl "https://circleci.com/gh/SmallRoomLabs/circleci-demo-go/tree/master.svg?style=shield&circle-token=632f67b7a9980f59c8b802d6a155885b55313a70"
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="93" height="20">
<linearGradient id="b" x2="0" y2="100%">
<stop offset="0" stop-color="#bbb" stop-opacity=".1" />
<stop offset="1" stop-opacity=".1" />
</linearGradient>
<mask id="a">
<rect width="93" height="20" rx="3" fill="#fff" />
@mengstr
mengstr / gpioblink.ino
Last active November 5, 2022 18:34
Blink the blue LED on a NodeMCU using direct port manipulation