This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Override some stuff to detect FacotoryGirl usage out of `it` | |
module RSpec | |
module Core | |
class ExampleGroup | |
class << self | |
# redefine to do nothing | |
def it(*args) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def show_page | |
filename = "/tmp/shot.png" | |
driver = page.driver | |
driver.save_screenshot(filename) | |
system "eog #{filename}" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Benchmark of djb2, sdbm and lose lose hashing algorithms | |
# Algorithm descriptions: http://www.cse.yorku.ca/~oz/hash.html | |
# Output | |
# | |
# ===== djb2 ===== | |
# Values: 5000000 | |
# Collisions: 2988 | |
# Time: 0.76589 | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let funcs = [ | |
("+", sum as fn(f64, f64) -> f64), | |
("-", sub), | |
("*", mult), | |
("/", div), | |
("^", pow) | |
]; | |
for &(name, func) in funcs.iter() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let v1 = vec![4, 8, 12, 16]; | |
let v2 = mult(&v1, 10); | |
pv("v1", &v1); | |
pv("v2", &v2); | |
println!(""); | |
println!("{}", v1[2]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait HasArea { | |
fn area(&self) -> f64; | |
} | |
struct Cyrcle { | |
radius : f64, | |
} | |
impl HasArea for Cyrcle { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Debug)] | |
struct Point { | |
x : f64, | |
} | |
trait Add { | |
fn add(&self, &Self) -> Self; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Debug)] | |
struct Point { | |
x : f64, | |
} | |
trait Math : { | |
fn sub(&self, &Self) -> Self; | |
fn add(&self, &Self) -> Self; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::ops::Mul; | |
#[derive(Debug)] | |
struct Vector { | |
x : f64, | |
y : f64 | |
} | |
impl<'a> Mul<f64> for &'a Vector { | |
type Output = Vector; |