This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ),*); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Program is | |
Declaration+ | |
TopLevelDeclaration is | |
"type" Ident = '{' FieldDeclaration* '}' | |
"enum" Ident = ('|' EnumDeclaration)* | |
Declaration | |
"for<"(Ident',')+'>' TopLevelDeclaration | |
Declaration is |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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\ |