Skip to content

Instantly share code, notes, and snippets.

Avatar

Chuck Remes chuckremes

View GitHub Profile
View gist:9080237
/*
Lesson:
Wrapping it all up into a struct & impl.
*/
struct BubbleSort;
impl BubbleSort {
View generic.rs
struct Helper<T> {
field1: T
}
impl<T> Helper<T> {
fn new (foo: T) -> Helper<T> {
Helper { field1: foo }
}
View bit_set.rs
struct Helper {
field1: u64
}
impl Helper {
fn new (foo: u64) -> Helper {
Helper { field1: foo }
}
fn bit_set (&self, bit: u64) -> bool {
View gist:9176029
cremes$ rustc --test vec.rs
vec.rs:4362:12: 4362:17 error: expected `{` or `mod` but found `crate`
vec.rs:4362 extern crate test;
View gist:9195551
cremes$ x86_64-apple-darwin/stage2/bin/rustc -L./x86_64-apple-darwin/rt/ --test src/libstd/lib.rs
src/libstd/vec.rs:4923:13: 4923:27 error: type `~[u64]` does not implement any method in scope named `smoothsort`
src/libstd/vec.rs:4923 v.smoothsort();
^~~~~~~~~~~~~~
error: aborting due to previous error
View gist:9191304
cremes$ x86_64-apple-darwin/stage2/bin/rustc --test src/libstd/lib.rs
src/libstd/path/posix.rs:701:32: 701:39 warning: unnecessary parentheses around assigned value, #[warn(unnecessary_parens)] on by default
src/libstd/path/posix.rs:701 let path = ($path);
^~~~~~~
src/libstd/path/posix.rs:698:9: 711:10 note: in expansion of t!
src/libstd/path/posix.rs:711:9: 711:30 note: expansion site
src/libstd/path/posix.rs:702:32: 702:39 warning: unnecessary parentheses around assigned value, #[warn(unnecessary_parens)] on by default
src/libstd/path/posix.rs:702 let join = ($join);
^~~~~~~
src/libstd/path/posix.rs:698:9: 711:10 note: in expansion of t!
View gist:9673538
Total running time: 60.377214919000004s
index % time self children called name
----------------------------------------------------------
[1] 100.0 0.00 60.37 1 Rubinius::Loader#script [1]
0.00 60.37 1 Rubinius::CodeLoader.load_script [2]
0.00 0.00 1 IO.read
-------------------------------------------------------
0.00 60.37 1 Rubinius::Loader#script [1]
[2] 100.0 0.00 60.37 1 Rubinius::CodeLoader.load_script [2]
0.00 60.37 1 Rubinius::CodeLoader#load_script [3]
View iovars.rb
# before
def reset!
@start = @used = 0
@eof = false
@write_synced = true
end
def discard(skip)
while @start < @used
View bench_each_byte.rb
require 'benchmark'
require 'benchmark/ips'
small_file = File.join(File.dirname(__FILE__), 'small.txt')
medium_file = File.join(File.dirname(__FILE__), 'medium.txt')
large_file = File.join(File.dirname(__FILE__), 'large.txt')
# Open these before the actual benchmarks so we don't also benchmark
# File.open().
small_handle = File.open(small_file, 'r')
View gist:9777120
require 'benchmark'
require 'benchmark/ips'
small_file = File.join(File.dirname(__FILE__), 'small.txt')
medium_file = File.join(File.dirname(__FILE__), 'medium.txt')
large_file = File.join(File.dirname(__FILE__), 'large.txt')
# Open these before the actual benchmarks so we don't also benchmark
# File.open().
small_handle = File.open(small_file, 'r')