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
pub fn add_text(&mut self, text: &'static str) { | |
let re = regex!(r"\n"); | |
let without_newline = re.replace_all(text, "."); | |
let seps = regex!("([.!?;:])"); | |
let mut pieces = seps.split(without_newline.as_slice()); | |
let mut sentence = "".to_string(); | |
for piece in pieces { | |
if piece != "" { |
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
//struct mpc_parser_t { | |
// char retained; | |
// char *name; | |
// char type; | |
// mpc_pdata_t data; | |
//}; | |
#[repr(C)] | |
#[deriving(Show)] | |
struct mpc_parser_t { |
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 Foo { | |
fn foo(&self); | |
} | |
#[deriving(Show)] | |
enum SomeValue { | |
Value(int) | |
} | |
struct Bar { |
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
enum OptionalInt { | |
Value(int), | |
Missing, | |
} | |
fn main() { | |
let x = Value(5); | |
let y = Missing; | |
match x { |
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
// Karma configuration | |
// Generated on Wed Jul 02 2014 11:05:24 GMT-0300 (BRT) | |
module.exports = function(config) { | |
config.set({ | |
// base path that will be used to resolve all patterns (eg. files, exclude) | |
basePath: '', |
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::vec::Vec; | |
use std::rand::random; | |
use super::individual::Individual; | |
pub struct Population<'ind> { | |
size: uint, | |
individuals: Vec<&'ind mut Individual> | |
} | |
// ??? | |
// compiler error: wrong number of lifetime parameters: expected 1 but found 0 |
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
from random import random, randint | |
class Individual: | |
def __init__(self, size): | |
self.size = size | |
self.genes = map(lambda x: 1 if random() < 0.50 else 0, [0] * self.size) | |
def fitness(self): | |
return abs((sum([1 + i for i in range(len(self.genes)) if self.genes[i] == 0]) - 36.0) / 36.0) |
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
private function _onStageResize(event:Event):void { | |
_hls.width = stage.stageWidth; | |
stage.fullScreenSourceRect = new Rectangle(0,0,stage.stageWidth,stage.stageHeight); | |
_resize(); | |
}; | |
private function _resize():void { | |
var rect:Rectangle; | |
rect = ScaleVideo.resizeRectangle(_videoWidth, _videoHeight, stage.stageWidth, stage.stageHeight); | |
// resize video |
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
from math import sqrt | |
from heapq import heappush, heappop, nsmallest | |
class Point: | |
def __init__(self, coord, data=None): | |
self.coord = coord | |
self.data = data | |
self.dest = None |
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
.background { | |
background-image: none; | |
background-color: rgb(0, 86, 169); | |
} | |
.logo { | |
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPsAAACpCAYAAADtNEtaAAAEJGlDQ1BJQ0MgUHJvZmlsZQAAOBGFVd9v21QUPolvUqQWPyBYR4eKxa9VU1u5GxqtxgZJk6XtShal6dgqJOQ6N4mpGwfb6baqT3uBNwb8AUDZAw9IPCENBmJ72fbAtElThyqqSUh76MQPISbtBVXhu3ZiJ1PEXPX6yznfOec7517bRD1fabWaGVWIlquunc8klZOnFpSeTYrSs9RLA9Sr6U4tkcvNEi7BFffO6+EdigjL7ZHu/k72I796i9zRiSJPwG4VHX0Z+AxRzNRrtksUvwf7+Gm3BtzzHPDTNgQCqwKXfZwSeNHHJz1OIT8JjtAq6xWtCLwGPLzYZi+3YV8DGMiT4VVuG7oiZpGzrZJhcs/hL49xtzH/Dy6bdfTsXYNY+5yluWO4D4neK/ZUvok/17X0HPBLsF+vuUlhfwX4j/rSfAJ4H1H0qZJ9dN7nR19frRTeBt4Fe9FwpwtN+2p1MXscGLHR9SXrmMgjONd1ZxKzpBeA71b4tNhj6JGoyFNp4GHgwUp9qplfmnFW5oTdy7NamcwCI49kv6fN5IAHgD+0rbyoBc3SOjczohbyS1drbq6pQdqumllRC/0ymTtej8gpbbuVwpQfyw66dqEZyxZKxtHpJn+tZnpnEdrYBbueF9qQn93S7HQGGHnYP7w6L+YGHNtd1FJitqPAR+hERCNOFi1i1alKO6RQnjKUxL1GNjwlMsiEhcPLYTEiT9ISbN15OY/jx4SMshe9LaJRpTvHr3C/ybFYP1PZAfwfYrPsMBtnE6SwN9ib7AhLwTrBDgUKcm06FSrTfSj187xPdVQWOk5Q8vxAfSiIUc7Z7xr6zY/+hpqwSy |