Skip to content

Instantly share code, notes, and snippets.

View anglesideangle's full-sized avatar
:atom:

Asa Paparo anglesideangle

:atom:
View GitHub Profile
@anglesideangle
anglesideangle / wrap.nix
Last active August 9, 2025 07:45
simple and robust nix wrapper function
/**
Wraps a package with flags and env vars.
The wrapper derivation has each specified binary in the original package replaced by a wrapper with the specified flags and environment variables.
Every other file from the original derivation is symlinked to by the new derivation, except any file referencing the original $pkg will be cloned and have that reference replaced by the wrapper derivation's $out.
# Example
```nix
mkWrapper = import ./wrap.nix;
@anglesideangle
anglesideangle / lifetime-guard.rs
Last active August 15, 2025 22:19
unsound stack allocated lifetime guard that would be sound with https://github.com/rust-lang/rfcs/pull/3782
//! # Lifetime Guard
//!
//! `lifetime-guard` provides `ValueGuard` and `RefGuard` structs to allow for
//! weak references to interior mutable values, similar to a singular pair of
//! `Rc` and `Weak`, but without heap allocation.
//!
//! ## Example Usage
//!
//! ```rust
//! use std::pin;
{
description = "Bevfusion";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem(system: let
@anglesideangle
anglesideangle / Option.java
Last active May 19, 2024 22:25
Rusty Java 21
import java.util.Objects;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Stream;
public sealed interface Option<T> {
record Some<T>(T value) implements Option<T> {}
final class None<T> implements Option<T> {
@anglesideangle
anglesideangle / SparkUtils.java
Last active March 15, 2024 16:53
A utility class for configuration of Spark Max/Flex motor controllers
package org.sciborgs1155.lib;
import com.revrobotics.CANSparkBase;
import com.revrobotics.CANSparkLowLevel.PeriodicFrame;
import com.revrobotics.REVLibError;
import edu.wpi.first.wpilibj.DriverStation;
import java.util.Optional;
import java.util.Set;
import java.util.function.Supplier;
@anglesideangle
anglesideangle / racecar_tool.sh
Last active July 31, 2023 22:41
rsync in BWSI RACECAR syncing
#!/bin/sh
# Creates the racecar tool for easily using and communicating with a RACECAR
racecar() {
if [ "$RACECAR_CONFIG_LOADED" != "TRUE" ]; then
echo "Error: unable to find your local .config file. Please make sure that you setup the racecar tool correctly."
echo "Go to \"https://mitll-racecar-mn.readthedocs.io/en/latest/gettingStarted/computerSetup.html\" for setup instructions."
else
local RACECAR_DESTINATION_PATH="/home/racecar/Documents/${RACECAR_TEAM}"
if [ $# -eq 1 ] && [ "$1" = "cd" ]; then
package frc.sciborgs.robot.subsystems
import edu.wpi.first.wpilibj2.command.SubsystemBase
import edu.wpi.first.math.MathUtil
import edu.wpi.first.math.controller.SimpleMotorFeedforward
import edu.wpi.first.math.controller.PIDController
import edu.wpi.first.wpilibj.Timer
import frc.sciborgs.robot.Motors
import frc.sciborgs.robot.Ports
import frc.sciborgs.robot.ShooterConstants