Skip to content

Instantly share code, notes, and snippets.

View breqdev's full-sized avatar

Brooke Chalmers breqdev

View GitHub Profile
@breqdev
breqdev / ros2_sunburst.py
Created May 16, 2024 19:19
Sunburst visualization of bandwidth usage by topic/namespace in a ROS 2 system
from typing import Literal
import pcapng
topics: dict[bytes, bytes] = {}
hits: dict[bytes, int] = {}
def parse_submessage(data: bytes, offset: int) -> int:
msg_id = data[offset]
endian: Literal["little"] | Literal["big"] = "little" if data[offset + 1] else "big"

Keybase proof

I hereby claim:

  • I am breqdev on github.
  • I am breq (https://keybase.io/breq) on keybase.
  • I have a public key ASAWVwba81NxJa-ffsPk2k_1I9Mu7iiPpIkBlHuL3l4c6go

To claim this, I am signing this object:

import os
from dotenv import load_dotenv
import tweepy
load_dotenv()
handler = tweepy.OAuth1UserHandler(
os.getenv("TWITTER_CLIENT_KEY"), os.getenv("TWITTER_CLIENT_SECRET"), callback="oob"
)
@breqdev
breqdev / tilepirate.py
Created May 21, 2022 12:50
Download map tiles for an area
import math
import pathlib
import requests
root = pathlib.Path("tiles")
base_url = "https://tile.openstreetmap.org/{zoom}/{x}/{y}.png"
tile_format = "png"
def download_tile(zoom: int, x: int, y: int):
@breqdev
breqdev / stacking.ino
Created March 24, 2022 21:48
Stacking game I made using an ATTiny85 in March 2020.
#include <USI_TWI_Master.h>
#include <TinyWireM.h>
#include <avr/power.h>
#include <avr/sleep.h>
uint8_t dispbuf[8];
void initDisp(int brightness) {
TinyWireM.begin();
@breqdev
breqdev / launch.json
Last active March 23, 2022 20:40
Launch configuration to run Java programs using the Khoury Tester library
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Run using Tester",
"request": "launch",
"mainClass": "tester.Main",
"projectName": "${input:projectName}",
"args": "${input:examples}"
type LetterGuess = {
letter: string;
color: "gray" | "yellow" | "green";
};
let guess = "...";
let target = "...";
// Store the color alongside each guess letter
let guessLetters: LetterGuess[] = guess.split("").map((letter) => ({
@breqdev
breqdev / example.tsx
Last active February 11, 2022 03:26
React hook to keep track of a "dirty" flag and manage an interval which clears it.
export default function ArmSliderControl() {
const [joints, setJoints] = React.useState(JOINTS.map(() => 0));
const publish = useRosPublisher(topics.arm.positions);
const setDirty = useDirtyInterval(() => {
publish({
header: {
seq: 0,
stamp: {

Keybase proof

I hereby claim:

  • I am breq16 on github.
  • I am breq (https://keybase.io/breq) on keybase.
  • I have a public key ASDzngmuyD5spnJks3uFWsUZYuxP6YPVwAUVsTUbW7364Qo

To claim this, I am signing this object:

@breqdev
breqdev / wordify.py
Created January 9, 2018 03:39
Convert IPv6 addresses to words so that they'll be more memorable (in theory).
import ipaddress
import requests
words = requests.get(
"https://www.eff.org/files/2016/07/18/eff_large_wordlist.txt").text
words = words.split("\n")[:-1]
for word in range(len(words)):
words[word] = words[word].split("\t")[-1]