Skip to content

Instantly share code, notes, and snippets.

use crypto_bench;
use openssl::{rand, symm};
use openssl::error::ErrorStack;
use test;
fn generate_sealing_key(algorithm: symm::Cipher) -> Result<Vec<u8>, ()> {
let mut key_bytes = vec![0u8; algorithm.key_len()];
try!(rand::rand_bytes(&mut key_bytes).map_err(|_| ()));
Ok(key_bytes)
}
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
namespace ConsoleApp1
{
class Program
{
// x86_64-w64-mingw32-gcc tfo.c -o tfo -lws2_32 -static -g -O0
#define TARGET_URL "localhost"
#define TARGET_PORT 8000
#ifndef _WINSOCK_H
#define _WINSOCK_H
#ifdef __MINGW32__
/**
* http://d.hatena.ne.jp/odz/20070507/1178558340
*/
// x86_64-w64-mingw32-gcc echo.c wepoll.c -O0 -o echo -g -lws2_32 -static
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
{-# LANGUAGE RankNTypes #-}
module Nat where
import Prelude hiding (succ, pred)
class Nat a where
zero :: a
succ :: a -> a
pred :: a -> a
fold :: (b -> b) -> b -> a -> b
@linusyang
linusyang / GADT.hs
Created July 15, 2015 12:15
Code for Fun with phantom types
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeOperators #-}
module Main where
import Data.Char (ord, chr)
import Text.PrettyPrint.ANSI.Leijen hiding (pretty)
import qualified Data.Ord as DO (compare)
import Prelude hiding (compare)
@linusyang
linusyang / fix_rpath.py
Last active August 29, 2015 14:13
Fix ghc rpath issue when dynamically linking
#!/usr/bin/env python
'''
Fix the rpath issue when cabal (ghc) links dynamically on Linux and OS X.
Put this script in your .cabal/bin for execution.
'''
import os
import re
import sys
@linusyang
linusyang / libom-patch.py
Created November 17, 2013 17:41
New WebKit-based Opera Mobile Off-Road Proxy Modifier
#!/usr/bin/env python
#-*- encoding: utf-8 -*-
#
# Opera Mobile Off-Road Proxy Modifier
# By Linus Yang <laokongzi@gmail.com>
# Licensed under GPLv3
#
from optparse import OptionParser
from zipfile import ZipFile, ZipInfo, ZIP_DEFLATED
@linusyang
linusyang / dfa.py
Created April 9, 2013 17:35
A simple NFA to DFA converter
#!/usr/bin/env python
#
# By Linus Yang <laokongzi@gmail.com>
# Written on iPad using Textastic Code Editor
# Licensed under GPL v3
#
'''
Function:
Transform an NFA to DFA then simplify it