Skip to content

Instantly share code, notes, and snippets.

Avatar

Brandon Ros brandonros

View GitHub Profile
@brandonros
brandonros / volumetric-efficiency-calculator.js
Last active Aug 3, 2020
VE (volumetric efficiency) calculator
View volumetric-efficiency-calculator.js
// 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 Aug 10, 2020
Preact + Hyperscript Tagged Markup (HTM) example
View preact-htm-example.html
<!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 / gist:9086f20135233b1fcf10212cc0830d31
Created Jul 31, 2020
OBD-II data/parameter identifier groups to log for ECU tuning
View gist:9086f20135233b1fcf10212cc0830d31
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 Jul 24, 2020
Set up a new Windows Server 2019 install from scratch for node.js native module compiling
View windows-server-2019.md

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

View gist:d0f4766e913a628a8f86c91c6656c4e0
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
View build-qemu-tricore.md

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

View opcode.rs
use crate::{masks};
pub enum Format {
// 16 bit formats
SB,
SBC,
SBR,
SBRN,
SC,
SLR,
@brandonros
brandonros / parse-tricore-instructions.js
Created Jun 17, 2020
Parse TriCore instructions from hex in node.js
View parse-tricore-instructions.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 {
View docker-extlinux.md

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)
@brandonros
brandonros / dockcross-kernel.sh
Created Jun 1, 2020
Compile Linux kernel with dockcross
View dockcross-kernel.sh
wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.6.15.tar.xz
tar -xf linux-5.6.15.tar.xz
cd linux-5.6.15
docker run --rm dockcross/linux-x64 > ./dockcross
chmod +x dockcross
./dockcross make defconfig
./dockcross make -j 4
You can’t perform that action at this time.