Skip to content

Instantly share code, notes, and snippets.

View killerswan's full-sized avatar

Kevin Cantú killerswan

View GitHub Profile
@killerswan
killerswan / err.log
Created June 4, 2012 00:59
what have I done now?
$ RUST_LOG=rustc=0,::rt::backtrace make
cfg: shell host triple x86_64-unknown-linux-gnu
cfg: host for x86_64-unknown-linux-gnu is x86_64
cfg: unix-y environment
cfg: using gcc
cfg: no llnextgen found, omitting grammar-verification
compile_and_link: x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd.so
rust: upcall fail 'Assertion !ty::type_has_params(t) failed', /home/rustbuild/src/rustbot/workspace-snap-stage3-x86_64-unknown-linux-gnu/src/src/rustc/middle/trans/common.rs:929
/code/rust/x86_64-unknown-linux-gnu/stage0/bin/../lib/librustrt.so(_ZN9rust_task13begin_failureEPKcS1_m+0x55)[0x2b5e9c1faf65]
/code/rust/x86_64-unknown-linux-gnu/stage0/bin/../lib/librustrt.so(+0x2fce9)[0x2b5e9c211ce9]
@killerswan
killerswan / floatplus.rs
Created June 2, 2012 05:39
floats as strings in Rust...
#[test]
fn rounding() {
// trailing zeroes should be inserted, or rather
// this dodgy floating point stuff should be rounded
assert "3.141589999" == #fmt["%9.9f", 3.14159];
assert "3.141589999" == float::to_str_common(3.14159, 9u, false);
assert "3.141590000" == my_to_str_common(3.14159, 9u, false); // FIXED
assert "3.14158" == float::to_str_common(3.14159, 5u, false);
assert "3.14159" == my_to_str_common(3.14159, 5u, false); // FIXED
@killerswan
killerswan / knucleotide.diff
Created June 1, 2012 08:35
Rust #fmt doesn't round floats?
$ diff -u knucleotide-output.txt <(rustx knucleotide.rs < knucleotide-input.txt)
--- knucleotide-output.txt 2012-05-30 02:33:06.912688859 -0700
+++ /dev/fd/63 2012-06-01 01:39:47.330695330 -0700
@@ -1,19 +1,19 @@
A 30.279
-T 30.113
+T 30.112
G 19.835
-C 19.773
+C 19.772
@killerswan
killerswan / demo.rs
Created May 29, 2012 01:35
where is libc::stat, anyways?
fn chmod(filepath: str, mode: i32) -> i32 {
import libc::types::os::arch::posix88::mode_t;
ret str::as_c_str(filepath, {|fp| libc::chmod(fp, mode as mode_t) });
}
fn cp(src: str, dest: str) {
// What I'd like to do is something like so,
// but where's the stat function?
//
@killerswan
killerswan / destructive-cargo-test.bash
Created May 27, 2012 03:30
how rust `cargo` should work!
#!/bin/bash -x
sudo rm -rf .cargo/ ~/.cargo/ /usr/local/lib/cargo/ \
&& sudo cargo init \
&& sudo cargo sync \
&& cargo install rustx \
&& cargo install --mode=local rustx \
&& cargo install -g rustx \
&& cargo install --mode=user rustx \
&& sudo cargo install -G rustx \
@killerswan
killerswan / gist:2795348
Created May 26, 2012 21:19
os::copy_file makes a funny smell?
fn copy_warn(src: str, dest: str) {
if !os::copy_file(src, dest) {
io::println(#fmt["Copying %s to %s failed", src, dest]);
}
}
fn main() {
// EDIT: not so bad, I just wasn't paying attention
copy_warn("./dir/a", "./dir2" );
copy_warn("./dir/a", "./dir2/a"); // THIS ONE IS OK
@killerswan
killerswan / cargo_bug.log
Created May 26, 2012 18:58
failure to copy on `cargo install rustx`
kunix:temp $ rm -rf .cargo
kunix:temp $
kunix:temp $ cargo init
info: signature ok for '/code/temp/.cargo/sources.json.new'
info: Initialized .cargo in /code/temp/.cargo
kunix:temp $
kunix:temp $ cargo sync
info: fetching source central...
info: fetched source: central
info: no signature for source central
@killerswan
killerswan / bug.log
Created May 26, 2012 14:26
Cargo permissions bug
$ cargo install rustx
rust: upcall fail 'can't make_dir /usr/local/lib/cargo/sources', /code/rust/src/cargo/cargo.rs:176
rust: domain main @0x1382e80 root task failed
rust: upcall fail 'killed', /code/rust/src/libcore/task.rs:454
...
$ cargo -g install rustx
rust: upcall fail 'can't make_dir /usr/local/lib/cargo/sources', /code/rust/src/cargo/cargo.rs:176
rust: domain main @0x15dde80 root task failed
rust: upcall fail 'killed', /code/rust/src/libcore/task.rs:454
@killerswan
killerswan / inversefb.py
Created May 22, 2012 21:39
Inverse Fizz Buzz
# Kevin Cantu
#
# inverse fizz buzz, per David Bell's comment
# http://www.jasq.org/2/post/2012/05/inverse-fizzbuzz.html
def makeOffsets(num):
off = [3,5,6,9,10,12,15]
acc = []
for x in range(num/7 + 2):
acc += map((lambda n: n + 15 * x), off)
@killerswan
killerswan / demo2.py
Created May 17, 2012 00:47
android-scripting full screen ui demo 2
import android
from full_screen_ui_wrapper import full_screen_ui_wrapper
droid = android.Android()
class main_screen(full_screen_ui_wrapper):