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
| #user nobody; | |
| worker_processes 1; | |
| error_log logs/error.log; | |
| error_log logs/error.log notice; | |
| error_log logs/error.log info; | |
| pid logs/nginx.pid; |
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 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 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
| //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 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 Foo { | |
| fn foo(&self); | |
| } | |
| #[deriving(Show)] | |
| enum SomeValue { | |
| Value(int) | |
| } | |
| struct Bar { |
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
| enum OptionalInt { | |
| Value(int), | |
| Missing, | |
| } | |
| fn main() { | |
| let x = Value(5); | |
| let y = Missing; | |
| match x { |
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
| // 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 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::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 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
| 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 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
| 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 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
| 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 |