This file contains hidden or 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
/// Returns the two points on a circle that form a tangent with the given point. | |
/// | |
/// If the point is inside the circle, returns `None`. | |
pub fn circle_point_tangents( | |
center: Point2<f32>, | |
radius: f32, | |
point: Point2<f32>, | |
) -> Option<[Point2<f32>; 2]> { | |
// I'm so glad the internet exists | |
// http://www.ambrsoft.com/TrigoCalc/Circles2/CirclePoint/CirclePointDistance.htm |
This file contains hidden or 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
pub struct X { | |
a: i32, | |
b: i32, | |
c: i32, | |
d: i32, | |
} | |
impl X { | |
pub fn set_a_mut(&mut self, a: i32) { | |
self.a = a; |
This file contains hidden or 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 Node { } | |
struct LI { | |
nodes: Vec<Box<Node>> | |
} | |
impl Node for LI { } | |
struct A<'a> { | |
nodes: Vec<Box<Node>>, |
This file contains hidden or 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
#!/bin/bash | |
# Usage: rust-backtrace ./my-rust-prog args... | |
exec gdb -batch -n -x /dev/fd/3 --args "$@" 3<<ENDGDB | |
set height 0 | |
set breakpoint pending on | |
break rust_fail |
This file contains hidden or 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 mut c = Container { tests: ~[] }; | |
c.add_str_test(~"/"); | |
c.tests[0].test(); | |
} | |
trait Test { | |
fn test(&self) -> bool; | |
} |
This file contains hidden or 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
import hashlib | |
class FeistelSHA1: | |
rounds = 4 # 4 rounds is sufficient as long as the round function is cryptographically secure | |
split = 1 / 2 | |
def __init__(self, key, rounds=rounds): | |
self.subkeys = [hashlib.sha1(bytes((i,)) + key).digest() for i in range(rounds)] |