Skip to content

Instantly share code, notes, and snippets.

Avatar

Brendan Zabarauskas brendanzab

View GitHub Profile
View rust-brainfuck.rs
use std::io;
fn main() {
eval(bytes!("++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.")); // I stole this off of wikipedia, sorry, wikipedia :(
}
fn eval(program: &[u8]) {
let mut pointer = 0u;
let mut memory = [0u8, ..1024];
let mut jmp_stack = vec!();
View map.rs
use std::iter::Iterator;
fn map<T, U, I: Iterator<T>>(fun: |T| -> U, mut iter: I) -> Vec<U> {
let mut acc = vec![];
for elt in iter {
acc.push(fun(elt));
}
acc
}
View error
rustc src/lib.rs -o idris/idrisfs.o --crate-type=lib --emit=obj
Undefined symbols for architecture x86_64:
"___morestack", referenced from:
_sizeof_int in idrisfs.o
sizeof_int::__rust_abi in idrisfs.o
mem::size_of::h1f2d9faff57bec09oaa::v0.0 in idrisfs.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
FAILURE: gcc -O2 -fwrapv -fno-strict-overflow -I. ./idrisfs.o -x c /var/folders/_t/g72k9vzd30b5svvyd1nxpwp40000gn/T/idris5178 -L/Users/sven/Library/Haskell/ghc-7.6.3/lib/idris-0.9.12/share/rts -lidris_rts -lgmp -lpthread -I/Users/sven/Library/Haskell/ghc-7.6.3/lib/idris-0.9.12/share/rts -I. -I/Users/sven/Library/Haskell/ghc-7.6.3/lib/idris-0.9.12/share/prelude -I/Users/sven/Library/Haskell/ghc-7.6.3/lib/idris-0.9.12/share/base -o /var/folders/_t/g72k9vzd30b5svvyd1nxpwp40000gn/T/idris5176
View update_rust.sh
#!/bin/sh
if [ "`uname`" = "Darwin" ]; then
target=x86_64-apple-darwin
else
target=x86_64-unknown-linux-gnu
fi
mkdir /tmp/rust-update
cd /tmp/rust-update
View counter_thingy.rs
extern crate collections;
use std::collections::HashMap;
use std::collections::hashmap::Entries;
use collections::hash::Hash;
struct Counter<T> {
counts: HashMap<T, uint>,
}
View Cargo.toml
[package]
name = "triangle"
version = "0.1.0"
authors = [ "Brendan Zabarauskas" ]
[[bin]]
name = "triangle" # the name of the executable to generate
View update-cargo
#!/bin/sh
cd /tmp/
git clone --recursive https://github.com/rust-lang/cargo
cd cargo
make
make install
cd $HOME
rm -rf /tmp/cargo
View signal.rs
/// Sends cloned values to multiple monitoring `Receiver`s.
pub struct Signal<T> {
txs: Vec<Sender<T>>,
}
impl<T: Send> Signal<T> {
/// Create a signal with no monitors connected.
pub fn new() -> Signal<T> {
Signal { txs: Vec::new() }
}
View flags.rs
#![feature(macro_rules)]
macro_rules! flag {
($Flag:ident) => {
flag!($Flag { Yes, No })
};
($Flag:ident { $Yes:ident, $No:ident, }) => {
flag!($Flag { $Yes, $No })
};
($Flag:ident { $Yes:ident, $No:ident }) => {
View glutin-ns-events.rs
// user application
loop {
window.poll_events();
}
// mac/glutin
fn poll_events(&self) {
nsapp_waitevent();