Skip to content

Instantly share code, notes, and snippets.

use std::collections::HashMap;
use std::fs::File;
use std::io;
use std::io::prelude::*;
use regex::Regex;
use itertools::Itertools;
type MailHeader = HashMap<String, Vec<String>>;
fn read_file(path: &str) -> io::Result<String> {
use std::collections::HashMap;
use std::fs::File;
use std::io::{BufRead, BufReader, Result};
type MailHeader = HashMap<String, Vec<String>>;
fn proc_folding_line(line: String, prev_fname: &String, mail_header: &mut MailHeader) {
if prev_fname == "" {
eprintln!("prev-key error: line: {}", line);
}
@ykon
ykon / fizzbuzz_fp.py
Created August 4, 2018 07:56
FizzBuzz FP
# FizzBuzz FP
from typing import Callable, Iterable, List, TypeVar, Tuple
T = TypeVar('T')
def foreach(f: Callable[[T], None], l: Iterable[T]) -> None:
for x in l:
@ykon
ykon / fizzbuzz_oop.py
Created August 4, 2018 07:54
FizzBuzz OOP
# FizzBuzz OOP
from abc import ABC, abstractmethod
class BaseFizzBuzz(ABC):
def __init__(self, n: int) -> None:
self.number = n
@staticmethod
@ykon
ykon / fizzbuzz_imp.py
Last active August 4, 2018 07:50
FizzBuzz Imperative
# FizzBuzz Imperative
i = 1
while i < 101:
if i % 15 == 0:
print('FizzBuzz')
elif i % 3 == 0:
print('Fizz')
elif i % 5 == 0:
print('Buzz')
@ykon
ykon / test_dec.cpp
Created July 21, 2018 11:11
CMS Decrypt
// original: openssl/demos/cms/cms_dec.c
// g++ test_dec.cpp -lcrypto -o test_dec
#include <iostream>
#include <string>
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
#include <openssl/pkcs7.h>
@ykon
ykon / test_enc.cpp
Created July 21, 2018 11:09
CMS Encrypt
// original: openssl/demos/cms/cms_enc.c
// g++ test_enc.cpp -lcrypto -o test_enc
#include <iostream>
#include <string>
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
#include <openssl/pkcs7.h>
@ykon
ykon / test_sign.cpp
Created July 21, 2018 11:06
CMS Sign
// original: openssl/demos/cms/cms_sign.c
// g++ test_sign.cpp -lcrypto -o test_sign
#include <iostream>
#include <string>
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
#include <openssl/pkcs7.h>
@ykon
ykon / test_verify.cpp
Created July 21, 2018 11:04
CMS Verify
// original: openssl/demos/cms/cms_ver.c
// g++ test_verify.cpp -lcrypto -o test_verify
#include <iostream>
#include <string>
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
#include <openssl/pkcs7.h>
interface FizzBuzz { kind: 'fizzbuzz'; num: number; }
interface Fizz { kind: 'fizz'; num: number; }
interface Buzz { kind: 'buzz'; num: number; }
interface Other { kind: 'other'; num: number; }
type FizzBuzzType = FizzBuzz | Fizz | Buzz | Other;
const range_100: () => number[] = () => Array.apply(0, Array(100)).map((x, y) => y + 1);
const is_fizzbuzz: (n: number) => boolean = n => (n % 15) === 0;