Skip to content

Instantly share code, notes, and snippets.

View alphaKAI's full-sized avatar

Akihiro Shoji alphaKAI

View GitHub Profile
@alphaKAI
alphaKAI / le.ts
Created April 5, 2016 13:05
TypeScript Lazy Evalution
class Thunk {
public value: number;
public evaluated: boolean;
constructor(value: any) {
this.value = value
this.evaluated = false
}
}
class Lambda {
@alphaKAI
alphaKAI / le.rb
Last active April 5, 2016 13:05
Ruby Lazy Evaluation
#encoding:utf-8
class Thunk
attr_accessor :value, :evaluated
def initialize(value)
@value = value
@evaluated = false
end
end
@alphaKAI
alphaKAI / AnonymousClass.d
Last active March 30, 2016 05:14
Anonymous Class for D Language
import std.algorithm,
std.typecons,
std.string,
std.array,
std.range,
std.conv;
template AnonymousClassImpl(
string BaseClassName,
string bodyString,
@alphaKAI
alphaKAI / pcre4dc.c
Last active March 27, 2016 10:13
An Example of D bindings for PCRE
#include <pcre.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#define DEBUG false
struct Matchs {
int length;
@alphaKAI
alphaKAI / Makefile
Last active March 17, 2016 10:51
A Brainfuck Interpreter on UEFI Shell (Requirements: gnu-efi)
ARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)
OBJS = main.o
TARGET = main.efi
EFIINC = /usr/include/efi
EFIINCS = -I$(EFIINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol
EFILIB = /usr/lib
EFI_CRT_OBJS = $(EFILIB)/crt0-efi-$(ARCH).o
EFI_LDS = $(EFILIB)/elf_$(ARCH)_efi.lds
CFLAGS = $(EFIINCS) \
-fno-stack-protector \
@alphaKAI
alphaKAI / tinyBase64NonTyped.d
Created February 27, 2016 07:13
An One-liner base64 encoder -Non typed version-
import std.algorithm,
std.string,
std.ascii,
std.range,
std.conv;
import std.stdio;
R delegate(Args) Z(R, Args...)(R delegate(R delegate(Args), Args) f){
return (Args args) => f(Z(f), args);
}
@alphaKAI
alphaKAI / tinyBrainfuckNonTyped.d
Last active February 27, 2016 07:14
An One-liner Brainfuck interpreter - Non typed version -
import std.algorithm,
std.array,
std.stdio,
std.string,
std.conv;
import core.memory;
R delegate(Args) Z(R, Args...)(R delegate(R delegate(Args), Args) f){
return (Args args) => f(Z(f), args);
@alphaKAI
alphaKAI / iTunes.mm
Last active February 23, 2016 02:35
Get CurrentTrack Information of iTunes(OS X) in Objective-C. (I'm not an Objective-C programmer maybe this code is wrong.)
#include <stdlib.h>
#include <stdbool.h>
// You can generate iTunes.h as follows:
// $ sdef /Applications/iTunes.app | sdp -fh --basename iTunes
#import "iTunes.h"
// For ABI
extern "C" {
struct Music {
const char* name;
@alphaKAI
alphaKAI / bench.d
Last active February 12, 2016 10:09
Multi Thread Benchmark in D
import std.parallelism,
std.algorithm,
std.datetime,
std.stdio,
std.range,
std.conv,
std.math;
enum times = 100;
bool sideEffectTask;
import std.algorithm,
std.string,
std.ascii,
std.range,
std.conv;
import std.stdio;
R delegate(Args) Z(R, Args...)(R delegate(R delegate(Args), Args) f){
return (Args args) => f(Z(f), args);
}