Skip to content

Instantly share code, notes, and snippets.

@drm343
drm343 / easy_otp.erl
Last active January 29, 2016 17:54
Erlang 的 hello world 等級 server
-module(easy_otp).
-export([ start/1
, close/1
]).
% define own behaviour
-export([behaviour_info/1]).
-record(server, { socket
, mod
@drm343
drm343 / ada_style.h
Last active April 20, 2017 03:54
工作上不要學
#define PROCEDURE(func_name, type_in) void func_name type_in
#define FUNCTION(func_name, type_in, type_out) type_out func_name type_in
#define IS {
#define END }
#define BEGIN
#define RECORD_TYPE(name,code) typedef struct { \
code \
} name; \
@drm343
drm343 / sdl2_text_input_utf8.c
Created July 15, 2017 06:55
SDL2 處理中文輸入
// Use `gcc sdl2_text_input_utf8.c -lSDL2 -lSDL2_ttf -o test_program`.
//
// You must use CJK font for SDL2_ttf and put the same directory with test_program.
// This example use "NotoSansMonoCJKtc-Regular.otf".
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <SDL2/SDL.h>
#lang racket
(provide
(all-defined-out))
; new table
(define empty-table
(lambda (name)
'()))
@drm343
drm343 / dm-solve.py
Last active February 15, 2022 05:27
幫解問題 by minikanren with python3
#!/usr/bin/env python3
# pip install miniKanren
from unification import reify
from kanren import fact, facts, run, Var, conde, Relation, eq
from kanren.core import fail, succeed, lall, lany
base_item = Relation()
formula = Relation()