Skip to content

Instantly share code, notes, and snippets.

View porglezomp's full-sized avatar
💖
GITHUB DROP ICE

Cassie Jones porglezomp

💖
GITHUB DROP ICE
View GitHub Profile
@porglezomp
porglezomp / .gitignore
Last active January 2, 2016 18:39
Doing my math homework using libgraphicsmath
Math
.DS_Store
@porglezomp
porglezomp / Rocket
Last active January 4, 2016 09:19
A little diagram of a rocket for Strategic Offense Initiative
[1] warhead
1
[2] computer
2
[3] booster -3- [4] control -4- [5] booster
5
[6] fuel
|6|
[7] coupler
|7|
@porglezomp
porglezomp / Extrap.cs
Last active August 31, 2018 01:56
Provides some of Unity's interpolation methods without clamping to [0, 1]
using UnityEngine;
using System.Collections;
public class Extrap {
public static Quaternion Slerp(Quaternion q1, Quaternion q2, float t)
{
float angle;
Vector3 axis;
@porglezomp
porglezomp / README.md
Last active August 29, 2015 14:05
Do parametric animation in Unity3d, inspired by UIView animation in iOS

How to use this

Installation

  1. Copy the PAnim.cs class into your Unity3d project
  2. You're done!

Animating Objects

fib ^n = {
fib ^n ^a ^b = {
if (n <= 0) ^!( return a )
if (n == 1) ^!( return b )
fib (n - 1) b (a + b)
}
fib n 0 1
}
macro_rules! parsable_enum {
($(#[$attrs:meta])* enum $name:ident { $($member:ident),*}) =>
(parsable_enum! { $(#[$attrs])* enum $name { $($member),* ,}});
($(#[$attrs:meta])* enum $name:ident { $($member:ident),* , }) => {
$(#[$attrs])*
pub enum $name {
$($member),+
}
use std::str::FromStr;
@porglezomp
porglezomp / README.md
Last active March 19, 2024 16:00
Serializing Binary Data in Rust

Serializing Binary Data in Rust

The way I like to serialize data in Rust into binary formats is to let a data structure blit itself into a mutable buffer. This is a relatively composable, low level way to work that lends itself to having other abstractions built on top of it. I recently was serializing network packets, so let's make up a small packet format that illustrates how we can do this.

+-------------+-------------+
|  Tag (u16)  | Count (u16) |
+-------------+-------------+
|                           |
~        Entry (u32)        ~

Keybase proof

I hereby claim:

  • I am porglezomp on github.
  • I am porglezomp (https://keybase.io/porglezomp) on keybase.
  • I have a public key ASBz_m2oruQIDIMJM-2Sg8gOiGO0o8uCWbG1hP-ti7F4_wo

To claim this, I am signing this object:

@porglezomp
porglezomp / conformant_json_parser.py
Created October 27, 2016 06:08
It's possible to have an extremely simple standard-conformant JSON parser!
# RFC 7159 § 9
# "An implementation may set limits on the size of texts that it accepts."
def parse_json(text):
if len(text) != 1:
raise ValueError("Only accepts single character JSON values")
return int(text[0])
@porglezomp
porglezomp / exception.c
Last active May 26, 2022 20:43
Exception handling in C with setjmp and longjmp!
#include <iso646.h>
#include <setjmp.h>
#include <stdio.h>
// Exception Macros
int _exn_handler_idx = 0;
jmp_buf _exn_handlers[1024];