Skip to content

Instantly share code, notes, and snippets.

View SuperFluffy's full-sized avatar

Richard Janis Goldschmidt SuperFluffy

View GitHub Profile
@SuperFluffy
SuperFluffy / PKGBUILD
Last active August 29, 2015 14:19 — forked from sdvillal/PKGBUILD
python-theano PKGBUILD
# Current maintainer: Janis Beckert <janis.beckert at gmail.com>
# Original maintainer: Thomas Dziedzic < gostrc at gmail >
# Modified by: Cristóvão D. Sousa <crisjss@gmail.com>
# Modified by: Santi Villalba <sdvillal@gmail.com>
# Modified by: Janis Beckert <janis.beckert at gmail.com>
pkgbase=python-theano
pkgname=(python-theano python2-theano)
pkgver=0.7.0
pkgrel=3
@SuperFluffy
SuperFluffy / lib.rs
Created February 7, 2016 11:45
Borrow error?
use std::ops::{Add,Mul};
pub trait ODE {
type State;
fn get_state(&self) -> &Self::State;
fn differentiate(&self, &Self::State) -> Self::State;
fn differentiate_into(&self, &Self::State, &mut Self::State);
fn update_state(&mut self, &Self::State);
#[macro_use(s)] extern crate ndarray;
#[macro_use] extern crate itertools;
use ndarray::{Array,OwnedArray};
fn main() {
let r = 0..16;
let v = r.map(|x| x as f64).collect::<Vec<_>>();
// Works
@SuperFluffy
SuperFluffy / test_approx.rs
Last active February 24, 2016 10:07
Showing that calling the library function is much slower
extern crate approx;
extern crate time;
use approx::ApproxEq;
use std::f64;
fn relative_eq(a: &f64, b: &f64, epsilon: f64, max_relative: f64) -> bool {
// Copied straight from approx
if a == b { return true; }
@SuperFluffy
SuperFluffy / ugly.rs
Created November 20, 2016 12:38
Loop until end of file
fn deserialize_to_last<S: io::Seek + io::Read>(stream: &mut S) -> Result<Self, bincode::serde::DeserializeError> {
use bincode::serde::{Deserializer,DeserializeError};
let mut deserializer = Deserializer::new(stream, bincode::SizeLimit::Infinite);
let mut input: DeserializationStruct = Deserialize::deserialize(&mut deserializer)?;
loop {
#[cfg(debug_assertions)]
println!("{:?}", input);
input = match Deserialize::deserialize(&mut deserializer) {
let time_progression = match sim_config.progression {
StepProgression::Linear => vec![sim_config.t; sim_config.nt],
StepProgression::Exponential => {
(0..sim_config.nt)
.map(|x| sim_config.t * 2f64.powi(x as i32))
.collect::<Vec<_>>()
},
};
@SuperFluffy
SuperFluffy / something.rs
Created December 1, 2016 11:26
Invert Option and Result
pub trait OptionResultExt {
type Out;
fn invert(self) -> Self::Out;
}
impl<T, E> OptionResultExt for Option<Result<T, E>> {
type Out = Result<Option<T>, E>;
fn invert(self) -> Self::Out {
@SuperFluffy
SuperFluffy / clap.log
Last active January 29, 2017 19:41
Clap index error
% cargo run -- -a
Compiling clap v2.20.0
Compiling clap-group v0.1.0 (file:///home/janis/code/scrap/rust/clap-group)
warning: unused variable: `matches`, #[warn(unused_variables)] on by default
--> main.rs:7:9
|
7 | let matches = App::new("myapp")
| ^^^^^^^
Finished dev [unoptimized + debuginfo] target(s) in 21.31 secs
@SuperFluffy
SuperFluffy / Cargo.toml
Created January 31, 2017 15:42
panic in self.pointer_is_inbounds() in impl_methods.rs:92
[package]
name = "arrayvec_blowstack"
version = "0.1.0"
authors = ["Richard Janis Goldschmidt <janis.beckert@gmail.com>"]
[dependencies]
ndarray = "0.7"
[dependencies.arraydeque]
git = "https://github.com/SuperFluffy/arraydeque"
name native_blas ns/iter native_noblas ns/iter diff ns/iter diff %
add_1d_regular 278 283 5 1.80%
add_1d_strided 3,815 3,750 -65 -1.70%
add_2d_0_to_2_iadd_scalar 187 181 -6 -3.21%
add_2d_assign_ops 300 286 -14 -4.67%
add_2d_broadcast_0_to_2 187 181 -6 -3.21%
add_2d_broadcast_1_to_2 560 541 -19 -3.39%
add_2d_cutout 810 799 -11 -1.36%
add_2d_f32_regular 310 312 2 0.65%
add_2d_regular 300 287 -13 -4.33%