Skip to content

Instantly share code, notes, and snippets.

#![cfg(feature = "alloc")]
use jemallocator;
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
use nom::{
branch::alt,
@Geal
Geal / ClientSocket.cpp
Last active June 21, 2019 21:01
TP multithreading EPSI 4 2018 28/03/2018
#include "ClientSocket.h"
#include "SocketException.h"
ClientSocket::ClientSocket ( std::string host, int port ){
if ( ! Socket::create() ){
throw SocketException ( "Could not create client socket." );
}
if ( ! Socket::connect ( host, port ) ) {
extern crate nom;
use nom::IResult;
use nom::bytes::complete::tag;
use nom::sequence::{separated_pair, terminated};
use nom::character::complete::alphanumeric1;
use std::cell::{Cell, RefCell};
use std::rc::Rc;
use std::iter::Iterator;
use std::collections::HashMap;
use gen::GenError;
pub trait SerializeFn<I>: Fn(I) -> Result<I, GenError> {}
impl<I, F: Fn(I) ->Result<I, GenError>> SerializeFn<I> for F {}
pub fn slice<'a, S: 'a + AsRef<[u8]>>(data: S) -> impl SerializeFn<&'a mut [u8]> {
let len = data.as_ref().len();
@0xa9970031d0caaf6d;
struct Biscuit {
authority @0 :Block;
blocks @1 :List(Block);
# each element must be 32 bytes
keys @2 :List(Data);
signature @3 :Signature;
}
@Geal
Geal / http.rs
Created February 16, 2019 10:17
#[macro_use]
extern crate bencher;
#[macro_use]
extern crate nom;
extern crate nomfun;
use bencher::{black_box, Bencher};
use nom::IResult;
#[macro_use]
extern crate nom;
#[macro_use]
extern crate bencher;
extern crate fnv;
use fnv::FnvHashMap as HashMap;
use bencher::{Bencher, black_box};
@Geal
Geal / fun.rs
Created February 15, 2019 11:05
#[macro_use]
extern crate nom;
use nom::{digit, be_u32, IResult, Err};
named!(first<u32>, flat_map!(digit, parse_to!(u32)));
named!(second<u32>, call!(be_u32));
/*fn or<'a, 'b, F>(input: &'a [u8], left: F, right: F) -> IResult<&'a [u8], u32>
@Geal
Geal / dog.rs
Created February 13, 2019 17:35
//extern crate conform;
extern crate flate2;
extern crate image;
extern crate ndarray;
extern crate tar;
extern crate protobuf;
#[allow(unused_imports)]
#[macro_use]
extern crate tract_core;
$ RUST_BACKTRACE=1 cargo run --bin wasmtime -- testload.wasm --function=load
Finished dev [unoptimized + debuginfo] target(s) in 0.21s
Running `target/debug/wasmtime testload.wasm --function=load`
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', libcore/option.rs:355:21
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::print
at libstd/sys_common/backtrace.rs:71
at libstd/sys_common/backtrace.rs:59