Skip to content

Instantly share code, notes, and snippets.

I am the Miaou user with id 2097 and name "wisely" on https://dystroy.org/miaou
extern crate texture;
extern crate glutin_window;
extern crate graphics;
extern crate opengl_graphics;
use opengl_graphics::Texture;
use graphics::image::Image;
use texture::TextureSettings;
fn main() {
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char last_input;
char *getstdin() {
char *line = NULL, *tmp = NULL;
size_t size = 0, index = 0;
int ch = EOF;
@0e4ef622
0e4ef622 / Cargo.toml
Last active June 22, 2018 03:53
very primitive not secure message wall
[package]
name = "webtesto"
version = "0.1.0"
authors = ["Matthew Tran <0e4ef622@gmail.com>"]
[dependencies]
actix-web = "0.6"
actix = "^0.5.8"
futures = "0.1"
serde_derive = "1.0"
@0e4ef622
0e4ef622 / Cargo.toml
Last active November 6, 2018 07:27
bug in glutin_window
[package]
name = "glutin-window-bug"
version = "0.1.0"
authors = ["Matthew Tran <0e4ef622@gmail.com>"]
edition = "2018"
[dependencies]
piston = "0.37"
piston-texture = "0.6"
# uncomment one of the below
@0e4ef622
0e4ef622 / lmao.rs
Last active November 21, 2018 02:50
why have i done this
macro_rules! gen_execute_macro {
($(($($idl:tt $it:tt $in:tt),*), ($($odl:tt $ot:tt $on:tt),*),)*) => {
macro_rules! execute_2 {
$(
($oname:ident, ($($idl$it:ty),*), ($($odl$ot:ty),*)) => {
fn execute(&self, in_var: Self::InType) -> Self::OutType {
let mut res = Self::OutType::default();
let kmut = (*KERNEL).clone();
let mut k = kmut.lock();
unsafe {
@0e4ef622
0e4ef622 / solution.rs
Last active December 6, 2018 06:57
aoc day 4
#[derive(Clone, Copy)]
enum Event {
Begin(usize),
Sleep,
Wake,
}
#[derive(Clone, Copy)]
struct Entry {
minute: usize,
@0e4ef622
0e4ef622 / solution.rs
Created December 8, 2018 12:31
aoc 2018 day8
use std::collections::*;
pub fn part1(input: &str) -> usize {
let mut input = input.split_whitespace().peekable();
let mut entries = Vec::new();
parse_node(input.by_ref(), &mut entries);
entries.into_iter().sum()
}
fn parse_node<'a>(input: &mut impl Iterator<Item = &'a str>, entries: &mut Vec<usize>) {
let child_node_count = input.next().unwrap().parse::<usize>().unwrap();
@0e4ef622
0e4ef622 / solution.rs
Last active December 11, 2018 07:52
aoc day 11 2018
use rayon::iter::{IntoParallelIterator, ParallelIterator};
pub fn part1(serial_number: usize) -> (usize, usize) {unsafe{
let mut cells = vec![[0isize; 300]; 300];
for y in 1..=300 {
let id = 11;
*cells.get_unchecked_mut(y-1).get_unchecked_mut(0) = ((id*y+serial_number)*id/100%10) as isize - 5;
if y != 1 {
*cells.get_unchecked_mut(y-1).get_unchecked_mut(0) += *cells.get_unchecked_mut(y-2).get_unchecked_mut(0);
}
}
@0e4ef622
0e4ef622 / solution.rs
Last active December 13, 2018 07:10
aoc day 13 2018
fn load(input: &str) -> (isize, isize, Vec<u8>, Vec<(isize, isize, isize, isize, usize)>) {
let width = input.lines().next().unwrap().len() as isize;
let height = input.lines().count() as isize;
let mut matrix = vec![0; (width*height) as usize];
let mut cars: Vec<(isize, isize, isize, isize, usize)> = vec![]; // (y, x, dx, dy, state) for sorting, down is positive
for (y, line) in input.lines().enumerate() {
for (x, &c) in line.as_bytes().iter().enumerate() {
let x = x as isize;
let y = y as isize;
matrix[(y*width+x) as usize] = c;