Skip to content

Instantly share code, notes, and snippets.

View rrichardson's full-sized avatar
💭
⚔️ Hacking Away

Rick Richardson rrichardson

💭
⚔️ Hacking Away
View GitHub Profile
typedef struct HCountedArray_ {
size_t capacity;
size_t used;
HArena * arena;
struct HParsedToken_ **elements;
} HCountedArray;
typedef struct HBytes_ {
const uint8_t *token;
size_t len;
enum HParserBackend {
PB_MIN = 0,
PB_PACKRAT = PB_MIN, // PB_MIN is always the default.
PB_REGULAR,
PB_LLk,
PB_LALR,
PB_GLR,
PB_MAX = PB_GLR
}
@rrichardson
rrichardson / gist:4e63b4b4189f2c486bdf
Last active August 29, 2015 14:04
recursion in rust.. looks like hieroglyphics
use std::fmt::Show;
trait Mappable<T> {
fn each<'r>(&self, f: &mut |&T|: 'r -> ());
fn map<'r, B>(&self, f: &mut |&T|: 'r -> B) -> Vec<B>;
}
enum BinaryTree<T> {
Leaf(T),
fn init_parser() -> *mut h::HParser {
unsafe {
let token1 = h::h_token(hello.as_ptr(), from_uint(hello.char_len()).expect("uint conversion failed"));
let token2 = h::h_token(world.as_ptr(), from_uint(world.char_len()).expect("uint conversion failed"));
let token3 = h::h_token(there.as_ptr(), from_uint(there.char_len()).expect("uint conversion failed"));
let token4 = h::h_token(bang.as_ptr(), from_uint(bang.char_len()).expect("uint conversion failed"));
h::h_sequence(token1, h::h_choice(token2, token3, token4, ptr::null<h::HParser>()) , ptr::null<h::HParser>())
}
}
extern crate libc;
use std::num::{ from_uint };
use std::ptr;
use std::mem;
use std::io::stdio;
use h = hammerll;
static hello : &'static str = "Hello ";
static world : &'static str = "World";
static there : &'static str = "there";
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/resource.h>
#define STACKSIZE (16 * 1024)
#define NUM_THREADS 100000
#define getlimit(x) getrlimit(RLIMIT_##x, &limit); printf("%s current: %lu, max: %lu\n", #x, limit.rlim_cur, limit.rlim_max);
void *do_nothing(void *args)
{
execute pathogen#infect()
" set UTF-8 encoding
set enc=utf-8
set fenc=utf-8
set termencoding=utf-8
" disable vi compatibility (emulation of old bugs)
set nocompatible
" use indentation of previous line
set autoindent
22:37:31.976 [sparkDriver-akka.actor.default-dispatcher-3] DEBUG o.a.s.s.BlockManagerMasterActor - [actor] handled message (0.072741 ms) ExpireDeadHosts from Actor[akka://sparkDriver/user/BlockManagerMaster#273583151]
22:37:32.376 [sparkDriver-akka.actor.default-dispatcher-13] DEBUG o.a.s.s.c.SparkDeploySchedulerBackend - [actor] received message ReviveOffers from Actor[akka://sparkDriver/user/CoarseGrainedScheduler#-801996212]
22:37:32.377 [sparkDriver-akka.actor.default-dispatcher-13] DEBUG o.a.s.s.c.SparkDeploySchedulerBackend - [actor] handled message (0.327742 ms) ReviveOffers from Actor[akka://sparkDriver/user/CoarseGrainedScheduler#-801996212]
22:37:33.376 [sparkDriver-akka.actor.default-dispatcher-13] DEBUG o.a.s.s.c.SparkDeploySchedulerBackend - [actor] received message ReviveOffers from Actor[akka://sparkDriver/user/CoarseGrainedScheduler#-801996212]
22:37:33.377 [sparkDriver-akka.actor.default-dispatcher-13] DEBUG o.a.s.s.c.SparkDeploySchedulerBackend - [actor] handled message (0.343444 ms) ReviveO
main : Element
main = plotAxis 580 300 "time - minutes" "events"
plotAxis w h xLabel yLabel =
let lineWidth = 2
labelHeight = 10
arrowSize = 6
ylen = toFloat (h-lineWidth-2*arrowSize-4*labelHeight)
xlen = toFloat (w-lineWidth-2*arrowSize-4*labelHeight)
maxX = 100
trait Strategy<Output> {
fn send(&self, item: Result<&Output>);
fn accept(&mut self, sub: &Subscriber<Output>) -> Option<uint>;
}
type Sub<I> = (Subscription, Subscriber<I>);
//This is the most basic strategy which only accepts a single subscriber
struct SingleStrategy<O> {
subscriber: Option<Sub<O>>,