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
use std::num::pow; | |
pub struct Point { x: int, y: int } | |
struct Line { p1: Point, p2: Point } | |
impl Line { | |
pub fn length(&self) -> f64 { | |
let xdiff = self.p1.x - self.p2.x; | |
let ydiff = self.p1.y - self.p2.y; | |
((pow(xdiff, 2) + pow(ydiff, 2)) as f64).sqrt() |
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
var ocemail = function(url, domain) { | |
var capitalize = function(s) { return s.charAt(0).toUpperCase() + s.slice(1).toLowerCase(); } | |
// url parser from http://jsperf.com/url-parsing | |
var urlParseRE = /^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/; | |
var hostname = urlParseRE.exec(url)[11]; | |
if (hostname) { | |
var domainMatch = /^(?:www[.])?([-a-z0-9]+)[.](house|senate)[.]gov$/; | |
var match = domainMatch.exec(hostname.toLowerCase()); |