Skip to content

Instantly share code, notes, and snippets.

View elimirks's full-sized avatar
:shipit:

Elijah Mirecki elimirks

:shipit:
View GitHub Profile
/// `FragmentedBytes` is a ring buffer of Bytes, useful to avoid copying
/// heap memory when parsing live content over a network
///
/// The `offset` in this function is the offset in `bytes` where we expect to
/// parse a new element.
/// The return value for each parse function is a tuple of:
/// `(new offset, parsed value)`
///
/// For anyone non-rusty, the `?` operator will propagate `ParseError` values up the
/// stack - similar to throwing exceptsions, without the overhead
#[derive(Default)]
struct FragmentedBytes {
parts: VecDeque<Bytes>,
len: usize,
}
impl FragmentedBytes {
pub fn push_bytes(&mut self, bytes: Bytes) {
self.len += bytes.len();
self.parts.push_back(bytes);
@elimirks
elimirks / +page.svelte
Created January 19, 2025 14:07
Complementary Color Picker
<script lang="ts">
import vertCode from "./vertex.glsl?raw";
import fragCode from "./fragment.glsl?raw";
let canvasGl: HTMLCanvasElement;
let canvas2d: HTMLCanvasElement;
function hsvToRgb(h: number, s: number, v: number) {
let r: number = 0.0,
g: number = 0.0,
package problem413
import scala.util.Random
/**
* Generates an array of random numbers in the given bounds.
*/
def generateArray(
seed: Int,
size: Int,
@elimirks
elimirks / init.el
Created February 22, 2022 20:33
Hammerspoon config
hs.hotkey.bind({"cmd"}, "1", function()
hs.application.launchOrFocus("Firefox")
end)
hs.hotkey.bind({"cmd"}, "2", function()
hs.application.launchOrFocus("/usr/local/Cellar/emacs-plus@28/28.0.50/Emacs.app")
end)
hs.hotkey.bind({"cmd"}, "3", function()
hs.application.launchOrFocus("Alacritty")
end)
hs.hotkey.bind({"cmd"}, "4", function()
(defun eli/lastpass-helm-list-all ()
(let* ((cmd-out (shell-command-to-string "lpass ls --color=never"))
(raw-lines (split-string cmd-out "\n" t)))
(mapcar (lambda (line)
(string-match "^\\(.*\\)/\\(.*\\) \\[id: \\([0-9]+\\)\\]$" line)
(list (match-string 1 line)
(match-string 2 line)
(match-string 3 line)))
raw-lines)))

Lecture 1 - Intro

Intro & Protein Folding stuff.

Lecture 2 - Jupyter intro

Jupyter and Markdown intro. Calculating binding energy. Introduction to plotting.

Lecture 3 - Number representation in Python & Numpy

How numbers are represented in python & numpy. Rounding error discussion. Floating point error.

#include <pthread.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#define THREAD_COUNT (4)
#define BATCH_SIZE (10000)
uint64_t *prime_nums;
size_t prime_number_count = 0;
// Hacky, but quick.
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
uint64_t *prime_nums;
size_t prime_number_count = 0;
size_t prime_number_size = 1024;
@elimirks
elimirks / ping_client.py
Created August 30, 2018 20:43
Sample networked python program
#!/usr/bin/env python3
import socket
s = socket.socket()
host = socket.gethostname()
port = 14447
s.connect((host, port))