Skip to content

Instantly share code, notes, and snippets.

View cfr's full-sized avatar
💭
👾

Stan Serebryakov cfr

💭
👾
View GitHub Profile
@cfr
cfr / Roman.lhs
Last active August 29, 2015 14:21
[Haskell-cafe] Type level Roman numerals and skew binary random access lists
https://mail.haskell.org/pipermail/haskell-cafe/2011-August/094533.html
Ivan Tomac ivan.tomac at gmail.com
Wed Aug 10 13:26:20 CEST 2011
---------------------------------------------------------------------
I've recently been playing with Sebastian Fischer's explicit sharing
monad library (found at http://sebfisch.github.com/explicit-sharing)
and after looking at the code noticed the implementation memoizes
import Foundation
public protocol JSONEncodable {
var json: [String : AnyObject] { get }
var Name: String { get }
}
public protocol JSONDecodable {
init?(json: [String : AnyObject])
}
@cfr
cfr / pad.c
Last active August 29, 2015 14:21
#include <stdio.h>
typedef struct {
char her;
long double hear[16];
int hero;
float yo[17];
} A;
#pragma pack(1)
protocol Convertible {
func to<T>() -> T;
// var <T>to: T { get } // multiple instances of generic var is not allowed
}
extension String {
func to() -> String {
return self
}
// clang -std=c99 -O3 cpy-vs-cat.c
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <mach/mach_time.h>
const int e6 = 1000000;
#define repeat for(int j = 0; j < e6; j++)
void flush() { fflush(stdout); }
@cfr
cfr / Completion.swift
Last active August 29, 2015 14:23
Completion type instead of (a → Void)
struct Completion<A> {
let f: (A -> Void)
init(f: A -> Void) {
self.f = f
}
func run(a: A) {
f(a)
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
syntax:glob
main
*.o
#import <stdio.h>
#import <highgui.h>
#import <cv.h>
IplImage *renderFaces(IplImage *, CvSeq *, double);
int main(int argc, char** argv)
{
double scale = 5; // primary speed factor