Skip to content

Instantly share code, notes, and snippets.

ssh -N -L 3389:127.0.0.1:3389 user@HOST
./websockify.js 0.0.0.0:6080 127.0.0.1:3389
https://novnc.com/noVNC/vnc.html -> advanced -> websocket
host: 127.0.0.1
port: 6080
encrypt: no
path: websockify
@brandonros
brandonros / volumetric-efficiency-calculator.js
Last active August 3, 2020 02:53
VE (volumetric efficiency) calculator
// from https://atgtraining.com/atg-volumetric-efficiency-calculator/
const calculateVe = ({engineSize, rpm, maf, iat, cylinder, pressuure, mafSelection, iatSelection, pressureSelection}) => {
let val = 0, cid = 0, lb = 0, degc = 0, degf = 0, tempK = 0, v = 0, molorMass = 0.28705, gb_air_vol = 0, gsec = 0;
let gb_theo_air_vol = 0, lMin = 0, estv = 0, load = 0, cylAir = 0, refCylAir = 0, estGross = 0, estRWHP = 0;
cid = engineSize / 0.0163871;
if (mafSelection == 0) { // g/sec
lb = maf * 0.00220462 * 60;
} else { // lb/min
gsec = maf / (0.00220462 * 60);
@brandonros
brandonros / preact-htm-example.html
Last active August 9, 2024 04:32
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/[email protected]/dist/preact.module.js'
import htm from 'https://unpkg.com/[email protected]/dist/htm.module.js'
@brandonros
brandonros / gist:9086f20135233b1fcf10212cc0830d31
Created July 31, 2020 03:53
OBD-II data/parameter identifier groups to log for ECU tuning
1. general (rpm, speed, gear, time)
2. engine load (actual + target)
3. torque (actual + target)
4. accelerator pedal angle
5. throttle body angle
6. boost (actual + target)
7. wastegate duty cycle
8. fuel trims (short term)
9. fuel pressure (low + high)
10. ignition timing (all cylinders + average)
@brandonros
brandonros / windows-server-2019.md
Last active July 24, 2020 15:54
Set up a new Windows Server 2019 install from scratch for node.js native module compiling

1. Enable SSH

Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Start-Service sshd
Set-Service -Name sshd -StartupType "Automatic"
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -PropertyType String -Force

2. Install Choco package manager

Brandons-MacBook-Pro-2:can-utils-rs brandonros$ cargo build
Compiling can-utils-rs v0.0.1 (/Users/brandonros/Desktop/can-utils-rs)
error[E0382]: use of moved value: `frame`
--> src/main.rs:57:65
|
55 | let mut handler = move |frame: Vec<u8>| {
| ----- move occurs because `frame` has type `std::vec::Vec<u8>`, which does not implement the `Copy` trait
56 | for websocket in websockets.lock().unwrap().iter() {
57 | let binary_frame = tungstenite::Message::Binary(frame);
| ^^^^^ value moved here, in previous iteration of loop

./configure --target-list=tricore-softmmu &amp;&amp; make -j 4 &amp;&amp; ./tricore-softmmu/qemu-system-tricore --machine tricore_testboard -nographic -D /tmp/qemu.log -d in_asm,out_asm,op,cpu,exec,mmu -singlestep

use crate::{masks};
pub enum Format {
// 16 bit formats
SB,
SBC,
SBR,
SBRN,
SC,
SLR,
@brandonros
brandonros / parse-tricore-instructions.js
Created June 17, 2020 02:25
Parse TriCore instructions from hex in node.js
const parseInstructions = (input) => {
const instructions = []
let i = 0
while (i < input.length) {
const instructionLow = input.readUInt16LE(i)
const is16Bit = (instructionLow & 0x01) === 0x00
if (is16Bit) {
instructions.push(instructionLow)
i += 2
} else {

Compiling kernel

wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.7.tar.xz
tar -xf linux-5.7.tar.xz
cd linux-5.7
docker run --rm dockcross/linux-x64 > ./dockcross
chmod +x ./dockcross
./dockcross make defconfig
./dockcross make -j $(sysctl -n hw.ncpu)