Skip to content

Instantly share code, notes, and snippets.

View JCBurnside's full-sized avatar

Jasmine Burnside JCBurnside

View GitHub Profile
trait TupleCall {
type Args;
type Output;
unsafe fn call_tuple(&self,args:Self::Args)->Self::Output;
}
macro_rules! impl_unsafe_fn {
(@recurse $first:ident $( , $rest:ident )*) => {
impl_unsafe_fn!($( $rest ),*);
};
@JCBurnside
JCBurnside / main.rs
Last active February 21, 2024 02:35
A small sample using LLJIT
use llvm_sys::orc2;
use std::{ffi::{CStr, CString}, mem::MaybeUninit, ops::Deref};
struct LLJIT(orc2::lljit::LLVMOrcLLJITRef);
impl Drop for LLJIT {
fn drop(&mut self) {
unsafe { orc2::lljit::LLVMOrcDisposeLLJIT(self.0) };
}
}
impl Deref for LLJIT {
@JCBurnside
JCBurnside / fflat_design
Last active October 9, 2023 19:32
a document detailing the design of the ast for my lange fflat
Program is
Declaration+
TopLevelDeclaration is
"type" Ident = '{' FieldDeclaration* '}'
"enum" Ident = ('|' EnumDeclaration)*
Declaration
"for<"(Ident',')+'>' TopLevelDeclaration
Declaration is
@JCBurnside
JCBurnside / main.rs
Created December 9, 2020 22:37
aoc 2020 day 9
fn part1(data: &[u32], preamble_len: usize) -> u32 {
use itertools::Itertools;
data.iter()
.skip(preamble_len)
.enumerate()
.map(|(i, &datum)| {
(
data.iter()
.skip(i)
.take(preamble_len)
@JCBurnside
JCBurnside / main.rs
Created December 5, 2020 17:47
aoc2020 day5
use itertools::Itertools;
use std::fs::File;
use std::io::{BufRead, BufReader};
fn map_to_bool_array(s: &str) -> [bool; 10] {
let mut output = [false; 10];
for (i, c) in s.chars().enumerate() {
output[i] = match c {
'B' | 'R' => true,
_ => false,
@JCBurnside
JCBurnside / data.rs
Created December 5, 2020 00:44
day 4 of AoC2020
use lazy_static::lazy_static;
use parse_display::{Display, FromStr};
use std::str::FromStr;
#[derive(FromStr, Debug, Copy, Clone)]
#[from_str(regex = "(?P<0>\\d+)(in|cm){1}")]
pub enum Height {
#[from_str(regex = "(?P<0>\\d+)cm")]
cm(u8),
#[from_str(regex = "(?P<0>\\d+)in")]
inch(u8),
@JCBurnside
JCBurnside / day1.rs
Last active December 2, 2020 00:33
aoc2020 day 1
use std::fs;
use std::io::{BufRead, BufReader, Error};
fn main() -> anyhow::Result<()> {
let data_file = fs::File::open("data.txt")?;
let numbers =BufReader::new(data_file)
.lines()
.map(|l| Ok(l?.parse()?))
.collect::<anyhow::Result<Vec<u32>>>()?;
println!("part one");
@JCBurnside
JCBurnside / main.cpp
Last active April 10, 2020 19:54
A not so simple implementation of Vector2 in c++ with sample
#include <type_traits>
#include <utility>
#include <iostream>
#include <math.h>
template<typename TLeft, typename TRight>
concept Same = std::is_same_v<TLeft,TRight> && std::is_same_v<TRight,TLeft>;
template<typename TType>
concept Arithmetic = std::is_arithmetic_v<TType>;
[10:35:15.573] Starting new session: ForceField
[10:35:15.575] IsServer: True
[10:35:15.575] CreativeMode: True
[10:35:15.575] OnlineMode: OFFLINE
[10:35:15.575] IsDedicated: False
[10:35:15.575] mods: 2
[10:35:15.575] mod: Text HUD API
[10:35:15.575] mod: Nanowalls
[10:35:15.575] Mod Publish ID: 0
[10:35:15.576] Mod Model Folder Path: C:\Users\James-Gaming\AppData\Roaming\SpaceEngineers\Mods\Shaostoul - Nanowall\Models\