Skip to content

Instantly share code, notes, and snippets.

View nistath's full-sized avatar

Nick Stathas nistath

View GitHub Profile
@nistath
nistath / benchmark.py
Created February 13, 2023 04:38
tiktoken benchmark
import os
import time
from typing import List
import tiktoken
def make_tiktoken_serial_benchmark(method_name: str):
def wrapped(documents: List[str], encoding: str) -> None:
enc = tiktoken.get_encoding(encoding)
@nistath
nistath / backport_rosbag2_py.patch
Last active July 12, 2022 12:36
Backport rosbag2_py to ROS2 Foxy
diff --git a/rosbag2_py/src/rosbag2_py/_reader.cpp b/rosbag2_py/src/rosbag2_py/_reader.cpp
index 731e627..51fa640 100644
--- a/rosbag2_py/src/rosbag2_py/_reader.cpp
+++ b/rosbag2_py/src/rosbag2_py/_reader.cpp
@@ -21,7 +21,7 @@
#include "rosbag2_cpp/readers/sequential_reader.hpp"
#include "rosbag2_cpp/reader.hpp"
#include "rosbag2_storage/storage_filter.hpp"
-#include "rosbag2_storage/storage_options.hpp"
+#include "rosbag2_cpp/storage_options.hpp"
@nistath
nistath / a_b_binarysearch.txt
Last active September 9, 2020 12:52
Project 1 Beta Indicative Performance Guidance on AWSRUN
Submitting Job: ./rotate -t tiers -M 47
Waiting for job to finish...
==== Standard Output ====
FYI: the max tier you can be graded on is 47.
Setting up test up to tier 47: Malloc 171968x171968 matrix...
Linear search from tier 0 to 8...
PASS (yay!): Tier 0 : Rotated 26624x26624 matrix in 94 ms
PASS (ayy!): Tier 1 : Rotated 27712x27712 matrix in 123 ms
PASS (skrrt!): Tier 2 : Rotated 28864x28864 matrix in 133 ms
PASS (eoo!): Tier 3 : Rotated 30080x30080 matrix in 126 ms
From 5b7e17417e31e52f5920608399d20696b03b87e6 Mon Sep 17 00:00:00 2001
From: Cattalyya Nuengsigkapian <cattalyy@mit.edu>
Date: Sat, 14 Sep 2019 23:01:46 -0400
Subject: [PATCH] [Fix] Speed up overhead in tiers testing. Fix malloc issue if
size is too large. Fix index overflow (32b to 64b) for very large size
matrix.
---
utils/libbmp.c | 5 +++++
utils/main.c | 13 +++++++++----
@nistath
nistath / cubemxcpy.py
Last active January 23, 2020 01:07
cubemxcpy is a python script to copy CubeMX generated files in a nice format into your project.
import re
from pathlib import Path
INP_DIR = Path('./cubemx/')
OUT_DIR = Path('./')
comment = r'/\*{}([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/'
any_comment = re.compile(comment.format(''))
user_comment = re.compile(comment.format(' USER'))
empty_comment_title = re.compile(comment.format('') + r'[\s\t\r\n]+(?=/\*)')
@nistath
nistath / terminator.vbs
Last active February 19, 2023 22:15 — forked from ropnop/startTerminator.vbs
Script to start terminator on WSL from CMD or PowerShell
' Usage: terminator[.vbs] [path to starting directory]
' contents enclosed in square brackets optional
args = "-c" & " -l " & """DISPLAY=:0 terminator"""
' If there's a single argument, interpret it as the starting directory
If WScript.Arguments.Count = 1 Then
dir = WScript.Arguments(0)
Else
dir = ""
@nistath
nistath / ibrokeit.py
Created August 10, 2018 21:03
This code is somehow non-deterministic...
import copy
import dataclasses
import types
from dataclasses import dataclass, field
from functools import wraps
from inspect import isclass
from typing import ClassVar, Set, Mapping, Callable, Dict, T
@dataclass
@nistath
nistath / tree.json
Created May 28, 2018 23:40
DAQapp API Examples
{
"can0": {
"FrontCanNodeBrakeThrottle": {
"accel_1": null,
"accel_2": null,
"brake_1": null,
"brake_2": null
},
"FrontCanNodeWheelSpeed": {
"front_right_wheel_speed": "mRPM",
#include "CANlib.h"
#include "evil_macros.h"
static Frame lastMessage;
static Can_ErrorID_T lastError = Can_Error_NO_RX;
#define DEFINE(name) \
Can_ErrorID_T name ##_Write(name ## _T *type) { \
Frame frame; \
pack_ ## name(type, &frame); \