Skip to content

Instantly share code, notes, and snippets.

@mitchmindtree
mitchmindtree / ofxCpp11MakeErrors
Created May 10, 2014 10:49
openframeworks, C++11, OSX 10.9.2, make errors
mindTree:ofJenAI Mitch$ make
Compiling OF library for Release
make[2]: Nothing to be done for `ReleaseABI'.
Done!
Compiling ofJenAI for Release
find: demos: No such file or directory
find: demos: No such file or directory
Compiling src/main.cpp
@mitchmindtree
mitchmindtree / ofxMakeErrorsUndefinedSymbols
Created May 11, 2014 01:19
ofxMakeErrorsUndefinedSymbols
mindTree:ofJenAI Mitch$ make
Compiling OF library for Release
make[2]: Nothing to be done for `ReleaseABI'.
Done!
Compiling ofJenAI for Release
find: demos: No such file or directory
find: demos: No such file or directory
find: demos: No such file or directory
@mitchmindtree
mitchmindtree / RustQuestion1
Created May 29, 2014 15:56
A question about Rust 'mod', 'crate' and 'use' usage.
//--------------- main.rs ---------------------
extern crate rand; // Why do I have to use this here, when I've already done so in a.rs?
mod a;
mod b;
fn main() {
a::test();
b::test();
@mitchmindtree
mitchmindtree / RustQuestion2
Created May 30, 2014 17:37
A question about rust generics.
/*
I want a 'MyStruct' that can take any of the floating point primitive types.
When instantiating a 'MyStruct', I want to do so with MyStruct::new(val),
which should create a struct with val: val, but should also initialise
a: 0.0(f32/f64 - whatever it's floating point type is) and
b: 1.0(f32/f64 - whatever it's floating point type is).
Can I do this with a single impl method (like below)? Am I on the right
track, or is there a better way to handle this situation in Rust? (I'm
coming from c++).
@mitchmindtree
mitchmindtree / RustQuestion3
Last active August 29, 2015 14:02
A mismatched types error in Rust
use tempo::Tempo;
use time_signature::TimeSignature;
#[deriving(Clone)] // The error disappears if I remove this line.
#[deriving(Show)]
pub struct JTimePack<'r> {
sample_rate: int,
tempo: &'r Tempo,
time_sig: &'r TimeSignature, // << Error is found here pointing to 't' in 'time_sig'
ppqn: int
@mitchmindtree
mitchmindtree / RustQuestion4.rs
Created June 8, 2014 10:59
A question regarding good practice and impl'ing trait methods that return a mutable reference to self.
// Is it considered bad practise to do something like this?
// Or is it fine? Common even?
//
// I'm specifically referring to impl'ing a trait method for a
// struct that returns a mutable reference to itself? In my
// current situation, it seems it will save a lot of unnecessary
// impl'ing when deriving from trait "A".
#[deriving(Show)]
pub struct MyStruct<'a> { i: int }
@mitchmindtree
mitchmindtree / RustQuestion5.rs
Last active August 29, 2015 14:02
Defining "setter" methods within a trait.
// The example below gives the following:
//
// "error: cannot borrow `*self` as mutable more than once at a time"
//
// I understand why, but I am wondering if it is possible to define
// "setter" methods within the trait in a way similar to this?
#[deriving(Show)]
pub struct MyStruct<'a> { i: int, j: int }
@mitchmindtree
mitchmindtree / RustQuestion6.rs
Last active August 29, 2015 14:02
A question regarding structs containing multiple structs with the same lifetime.
//
// I'd like to be able to gain access to the 'foo', 'bar' and 'baz' members
// via the "get_my_struct" trait method.
//
// I'd like to be able to access both 'foo' and 'bar' as well as a mutable ref
// to 'baz' in order to write to 'baz' within the 'calc_baz' method.
//
struct A<'a> {
i: int
@mitchmindtree
mitchmindtree / ice-skating-mario
Created January 4, 2015 19:47
Mario Ice-Skating (first Elm code)
import Color (..)
import Graphics.Collage (..)
import Graphics.Element (..)
import Keyboard
import Signal
import Time (..)
import Window
-- MODEL
mario = { x=0, y=0, vx=0, vy=0, dir="right" }
@mitchmindtree
mitchmindtree / gist:66888b67ac15ba612c5e
Last active August 29, 2015 14:14
DspNode trait implementation
/// DSP Node trait. Implement this for any audio instrument or effects types that are to be used
/// within your DSP chain. Override all methods that you wish. If the Node is a parent of other
/// DSP nodes, be sure to implement the `inputs` method.
pub trait Node {
type Sample: Sample = f32;
type Buffer: DspBuffer = Vec<f32>;
/// Return the volume for this Node.
#[inline]
fn vol(&self) -> Volume { 1.0 }