Skip to content

Instantly share code, notes, and snippets.

@gavinb
gavinb / clutils.c
Created June 7, 2013 12:26
Convert an OpenCL cl_error code into a string.
/*
OpenCL Utility functions
*/
#ifndef CLUTILS_H_INC
#define CLUTILS_H_INC
#include <OpenCL/cl.h>
const char* clErrorString(cl_int err);
@gavinb
gavinb / tcptest.rs
Created July 14, 2013 22:54
Rust Networking test code which triggers an odd linker error relating to `rt::sched::__extensions__`.
// Cribbed from Rust libstd test code
// Causes a linker error on OS X
use std::cell::Cell;
use std::task::Task;
use std::rt::io::net::tcp;
use std::rt::io::net::ip;
use std::rt::local::Local;
use std::rt::io::{Reader, Writer, Listener};
@gavinb
gavinb / repeat_iterator.rs
Last active December 19, 2015 23:28
Experimental repeat() iterator for Rust
// iterator.rs
pub trait IteratorUtil<A> {
// ...
fn repeat_(&mut self) -> RepeatIterator<A, Self>;
}
//...
#[inline]
fn repeat_(&mut self) -> RepeatIterator<A, T> {
RepeatIterator{iter: self, iter_orig: copy self}
@gavinb
gavinb / iter_stuff.rs
Last active December 20, 2015 16:19
Troubles with types, iterators and collections
fn main() {
// Match parsed group lengths with expected - test data
let group_lengths: ~[(&int, &int)] = ~[(&8, &8), (&4, &4), (&4, &4), (&4, &4), (&8, &12)];
// ~~~
// ~~~ Problem 1: all vs take_while and unpacking tuple
// ~~~
// This works
@gavinb
gavinb / boring09.rs
Created February 18, 2014 04:29
Demonstrates a bug in c84890. Under OS X 10.9, crashes in receive code with null pointer.
// Rust IO Test
// Based on samples presented in Rob Pike's Go Concurrency talk
use std::libc::funcs::posix88::unistd::sleep;
use std::rand::random;
use std::comm::{Chan, Port};
struct Message {
string: ~str,
wait_chan: Chan<bool>,
@gavinb
gavinb / mrb.rs
Created March 26, 2014 05:37
Trying to share channels
extern crate native;
use std::comm::{Sender, Receiver, TryRecvResult, Data, channel};
struct Master<'a> {
chan_wc_to_engine: Sender<uint>,
chan_wc_from_engine: Receiver<uint>,
chan_engine_to_wc: Sender<uint>,
chan_engine_from_wc: Receiver<uint>,
@gavinb
gavinb / gist:9924137
Last active August 29, 2015 13:57
Trying template types
use std::num::{Zero};
use std::vec::Vec;
use std::mem::size_of;
pub struct Image<T> {
width: uint,
height: uint,
// ...
buffer: Vec<T>,
@gavinb
gavinb / gist:0c9874b66cae5779424a228b6c9b4dac
Created October 31, 2016 00:06
Trace of `cargo build` showing update after successful build
This file has been truncated, but you can view the full file.
DEBUG:cargo::build: executing; cmd=cargo-build; args=["/Users/abc/.multirust/toolchains/nightly-x86_64-apple-darwin/bin/cargo", "build"]
TRACE:cargo::ops::cargo_read_manifest: read_package; path=/Users/abc/src/rust-rosetta/Cargo.toml; source-id=file:///Users/abc/src/rust-rosetta
DEBUG:cargo::core::workspace: find_root - is root /Users/abc/src/rust-rosetta/Cargo.toml
DEBUG:cargo::core::workspace: find_members - /Users/abc/src/rust-rosetta/tasks/100-doors/Cargo.toml
TRACE:cargo::ops::cargo_read_manifest: read_package; path=/Users/abc/src/rust-rosetta/tasks/100-doors/Cargo.toml; source-id=file:///Users/abc/src/rust-rosetta/tasks/100-doors
DEBUG:cargo::core::workspace: find_members - /Users/abc/src/rust-rosetta/tasks/2048/Cargo.toml
TRACE:cargo::ops::cargo_read_manifest: read_package; path=/Users/abc/src/rust-rosetta/tasks/2048/Cargo.toml; source-id=file:///Users/abc/src/rust-rosetta/tasks/2048
DEBUG:cargo::core::workspace: find_members - /Users/abc/src/rust-rosetta/tasks/24-game/Cargo.toml
TRACE:cargo::ops::carg
@gavinb
gavinb / gist:8afca1d2335f3c1939cb23c475fe5429
Created October 31, 2016 14:56
Cargo build from acrichton/bad of rust-rosetta showing rust-openssl problem
This file has been truncated, but you can view the full file.
DEBUG:cargo::build: executing; cmd=cargo-build; args=["/Users/abc/src/cargo/target/debug/cargo", "build"]
TRACE:cargo::ops::cargo_read_manifest: read_package; path=/Users/abc/src/rust-rosetta/Cargo.toml; source-id=file:///Users/abc/src/rust-rosetta
DEBUG:cargo::core::workspace: find_root - is root /Users/abc/src/rust-rosetta/Cargo.toml
DEBUG:cargo::core::workspace: find_members - /Users/abc/src/rust-rosetta/tasks/100-doors/Cargo.toml
TRACE:cargo::ops::cargo_read_manifest: read_package; path=/Users/abc/src/rust-rosetta/tasks/100-doors/Cargo.toml; source-id=file:///Users/abc/src/rust-rosetta/tasks/100-doors
DEBUG:cargo::core::workspace: find_members - /Users/abc/src/rust-rosetta/tasks/2048/Cargo.toml
TRACE:cargo::ops::cargo_read_manifest: read_package; path=/Users/abc/src/rust-rosetta/tasks/2048/Cargo.toml; source-id=file:///Users/abc/src/rust-rosetta/tasks/2048
DEBUG:cargo::core::workspace: find_members - /Users/abc/src/rust-rosetta/tasks/24-game/Cargo.toml
TRACE:cargo::ops::cargo_read_manifest: read_package;
@gavinb
gavinb / cuda_device_link_error.md
Last active April 12, 2024 14:54
CUDA link error with CMake