Skip to content

Instantly share code, notes, and snippets.

@m4rw3r
m4rw3r / battlestation.md
Last active June 18, 2023 11:05
Gaming desktop hardware

My hardware if anyone is interested:

Gaming Computer

  • CPU: Intel Core i9 13900K @ +2 TVB bins, no OC (6.0 GHz @ 1-2 core) for now
  • RAM: G.Skill 64 (2x32GB) DDR5 6400MT/s CL32 Trident Z5 RGB @ XMP for now
  • GPU: MSI GeForce RTX 4090 Suprim X @ 3 GHz & +1500 Mem
  • Motherboard: ASUS Maximus Z790 Apex
  • PSU: Corsair HX1200i 1200W
  • Case: Streacom BC1 Bench Table
(function() {
var deferFunc = this.nextTick ? this.nextTick : this.setImmediate ? this.setImmediate : function(func) {
setTimeout(func, 0);
}, doResolve = function(default_action, next, callback, value) {
if ("function" != typeof callback) return next[default_action](value);
try {
var ret = callback(value);
ret && "function" == typeof ret.then ? ret.then(function(value) {
next.resolve(value);
}, function(reason) {
@m4rw3r
m4rw3r / combine_http_parser.rs
Created August 20, 2015 15:19
Version of the attoparsec example using the parser combinator Combine.
extern crate combine;
use combine::*;
use std::fs::File;
use std::env;
// Seems like combine does not support any kind of zero-copy parsing
#[derive(Debug, Clone)]
struct Request {
@m4rw3r
m4rw3r / playground.rs
Last active February 11, 2017 12:15 — forked from anonymous/playground.rs
Shared via Rust Playground
#[macro_use]
extern crate chomp;
use std::rc::Rc;
use chomp::prelude::{token, SimpleResult, parse_only};
use chomp::ascii::{is_alphanumeric, is_whitespace};
use chomp::types::{Buffer, U8Input};
use chomp::parsers::{take_while1, skip_while};
use chomp::combinators::many;
@m4rw3r
m4rw3r / functions.php
Created November 18, 2013 10:32
Attempting to implement something akin to Haskell's typeclasses
<?php
namespace m4rw3r;
use ReflectionMethod;
use ReflectionFunction;
function compose($f, $g)
{
switch(callableReflection($g)->getNumberOfParameters()) {
@m4rw3r
m4rw3r / chomp_impl_trait_performance_results.md
Last active August 23, 2016 17:56
Benchmarks comparing `feature/input_trait` with `experiment/impl_trait`

experiment/impl_trait is essentially a reimplementation of all the parsers and combinators using the same baseline code as feature/input_trait. The feature/input_trait is intended to be chomp 0.3, and experiment/impl_trait either 1.0 or maybe a new crate chomp2 (useful since feature/input_trait still works on stable while experiment/impl_trait requires the latest nightly version of rustc).

Both share the same reposiotory and dependencies, just two different branches. Same code is used for both tests, with slight adjustment for how parsers are structured.

rustc --version
rustc 1.13.0-nightly (1576de0ce 2016-08-21)

experiment/impl_trait

@m4rw3r
m4rw3r / http_parser.rs
Created August 19, 2016 00:29
impl Trait with Input trait version of the chomp example HTTP-parser
#![feature(conservative_impl_trait)]
#[macro_use]
extern crate chomp;
extern crate memmap;
use std::fs::File;
use std::env;
use chomp::types::{Input, Parser};
@m4rw3r
m4rw3r / chomp_numbering_wrapper.rs
Created February 10, 2016 13:23
Just a quick implementation of line-numbering where a parser is wrapped to keep track of the number of lines it has parsed so far
use std::marker::PhantomData;
pub trait NumberingType {
type Token;
type Position;
fn update(&mut self, &[Self::Token]);
fn position(&self) -> Self::Position;
}
@m4rw3r
m4rw3r / 0000-saturating-and-checking-integer-wrapper-types.md
Last active March 7, 2016 20:27
WIP of pre-RFC for saturating and wrapping integer wrapper types
  • Feature Name: saturating-and-checking-integer-wrapper-types
  • Start Date: (fill me in with today's date, YYYY-MM-DD)
  • RFC PR: (leave this empty)
  • Rust Issue: (leave this empty)

Summary

Implement two wrapper-types in std::num which provide two different types of behavior on overflow: saturating arithmetic and always checked arithmetic with the latter signalling a thread panic on

extern crate rsz;
use rsz::{FunctorMut, HKT, MonadMut, Unit};
// Let's say that this type requires to run the closure multiple times,
// so we can only implement the mutable monads.
pub struct Foo<T> {
inner: T,
}