Skip to content

Instantly share code, notes, and snippets.

View ExpHP's full-sized avatar

Michael Lamparski ExpHP

View GitHub Profile
@ExpHP
ExpHP / v.rs
Created October 21, 2017 23:57
//! Math utils for variable length contiguous vectors.
// Currently restricted to 'f64' to make the design tractible.
// Generic traits would be nice and I would kill for functional-style
// maps and folds, but issues concerning borrowed data and trait bounds
// get ugly fast.
#[derive(Debug,Copy,Clone,PartialEq,PartialOrd)]
pub struct BadNorm(pub f64);
diff --git a/Cargo.toml b/Cargo.toml
index 6b34472..63b1d0b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,8 +2,8 @@
path = "spell_core"
[dependencies]
-iron = "*"
-router = "*"
@ExpHP
ExpHP / main.py
Created November 8, 2017 02:59
path normalization comparison
import os
import sys
alphabet = sys.argv[1]
max_depth = int(sys.argv[2])
def gen_strings(alphabet, s, depth):
yield s
if depth > 0:
for ch in alphabet:
/// Move a file or directory, possibly across filesystems.
///
/// Properties:
/// * Moves files or folders alike.
/// * The destination must not exist.
/// * The destination can be on a different filesystem.
/// * The operation is O(1) and preserves hard-links if
/// the destination is on the same filesystem.
/// * Symlinks retain their textual path targets.
/// * Permissions and attributes are carried over on a best
 Compiling checkerr v0.1.0 (file:///home/lampam/cpp/throwaway/checkerr)
error[E0518](B: attribute should be applied to function(B
(B--> (Bexamples/E0518.rs:11:1(B
(B|(B
11(B (B| (B#[inline(always)] //~ ERROR E0518(B
(B| (B^^^^^^^^^^^^^^^^^(B
12(B (B| (Bstruct Foo; //~ not a function(B
(B| (B-----------(B (Bnot a function(B
error[E0518](B: attribute should be applied to function(B
 Compiling checkerr v0.1.0 (file:///home/lampam/cpp/throwaway/checkerr)
error[E0518](B: attribute should be applied to function(B
(B--> (Bexamples/E0518.rs:11:1(B
(B|(B
11(B (B| (B#[inline(always)] //~ ERROR E0518(B
(B| (B^^^^^^^^^^^^^^^^^(B (Brequires a function(B
error[E0518](B: attribute should be applied to function(B
(B--> (Bexamples/E0518.rs:14:1(B
(B|(B
[ lampam @ 20:17:42 ] (!!!) (master •10 -53 +188) ~/cpp/other/rust/rsp22
$ rustup toolchain add nightly
info: syncing channel updates for 'nightly-x86_64-unknown-linux-gnu'
240.9 KiB / 240.9 KiB (100 %) 240.9 KiB/s ETA: 0 s
info: latest update on 2017-11-16, rust version 1.23.0-nightly (fa26421f5 2017-11-15)
info: downloading component 'rustc'
44.2 MiB / 44.2 MiB (100 %) 5.1 MiB/s ETA: 0 s
info: downloading component 'rust-std'
59.9 MiB / 59.9 MiB (100 %) 5.0 MiB/s ETA: 0 s
info: downloading component 'cargo'
@ExpHP
ExpHP / lib.rs
Last active November 23, 2017 03:12
map rows and cols standalone
extern crate nalgebra as na;
use na::{Scalar, Matrix, MatrixMN, MatrixSlice, Matrix1, DVector, RowDVector};
use na::{U1, U3, Dynamic, Dim};
use na::allocator::Allocator;
use na::default_allocator::DefaultAllocator;
use na::storage::Storage;
trait MatrixMapExt<N, R, C, S>
where
N: Scalar,
use ::std::ops::{Add, Sub, Neg};
pub trait AddSub1
: Sized
+ Add<<Self as AddSub1>::NThrice, Output=<Self as AddSub1>::NTwice>
+ Sub<<Self as AddSub1>::NThrice>
+ Add<<Self as AddSub1>::NTwice, Output=<Self as AddSub1>::Neg>
+ Sub<<Self as AddSub1>::NTwice, Output=<Self as AddSub1>::Thrice>
+ Add<<Self as AddSub1>::Neg, Output=<Self as AddSub1>::Zero>
+ Sub<<Self as AddSub1>::Neg, Output=<Self as AddSub1>::Twice>
@ExpHP
ExpHP / madness.rs
Last active December 12, 2017 23:16
use ::std::ops::{Add, Sub, Neg};
pub trait AddSub2<OtherP>
: Sized
+ Add<<Self as AddSub2<OtherP>>::Zero, Output=Self>
+ Sub<<Self as AddSub2<OtherP>>::Zero, Output=Self>
+ Add<<Self as AddSub2<OtherP>>::Other, Output=<Self as AddSub2<OtherP>>::Add>
+ Sub<<Self as AddSub2<OtherP>>::Other, Output=<Self as AddSub2<OtherP>>::Sub>
+ Add<<Self as AddSub2<OtherP>>::NOther, Output=<Self as AddSub2<OtherP>>::Sub>
+ Sub<<Self as AddSub2<OtherP>>::NOther, Output=<Self as AddSub2<OtherP>>::Add>