Skip to content

Instantly share code, notes, and snippets.

View samsartor's full-sized avatar

Sam Sartor samsartor

View GitHub Profile
@samsartor
samsartor / CMF3Versions.txt
Last active August 29, 2015 14:10
A Change log for CFM3
3.1.2.2
?3.1.0 Initial
?3.1.1 Snowmen
@samsartor
samsartor / jive.sh
Last active August 29, 2015 14:15
A Program to Quickly Test Java
#!/bin/bash
function error
{
echo "Invalid Jive Command!"
usage
exit
}
function usage
@samsartor
samsartor / glcfg.js
Last active August 29, 2015 14:25
Help making the gl.json config for bluegin
//
// This is a node.js script designed to create the base JSON cfg file for the auto-gen of the GL, GLEnum, and GLCapabilities classes in BlueGin
// It looks at the C headers in the opengl registry (https://www.opengl.org/registry/) and gives us a starting point
//
var http = require('http');
var https = require('https');
var fs = require('fs');
var StringDecoder = require('string_decoder').StringDecoder;
@samsartor
samsartor / plexisphere.js
Last active August 29, 2015 14:26
Create n-dimentional plexispheres!
(function() {
var arr = function(length, fill) {
var arr = [];
for (var i = 0; i < length; i++)
{
arr.push(fill);
}
return arr;
};
@samsartor
samsartor / ElytraModel.java
Last active May 13, 2024 02:08
Code for simulating the elytra item in Minecraft
/**
* An accurate simulation of the elytra item as of Minecraft 15w41b
*/
public class ElytraModel
{
public int glideTime;
public int damageTaken;
public double posX;
public double posY;
@samsartor
samsartor / two_buttons.rs
Last active June 11, 2017 01:19
A theoretical boxflight double-button example
pub fn main() {
let mut ctx = Context::new();
let mut rng = thread_rng();
ctx.add_element(ButtonsModel {
color_a: random_color(&mut rng),
color_b: random_color(&mut rng),
});
ctx.launch();
}
@samsartor
samsartor / amicable.rs
Created June 29, 2017 19:07
Project Euler #95 (Rust)
use std::cmp::min;
use std::usize::MAX as NUM_MAX;
const MAX: usize = 1000000;
fn main() {
// statically-allocated list used by `amicable` to mark numbers
let mut marks = [0; MAX + 1];
let (min, len) = (1..marks.len())
.flat_map(|n| amicable(n, &mut marks)) // flat map to ignore `None`s
@samsartor
samsartor / linear_solitaire.hs
Created January 31, 2018 16:29
Plays the "linear" version of Solitaire
type Card = (Int, Int)
type Deck = [Card]
type Hand = [Card]
collase_one :: Hand -> Hand
collase_one ((_, ra) : _ : _ : (_, rb) : rest) | ra == rb = rest
collase_one (a@(sa, _) : _ : _ : b@(sb, _) : rest) | sa == sb = [a, b] ++ rest
collase_one t = t
collape_all :: Hand -> Hand
@samsartor
samsartor / bithack.rs
Created January 31, 2019 14:57
Connect-Four Bithacking
#![allow(dead_code)]
const L_COL: u64 = 0xFF00000000000000;
const R_COL: u64 = 0x00000000000000FF;
const B_ROW: u64 = 0x0101010101010101;
const T_ROW: u64 = 0x8080808080808080;
const B_ROWS: u64 = !T_ROW;
const R_COLS: u64 = !L_COL;
@samsartor
samsartor / pins.md
Last active October 14, 2021 20:36
First-Class Pin Stuff

Goal #1: safe pin projection

It should be possible to safely project through pinned user types:

struct Data<F: Future> {
    future: F,
    output: Option<F::Output>,
}

impl<F: Future> Data<F> {