Skip to content

Instantly share code, notes, and snippets.

View wzr1337's full-sized avatar

Patrick wzr1337

View GitHub Profile
@wzr1337
wzr1337 / main.py
Created December 7, 2023 14:30
tcp tester
import socket
import time
import threading
import argparse
# Constants
BUFFER_SIZE = 1024
MAX_MESSAGE_SIZE = 1400 # 1400 MTU
NUMBER_OF_MESSAGES = 10000
TICK_MILLISECONDS = 1 # Adjust the interval as needed
@wzr1337
wzr1337 / dtcmapping.json
Created April 27, 2021 10:04
OBD DTC diagnostic trouble code - a complete list (hopefully)
{
"P0000": "No trouble code",
"P0001": "Fuel Volume Regulator Control Circuit / Open",
"P0002": "Fuel Volume Regulator Control Circuit Range/Performance",
"P0003": "Fuel Volume Regulator Control Circuit Low",
"P0004": "Fuel Volume Regulator Control Circuit High",
"P0005": "Fuel Shutoff Valve Control Circuit / Open",
"P0006": "Fuel Shutoff Valve Control Circuit Low",
"P0007": "Fuel Shutoff Valve Control Circuit High",
"P0008": "Engine Position System Performance - Bank 1",
@wzr1337
wzr1337 / index.ts
Created August 16, 2018 07:28
A small colorful, timestamping typescript logger class
import { Logger } from "./logger";
Logger.log("just logging");
@wzr1337
wzr1337 / expectOptionally.ts
Last active May 5, 2018 21:22
How to expect optionally in jasmine. #Typescript solve: https://github.com/jasmine/jasmine/issues/1539
/**
* Create an optional expectation for a spec.
* @param actual Actual computed value to test expectations against.
*/
export function expectOptionally<T>(actual: any): jasmine.Matchers<T> {
if (!isNullOrUndefined(actual)) {
return expect(actual);
}
const voidExpect = new Proxy(expect(actual),
{

Some examples for comparison:

RSI GET /car/drivingstates/ receives a list of drivingStateObject VSS
drivingStateObject.yawRate Signal.Vehicle.Acceleration.Yaw
drivingStateObject.acceleratorPosition Signal.Chassis.Accelerator.PedalPosition
drivingStateObject.longitudinalAcceleration Signal.Vehicle.Acceleration.X
 drivingStateObject.lateralAcceleration Signal.Vehicle.Acceleration.Y
import RPi.GPIO as GPIO
import time
print GPIO.VERSION
#set up GPIO using BOARD numbering
GPIO.setmode(GPIO.BOARD)
GPIO.setup(12, GPIO.OUT)
GPIO.setup(16, GPIO.OUT)
GPIO.setup(18, GPIO.OUT)
@wzr1337
wzr1337 / localStorageMock.ts
Last active October 22, 2023 12:22
Mock localStorage for jasmine tests in TypeScript. This is the testing script. Copy the parts between snip and snap to mock your localStorage
/// <reference path="../../library.test.d.ts"/>
import * as angular from "angular"; angular;
import * as mocks from "angular-mocks/ngMock"; mocks;
describe('feat(localStorage Mock): ', function() {
beforeAll(() => {
angular.module('mock-module',[])
});
@wzr1337
wzr1337 / instal packagecontrol for sublime 3 behind proxy
Last active August 29, 2015 14:00
copy the following to your sublime console (show -> console), replace PROXY:PORT with your settings
import urllib.request,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404' + 'e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler({"http":"http://PROXY:PORT"})) ); by = urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
@wzr1337
wzr1337 / pull_all.sh
Created April 7, 2014 20:35
This script pulls all subdirectories
#! /bin/bash
find . -type d -depth 1 -exec git --git-dir={}/.git --work-tree=$PWD/{} pull origin master \;
// --------------------------------------------------
// Flexbox LESS mixins
// The spec: http://www.w3.org/TR/css3-flexbox
// --------------------------------------------------
// Flexbox display
// flex or inline-flex
.flex-display(@display: flex) {
.old-flex-display(@display);
display: ~"-webkit-@{display}";