Skip to content

Instantly share code, notes, and snippets.

View protortyp's full-sized avatar
🚀

Christian Engel protortyp

🚀
  • Boston / Munich
  • 11:31 (UTC +02:00)
View GitHub Profile

Proptest

  • everything is built around the concept of a Strategy
  • a Strategy can be a collection of other strategies, or a single Strategy
  • a Strategy returns a ValueTree that shrinks or complicates a value within that strategy
    • eg in a number range, shrinking would approx try to do a binary search to figure out the failing threshold
  • PROPTEST_CASES is equal to 256
  • any for built in types
    • any::<u32>() is a Strategy for all u32s
  • we can use prop_map to transform strategies
# set scroll history to 100,000 lines
set-option -g history-limit 100000
# modern colors
set -g default-terminal "tmux-256color"
set -ga terminal-overrides ",alacritty:Tc"
# vim copy mode
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-pipe 'pbcopy'
@protortyp
protortyp / init.lua
Last active March 9, 2025 15:03
nvim config
-- always set leader first!
vim.keymap.set("n", "<Space>", "<Nop>", { silent = true })
vim.g.mapleader = " "
-------------------------------------------------------------------------------
--
-- preferences
--
-------------------------------------------------------------------------------
-- never ever folding
@protortyp
protortyp / transforms.py
Created August 1, 2024 20:35
Useful transforms tools if you may or may not apply the same transformation to multiple images
import numpy as np
import albumentations as A
from albumentations.pytorch import ToTensorV2
from PIL import Image
def get_transforms(train=False):
"""
Takes a list of images and applies the same augmentations to all of them.
This is completely overengineered but it makes it easier to use in our pipeline
@protortyp
protortyp / upload_time_in_days.py
Created June 15, 2023 16:38
Calculate the upload time in days, given upload speed in mbps, and terrabytes to upload
def upload_time_in_days(mbps, tb):
mbps_in_MBps = mbps / 8
tb_in_MB = tb * 1000000
total_seconds = tb_in_MB / mbps_in_MBps
total_days = total_seconds / (60 * 60 * 24)
return total_days
@protortyp
protortyp / Dockerfile
Last active June 5, 2023 06:01
Dockerfile for libtorch development on Apple Silicon
FROM --platform=linux/amd64 ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y curl unzip wget zsh \
libopenblas-dev \
libjpeg-dev \
libpng-dev \
build-essential \
# Wait for the transform to become available
listener.waitForTransform('/base_link', '/end_effector', rospy.Time(), rospy.Duration(4.0))
# Get the transformation matrix from the robot base to the end effector
(trans, rot) = listener.lookupTransform('/base_link', '/end_effector', rospy.Time(0))
rot_matrix = tf.transformations.quaternion_matrix(rot)
transformation_matrix = tf.transformations.concatenate_matrices(rot_matrix, tf.transformations.translation_matrix(trans))
import rospy
import tf
from geometry_msgs.msg import Quaternion
# Create a quaternion object
quat = Quaternion()
quat.x = 0.1
quat.y = 0.2
quat.z = 0.3
quat.w = 0.4
#!/usr/bin/env python
import rospy
import cv2
from sensor_msgs.msg import Image
from cv_bridge import CvBridge
from PyCapture2 import *
def image_publisher():
rospy.init_node('epiphan_image_publisher', anonymous=True)
pub = rospy.Publisher('image_topic', Image, queue_size=10)
@protortyp
protortyp / daily_note.md
Created March 5, 2023 10:17
Obsidian Daily Note Template

<%* let weekNumber = moment().format('W') let year = moment().format('Y') let month = tp.date.now("MM-MMMM") let yesterday = tp.date.now("YYYY-MM-DD_ddd", -1) let today = tp.date.now("YYYY-MM-DD_ddd") let tag = "#cw" + weekNumber + "_" + year let prevTag = #cw${weekNumber - 1}_${year} let file_path = A_daily_notes/${year}/${month}/${today} %>