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
//! ```cargo | |
//! [dependencies.nom] | |
//! version = "4.0" | |
//! features = ["verbose-errors"] | |
//! ``` | |
#[macro_use] | |
extern crate nom; | |
#[derive(Clone, Debug, PartialEq)] |
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
/** | |
* A very simple dynamically-resized HashTable implementation in C. | |
*/ | |
#include <assert.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#define GROWTH_FACTOR 3 |
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
#!/usr/bin/env run-cargo-script | |
// cargo-deps: quickcheck | |
use std::{borrow::Borrow, io::{self, BufRead}}; | |
#[cfg(test)] | |
#[macro_use] | |
extern crate quickcheck; | |
fn longest_common_prefix_length(x: &str, y: &str) -> usize { | |
x.chars() |
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::collections::HashMap; | |
macro_rules! hashmap { | |
{$($key:expr => $value:expr),*} => {{ | |
let mut __hm = HashMap::new(); | |
$( | |
__hm.insert($key, $value); | |
)* | |
__hm | |
}} |
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
#!/usr/bin/env run-cargo-script | |
//! A factoid bot written in Rust, using the irc library. | |
//! This bot is written to showcase the irc library, however it might also be useful. | |
//! | |
//! To utilize, create a `factoid_config.json` file in your working directory defining at least | |
//! nickname, server and channels. | |
//! | |
//! If you want some useful logging, you can set the `RUST_LOG` environment variable equal to | |
//! `factoid_bot=info`. | |
//! |
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
#!/usr/bin/env python3 | |
from llvmlite import ir, binding as llvm | |
def compile_assembunny(instructions): | |
instructions = tuple(instructions) | |
program_size = len(instructions) | |
char = ir.IntType(8) | |
int32 = ir.IntType(32) |
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
#!/usr/bin/env python3 | |
from operator import sub, mul, floordiv | |
from functools import reduce | |
SHORT_LIST_THRESHOLD = 3 | |
def add_repr(cls): | |
import inspect | |
argspec = inspect.getargspec(cls.__init__) |
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
#!/usr/bin/env python3 | |
from operator import sub, mul, floordiv | |
from functools import reduce | |
SHORT_LIST_THRESHOLD = 3 | |
def add_repr(cls): | |
import inspect | |
argspec = inspect.getargspec(cls.__init__) |
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
#include <stdbool.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
typedef char* Key; | |
typedef char* Value; | |
typedef struct BucketValue { | |
/** The key that matches this entry. */ |
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
#include <stdio.h> | |
#include <stdlib.h> | |
typedef void (*printer_func)(void*); | |
struct LinkedList { | |
void *value; | |
struct LinkedList *next; | |
}; |