Skip to content

Instantly share code, notes, and snippets.

@brandonros
brandonros / gist:4aa6ae51d0f925671d034446947df555
Last active April 10, 2024 08:44
BMW UDS function descriptions
10 01;setDefaultSession
10 02;setProgrammingSession
10 03;setExtendedDiagnosticSession
11 01;hardReset
14 FF FF FF,31 01 0F 06,31 01 40 00 00,31 01 40 00 05,31 01 40 00 01;Clear all DTCs (clear DTC,clear Infospeicher,ZFS ***8211; DM_Lock,clear ZFS ***8211; DM_Clear,ZFS ***8211; DM_Unlock)
14 FF FF FF;Clear DTC
19 02 0C;ReadDTC(0C)
19 0A;ReadSupportedDTC
22 10 0A;readEnergyMode
22 10 0E;readExtendedMode
@brandonros
brandonros / bmw-esys-series-codes.java
Last active April 1, 2024 13:10
Extracted BMW F series ESYS commands (DME/ECU/Tune/Code)
// Random code sequences I found throughout a flashing tool
D = new hs("RCS_EraseCoding", "31 01 0F 01", 3, false);
e = new ha("DSC_DS", "10 01");
f = new ha("DSC_ES", "10 03");
g = new ha("DSC_PS", "10 02");
h = new ha("DSC_DEVS", "10 4F");
i = new ha("DSC_CS", "10 41");
j = new ku("RCS_SEMD", "31 01 0F 0C 00");
k = new ku("RCS_SEMF", "31 01 0F 0C 03");
#!/bin/bash
set -x
# run installer
curl -sfL https://get.k3s.io | sh -
# set up .kube/config for user
KUBECONFIG_CONTENT=$(sudo k3s kubectl config view --raw)
mkdir -p "/home/$USER/.kube"
@brandonros
brandonros / lit-element.html
Last active February 18, 2024 21:15
lit-element example with unpkg (no build), async API fetch() call, loading state, and styling
<!doctype html>
<html>
<head>
<script src="https://unpkg.com/@webcomponents/webcomponentsjs@2.0.0/custom-elements-es5-adapter.js"></script>
<script src="https://unpkg.com/@webcomponents/webcomponentsjs@2.0.0/webcomponents-bundle.js"></script>
<script type="module">
import { LitElement, css, html } from 'https://unpkg.com/lit-element@2.2.1/lit-element.js?module'
class SimpleGreeting extends LitElement {
static get styles() {
@brandonros
brandonros / stm32f407g-disc1-dfu-mode.md
Last active January 9, 2024 10:35
STM32F407G-DISC1/STM32F4DISCOVERY DFU mode
  1. Take every jumper off except JP1. Take both jumpers off CN3. Take the jumpers JP2 and JP3 off from the bottom of the board.
  2. Put a jumper between BOOT0 and VDD.
  3. Connect with a wire PA9 to 5V.
  4. Connect the device using the micro USB port, not the mini-USB port.
  5. sudo dfu-util -d 0483:df11 -a 0 -s 0x08000000 -D build/Example_Project.bin
  6. Unplug the device.
  7. Disconnect the BOOT0 jumper.
  8. Plug the device in.

Context

  • I am on Mac OS X arm64
  • I have 1 USB flash drive, not 2 (easy to write live USB installer to one and install to the other)
  • I do not have a Windows or Linux PC near by (can't format NTFS without pain, can't format ext4 without pain, etc.)
  • I want to prepare a USB flash drive that can be booted via a separate machine (non-Mac) via EFI (not legacy MBR).
  • I do not have Ethernet, just WiFi (no netboot capability)
  • I wanted the root filesystem to be compatible between Linux + Mac + Windows (NTFS/FAT32/ExFAT/EXT4 options; none meet this criteria)
  • I wanted to write Debian live image to USB stick, add toram boot parameter, turn around and install Debian to this USB stick. Did not work, doesn't come with debian-installer-launcher by default, had to add manually after manual wpa-supplicant config, then got a random error after partioning. live-toram also didn't work.
@brandonros
brandonros / preact-htm-example.html
Last active December 10, 2023 12:35
Preact + Hyperscript Tagged Markup (HTM) example
<!DOCTYPE html>
<html>
<head>
<title>Preact HTM Example</title>
</head>
<body>
<script type="module">
// 1. imports from unpkg.com
import * as Preact from 'https://unpkg.com/preact@10.4.7/dist/preact.module.js'
import htm from 'https://unpkg.com/htm@3.0.4/dist/htm.module.js'
@brandonros
brandonros / blueGreenDeployment.js
Created December 17, 2018 01:42
node.js + nginx + PM2 rolling release/blue green deployments (zero downtime)
const Promise = require('bluebird');
const fs = require('fs');
const execa = require('execa');
class BlueGreenDeployment {
constructor({appName, blueProxyPassPattern, greenProxyPassPattern, nginxConfigFile}) {
this.appName = appName;
this.blueProxyPassPattern = blueProxyPassPattern;
this.greenProxyPassPattern = greenProxyPassPattern;
this.nginxConfigFile = nginxConfigFile;
@brandonros
brandonros / dropbear.md
Last active November 23, 2023 00:41
Portable SSHD (Dropbear) on Windows with Cygwin
# build it with GitHub Actions: https://github.com/brandonros/dropbear/actions/runs/6964141533
# install Cygwin on the machine (probably need libcrypt package)
# run it from Cygwin terminal, not Git Bash or MinGW
mkpasswd -l > /etc/passwd
mkgroup -l > /etc/group
mkdir /etc/dropbear
mkdir ~/.ssh/
vi ~/.ssh/authorized_keys # paste ~/.ssh/id_rsa.pub into it, do not try to connect with passwords
./dropbear -F -E -R -w -s -g -j -k
root@vultr:~# journalctl -u k3s
Nov 05 20:29:09 vultr systemd[1]: Starting k3s.service - Lightweight Kubernetes...
Nov 05 20:29:09 vultr sh[18362]: + /usr/bin/systemctl is-enabled --quiet nm-cloud-setup.service
Nov 05 20:29:09 vultr systemctl[18363]: Failed to get unit file state for nm-cloud-setup.service: No such file or directory
Nov 05 20:29:09 vultr k3s[18368]: time="2023-11-05T20:29:09Z" level=info msg="Acquiring lock file /var/lib/rancher/k3s/data/.lock"
Nov 05 20:29:09 vultr k3s[18368]: time="2023-11-05T20:29:09Z" level=info msg="Preparing data dir /var/lib/rancher/k3s/data/e82313669fe2739df53b3870076163d1fe7785336a68b4771685219e51c9785d"
Nov 05 20:29:12 vultr k3s[18368]: time="2023-11-05T20:29:12Z" level=info msg="Starting k3s v1.27.7+k3s1 (b6f23014)"
Nov 05 20:29:12 vultr k3s[18368]: time="2023-11-05T20:29:12Z" level=info msg="Configuring sqlite3 database connection pooling: maxIdleConns=2, maxOpenConns=0, connMaxLifetime=0s"
Nov 05 20:29:12 vultr k3s[18368]: time="2023-11-05T20:29:12Z" level=info m