Skip to content

Instantly share code, notes, and snippets.

View developerfromjokela's full-sized avatar
🪑
chil

DFJ developerfromjokela

🪑
chil
View GitHub Profile
@developerfromjokela
developerfromjokela / nksum.py
Created May 8, 2025 11:16
Calculate NK update file SUM, Xanavi/Clarion 72xx
import argparse
def compute_checksum_and_verify(data: bytes) -> bool:
data_array = bytearray(data)
checksum_offset = 0x30
# Read and temporarily clear the stored checksum for region 0
original_checksum = int.from_bytes(data_array[checksum_offset:checksum_offset+2], byteorder='little')
data_array[checksum_offset:checksum_offset+2] = [0, 0]
# Calculate checksum by summing all bytes
@developerfromjokela
developerfromjokela / configuration.yaml
Created April 30, 2025 13:21
OpenCARWINGS Home Assistant template, add this to yoru configuration
template:
- binary_sensor:
- name: "EV Charging"
unique_id: ev_charging
device_class: battery_charging
state: >
{{ state_attr('sensor.ev_raw_data', 'ev_info').charging }}
- name: "EV Quick Charging"
unique_id: ev_qc_charging
device_class: battery_charging
@developerfromjokela
developerfromjokela / main.py
Created February 16, 2025 20:49
KWP extract
import sys
import struct
def extract_firmware(input_file, output_file):
DEFAULT_OUTPUT_SIZE = 300 * 1024 * 1024 # 1MB
total_bytes_extracted = 0
try:
with open(input_file, "rb") as infile:
@developerfromjokela
developerfromjokela / laskuri.py
Last active July 25, 2023 17:50
Wilma opintopiste laskuri
import requests
# Wilma2SID= cookie value here
SESSION = ""
# Your Wilma Base URL
BASEURL = "https://example.inschool.fi/!0249962/"
# Schedule ID as ENV if you know already, otherwise select using CLI
SCHEDULE = os.environ.get("SCHEDULE", '')
@developerfromjokela
developerfromjokela / parse.js
Created June 27, 2021 23:15
Parse Wilma Course Tray schedule generator
const {parseData} = require('./utils');
let jsonConf = "{\"others\":[{\"data\":\"1,585,75\",\"text\":\"vENA11.1, tukikurssi\"},{\"data\":\"1,670,105\",\"text\":\"vSAA05.1\"},{\"data\":\"1,785,75\",\"text\":\"vMAA05.3\"},{\"data\":\"1,870,75\",\"text\":\"vYH02.3\"},{\"data\":\"2,585,75\",\"text\":\"vSAA05.1\"},{\"data\":\"2,670,105\",\"text\":\"vÄI04.2\"},{\"data\":\"2,870,75\",\"text\":\"vOP06.3, HYK20C, klo 13.05-13.20\"},{\"data\":\"3,495,75\",\"text\":\"vYH02.3\"},{\"data\":\"3,585,75\",\"text\":\"vÄI04.2\"},{\"data\":\"3,670,105\",\"text\":\"vENA11.1, tukikurssi\"},{\"data\":\"4,585,75\",\"text\":\"vMAA05.3\"},{\"data\":\"4,670,105\",\"text\":\"vSAA05.1\"},{\"data\":\"4,785,75\",\"text\":\"vYH02.3\"},{\"data\":\"5,585,75\",\"text\":\"vENA11.1, tukikurssi\"},{\"data\":\"5,670,105\",\"text\":\"vMAA05.3\"},{\"data\":\"5,785,75\",\"text\":\"vÄI04.2\"}],\"checksum\":\"CE2089E\"}";
jsonConf = JSON.parse(jsonConf);
let multiplier = 1;
let globalItems = [];
jsonConf.others.forEach(item => {
let items = pars
@developerfromjokela
developerfromjokela / abitti_versionscan.py
Last active May 26, 2021 22:35
Scan all abitti versions and save them to a file
import json
from datetime import datetime
import remotezip
import requests
versionList = []
versions = {
"ktp": [],
"koe": []
#include <Servo.h>
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
}
void loop() {
@developerfromjokela
developerfromjokela / puumalligen.js
Created March 21, 2021 18:53
Crude Built-in-five-minute tree generator (only two layers) (do not use, code is shit and could break!)
let main = ["vanilja", "mansikka", "sulkaa", "päärynä"];
let sub = ["sulkaa", "kinuski"];
let tree = {};
main.forEach(item => {
tree[item] = sub;
})
@developerfromjokela
developerfromjokela / iterator.ts
Created February 7, 2021 09:57
Async iterator for typescript
/*
* Copyright (c) 2021 wilmaplus-notifier2, developed by @developerfromjokela, for Wilma Plus mobile app
*/
export class AsyncIterator<T> {
currentItem = -1
items: T[]
callback:(item: T, iterator: AsyncIterator<T>) => void;
endCallback:() => void;
@developerfromjokela
developerfromjokela / script.js
Last active February 4, 2021 14:43
Script to generate auth token, R-Kioski Postman Pre-request script
function uuidv4() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
function sha256(content) {
return CryptoJS.enc.Hex.stringify(CryptoJS.SHA256(content));