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 <stdint.h> | |
#include <string.h> | |
void | |
row_align(uint8_t *dst, const uint8_t *src, const size_t width_in_bits, const size_t height) | |
{ | |
const size_t width_in_whole_bytes = width_in_bits / 8; | |
if (width_in_bits % 32 == 0) { // word-aligned | |
memcpy(dst, src, width_in_whole_bytes * height); |
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 <type_traits> | |
namespace type_list { | |
class nil {}; | |
template<class Head, class Tail> | |
class cons {}; | |
// map f [] = [] |
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> | |
static int pstrcmp(const void *, const void *); | |
int | |
main(void) | |
{ | |
char buf[BUFSIZ]; |
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 Control.Applicative (liftA2) | |
data Term a = App (Term a) (Term a) | |
| Lam (Term (Maybe a)) | |
| Var a | |
instance Functor Term where | |
fmap f (App s t) = App (fmap f s) (fmap f t) | |
fmap f (Lam t) = Lam (fmap (fmap f) t) | |
fmap f (Var x) = Var (f x) |
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> | |
const char clo[64] = { | |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 5, 6, | |
}; | |
const char b64[64] = { |
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
BEGIN { FS = ";"; OFS = ","; } | |
{ name = $2; } | |
name ~ /<.*>/ { name = $11; } | |
name { print $1, name, $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
cartesian :: [[a]] -> [[a]] | |
cartesian [] = [[]] | |
cartesian (xs:zss) = [x:ys | x <- xs, ys <- cartesian zss] |
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
from fractions import Fraction | |
def catalan(n): | |
c = 1 | |
for k in range(2, n + 1): | |
c *= Fraction(n + k, k) | |
return int(c) |
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
from queue import PriorityQueue | |
class Field: | |
def __init__(self, size, align): | |
self.size = size | |
self.align = align | |
class Struct: | |
def __init__(self, fields): | |
size = 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
#!/bin/sh | |
dir=${1%/*} | |
bin=${1##*/} | |
shift | |
unset flag | |
set -f | |
IFS=: |