Skip to content

Instantly share code, notes, and snippets.

@tfogal
tfogal / cfuncs.go
Created July 4, 2014 17:23
how to do callbacks in Go. implements a 'filter' function. modified from the web example.
package main
/*
#include <stdio.h>
// The gateway function
int callOnMeGo_cgo(int* in)
{
return callOnMeGo(in);
}
@tfogal
tfogal / gist:9984008
Last active August 29, 2015 13:58
rust errors in english
* cannot index a value of type `std::vec::Vec<T>`
Rust's vector type doesn't implement whatever-it-needs to be able to use the standard indexing operator ("[]") with it. Use .get(idx) or .get_mut(idx) instead.
* error: cannot move out of dereference of `&`-pointer
The thing rust is highlighting is used in a context where it must be 'moved'. "moved" seems to imply the same semantics as C++'s 'std::move'.
One fix is to make the receiver accept a &T of whatever T it wants, and fix the call site appropriately. A better fix is to just rewrite the code so that the receiver isn't used at all.
@tfogal
tfogal / gist:9765258
Last active August 29, 2015 13:57
a new test for libuv which tests large writes.
diff --git a/test/test-fs.c b/test/test-fs.c
index f0ff824..837d251 100644
--- a/test/test-fs.c
+++ b/test/test-fs.c
@@ -732,6 +732,39 @@ TEST_IMPL(fs_file_sync) {
return 0;
}
+TEST_IMPL(fs_large_write) {
+ int r;
@tfogal
tfogal / netcdf.rs
Last active August 29, 2015 13:57
strange green error with current rust, see: http://itsapad.appspot.com/872001
use std::libc::{c_int, c_long, c_schar, c_uchar, c_void, ptrdiff_t, size_t};
use std::libc::{c_longlong, c_ulonglong, c_uint, c_ushort, c_double, c_float};
use std::libc::{c_short};
#[allow(non_camel_case_types)]
pub type nc_type = c_int;
#[allow(dead_code)]
#[allow(non_camel_case_types)]
pub struct nc_vlen_t {
len: size_t,
p: *mut c_void,