Skip to content

Instantly share code, notes, and snippets.

View thiagopnts's full-sized avatar
phew

Thiago Pontes thiagopnts

phew
View GitHub Profile
#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;
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 != "" {
//struct mpc_parser_t {
// char retained;
// char *name;
// char type;
// mpc_pdata_t data;
//};
#[repr(C)]
#[deriving(Show)]
struct mpc_parser_t {
trait Foo {
fn foo(&self);
}
#[deriving(Show)]
enum SomeValue {
Value(int)
}
struct Bar {
enum OptionalInt {
Value(int),
Missing,
}
fn main() {
let x = Value(5);
let y = Missing;
match x {
// 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: '',
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
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)
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
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