Skip to content

Instantly share code, notes, and snippets.

View killerswan's full-sized avatar

Kevin Cantú killerswan

View GitHub Profile
@killerswan
killerswan / a warning given at compile
Created September 1, 2012 04:51
help me understand implicit copyability
./pp.rs:12:14: 12:25 warning: instantiating copy type parameter with a not implicitly copyable type
./pp.rs:12 let data = result::get(result_data);
^~~~~~~~~~~
@killerswan
killerswan / io.rs
Created August 23, 2012 23:54
io.rs str_reader shenanigans
...
// GIVEN THIS CHANGE IN libcore/io.rs
fn str_reader(+ss: ~str) -> Reader {
bytes_reader(str::bytes(ss))
}
...
@killerswan
killerswan / gist:3441029
Created August 23, 2012 20:09
ICE with &FSyncable (all the gory details)
kunix:rust $ git diff
diff --git a/src/libcore/io.rs b/src/libcore/io.rs
index 046d155..7f437cf 100644
--- a/src/libcore/io.rs
+++ b/src/libcore/io.rs
@@ -4,6 +4,9 @@ Module: io
Basic input/output
*/
+#[forbid(deprecated_mode)];
@killerswan
killerswan / gist:3440976
Created August 23, 2012 20:05
an example && to replace (with ICE)
// Call o.fsync after executing blk
fn obj_sync(&&o: FSyncable, opt_level: option<Level>, /* ICE if I change this... */
blk: fn(&&Res<FSyncable>)) {
blk(Res({
val: o, opt_level: opt_level,
fsync_fn: fn@(&&o: FSyncable, l: Level) -> int {
return o.fsync(l);
}
}));
}
@killerswan
killerswan / gist:3440891
Created August 23, 2012 19:57
an example && to replace
// fsync fd after executing blk
fn fd_res_sync(&&fd: FdRes, opt_level: option<Level>,
blk: fn(&&Res<fd_t>)) {
blk(Res({
val: fd.fd, opt_level: opt_level,
fsync_fn: fn@(&&fd: fd_t, l: Level) -> int {
return os::fsync_fd(fd, l) as int;
}
}));
}
@killerswan
killerswan / gist:3440741
Created August 23, 2012 19:42
by reference (1)
fn getenv_nonempty(v: &Path) -> option<Path> {
match getenv(*v) {
some(x) =>
if str::is_empty(x) {
none
} else {
some(x)
},
_ => none
}
@killerswan
killerswan / demo.gv
Created August 9, 2012 23:24
a graphvis `dot` script example
// Kevin Cantu
// a graphvis `dot` script
strict digraph DEMO {
//graph[size="7.0,10.25"]
node[nodesep=0.75, ranksep=0.75, colsep=0.75]
//node[shape=Mrecord]
node[shape=rect]
@killerswan
killerswan / main.py
Created August 4, 2012 20:32
kivy, kinda working
#!/usr/bin/env python
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.textinput import TextInput
from kivy.uix.label import Label
from kivy.uix.button import Button
layout = BoxLayout(orientation='vertical')
pass0 = TextInput(text="<initial passphrase0>")
@killerswan
killerswan / generator.kv
Created August 4, 2012 20:09
kivy, not working yet
BoxLayout:
orientation: 'horizontal'
TextInput:
id: p0
TextInput:
id: p1
Label:
kunix:me $ ./cabal-dev/bin/lifter < samples/contest7.map
^C3.133571s: SIGINT Caught
12.640033s: Time's up
RDRRRDDLLDLDLLRURURRRDRDRRRLULLL
12.640286s: 867