Skip to content

Instantly share code, notes, and snippets.

@rsaxvc
rsaxvc / serial_scan.py
Created January 16, 2021 21:53
scan serial ports
#Scan a serial port at different baud rates looking for a human-readable terminal
#By: RSAXVC
import serial
#List of possible baud rates to scan
bauds = [ 110, 150, 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600]
#Path to POSIX port or Windows COM#
port = '/dev/ttyUSB0'
@rsaxvc
rsaxvc / mips32_kreg_printer.cpp
Created January 1, 2021 06:01
MIPS K0/K1 Kernel Register Printer
#include <unordered_set>
#include <cstdio>
//Represents bits from a register
#define reg_t unsigned
//Keep track of register contents seen already
std::unordered_set<reg_t> ks;
//Read either K0 or K1
@rsaxvc
rsaxvc / pyaudioDemo.py
Created July 2, 2019 01:36
pyAudio bidirectional callback example with graph
#pyAudio demo by RSAXVC
#Generates a transmit waveform of a near frequency,
#and plays it in a loop, while listening to the mic
#and plotting it
import pyaudio
import numpy as np
import struct
import matplotlib.pyplot as plt
import matplotlib.animation as animation
@rsaxvc
rsaxvc / low-overhead-cobs.py
Created January 9, 2019 05:05
Low-Overhead COBS Encoder
#COBS encoder using minimal buffer instead of encoding entire buffer at once
#Passes unit tests from Wikipedia page
class cobsEncoder:
def __init__(self):
self.cobsBuffer = b''
self.postZero = False
def encode(self,data):
for d in data:
if d == b'\x00':
@rsaxvc
rsaxvc / boinc_autobalance.sh
Created January 3, 2017 06:07
Cron Script to assign distinct CPU cores to Boinc jobs.
#!/bin/bash
#This script assumes #BOINC <= #Cores. To fix this, use a modulo function.
CORE=0
pgrep -f "/usr/lib/virtualbox/VBoxHeadless --comment boinc_" | while read -r pid ; do
taskset -a -pc "$CORE" "$pid" #This locks the VM to a specific core.
CORE=$((CORE+1)) #Use this without hyperthreading
#CORE=$((CORE+2)) #Use this with hyperthreading
done
@rsaxvc
rsaxvc / interfaces
Last active March 15, 2021 04:48
/etc/network/interfaces file for Linux router
# This file describes how to configure a Linux computer as a router for GoogleFiber.
# References:
# https://wiki.debian.org/NetworkConfiguration#Bridges_and_VLANs
# https://wiki.debian.org/BridgeNetworkConnections#Configuring_bridging_in_.2Fetc.2Fnetwork.2Finterfaces
# http://flyovercountry.org/2014/02/google-fiber-gigabit-speeds-your-router-part-2-qos/
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
#include <stdlib.h>
/*
* example.c
*
* This file illustrates how to use the IJG code as a subroutine library
* to read or write JPEG image files. You should look at this code in
* conjunction with the documentation file libjpeg.txt.
*
* This code will not do anything useful as-is, but it may be helpful as a
* skeleton for constructing routines that call the JPEG library.
#!/usr/bin/perl
#
# Eric Jiang
# http://notes.ericjiang.com/posts/54
# This software is public domain.
#
use bytes;
my $data;