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
import Data.Char (toLower) | |
rdToDec :: Char -> Int | |
rdToDec 'i' = 1 | |
rdToDec 'v' = 5 | |
rdToDec 'x' = 10 | |
rdToDec 'l' = 50 | |
rdToDec 'c' = 100 | |
rdToDec 'd' = 500 |
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
// Licensed under MIT license. | |
// (c) Lewin Bormann 2014 | |
# include <string> | |
# include <iostream> | |
# include <list> | |
# include <cstring> | |
# include <algorithm> | |
using std::string; |
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> | |
# include <string.h> | |
# include <stdbool.h> | |
_Bool find(const char* haystack, const char* needle) | |
{ | |
size_t hlen = strlen(haystack); | |
size_t nlen = strlen(needle); | |
unsigned int found = 0; |
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
// Converts a number to a little-endian byte array | |
func lengthToBytes(l uint64) [8]byte { | |
var sizebuf [8]byte | |
var i int = 7 | |
for ; i >= 0; i-- { | |
// The commented implementation is 5 times slower but equivalent | |
/* | |
var divisor uint64 = 1 << (uint(i) * 8) | |
sizebuf[i] = uint8(l / divisor) |
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
# ifndef _CHAN_HPP | |
# define _CHAN_HPP | |
# include <deque> | |
# include <mutex> | |
# include <condition_variable> | |
# include <utility> | |
template<typename T> | |
class Chan { |
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
extern crate time; | |
extern crate argparse; | |
use std::cmp::Ordering; | |
use std::cmp::PartialOrd; | |
use std::fmt::Write; | |
use std::marker::Copy; | |
use std::option::Option; | |
use std::ops::Add; | |
use std::ops::Sub; |
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
fn read_client_secret(file: &str) -> ApplicationSecret { | |
use std::fs::{File, OpenOptions}; | |
use std::io::Read; | |
let mut secret = String::new(); | |
OpenOptions::new().read(true).open(file).unwrap().read_to_string(&mut secret); | |
let consappsec: ConsoleApplicationSecret = serde_json::from_str(secret.as_str()).unwrap(); | |
consappsec.installed.unwrap() | |
} |
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::cmp::Ordering; | |
use std::fmt::Debug; | |
// min-heap, for now | |
#[derive(Debug)] | |
struct Heap<T: Ord> { | |
h: Vec<T>, | |
/// min heap if true, otherwise max heap | |
min: bool, | |
} |
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 with | |
// [dependencies] | |
// combine = "1.3.0" | |
extern crate combine; | |
use combine::*; | |
#[derive(Debug)] | |
enum Expr { | |
Scalar(f64), |
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
package play1 | |
import ( | |
"errors" | |
"time" | |
) | |
type MyStruct struct { | |
m map[string]uint64 | |
} |