Skip to content

Instantly share code, notes, and snippets.

View NyxCode's full-sized avatar

NyxCode NyxCode

View GitHub Profile
@NyxCode
NyxCode / calculator.rs
Created March 22, 2024 16:14
Rust - Calculator
// https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=8eb18dcae59db15009c090867827a7d9
use core::iter::Peekable;
#[derive(Debug)]
enum Expr {
BinOp(Box<Expr>, Op, Box<Expr>),
Num(f64),
Neg(Box<Expr>),
}
.textareaLinesNumbers {
position: relative;
}
.textareaLinesNumbers textarea.linesContainer {
display:block;
border:none;
position:absolute;
overflow:hidden;
text-align:right;
@NyxCode
NyxCode / AutoFont.kt
Created April 25, 2019 10:35
use all fonts available on fonts.google.com in Kotlin JVM applications
import org.apache.commons.io.FileUtils
import java.awt.Font
import java.awt.GraphicsEnvironment
import java.io.File
import java.io.FileNotFoundException
import java.net.URL
private const val FONTS_REPOSITORY = "https://github.com/google/fonts/raw/master"
private val LICENSES = arrayOf("apache", "ofl", "ufl")
private val SANITIZE_EXPR = Regex("\\W+")
@NyxCode
NyxCode / tpm2.md
Last active August 21, 2017 15:39 — forked from jblang/tpm2.md
TPM2 Protocol Description

TPM2 Protocol Implementation

Introduction

Frame data is transferred inside packets (similar to DMX, for example). A frame is an image representing a matrix or a light scene.

The packets start and end with one-byte characters. In between are a few control bytes followed by the payload. There is no set size for a payload; it is transmitted with each packet. This makes the protocol quite flexible. There are enough bytes in a single packet for an RGB matrix with 21,845 pixels, but if you just want to control an RGBW lamp, that only requires 9 bytes. The variable frame size means there is no overhead, allowing for maximum transfer speed.

TPM2 Packet Structure