Skip to content

Instantly share code, notes, and snippets.

@siritori
siritori / cellular_automata.erl
Created December 16, 2011 00:11
セルオートマトン法・ω・
-module(cellular_automata).
-compile(export_all).
make_rule(N) ->
<<B1:1, B2:1, B3:1, B4:1, B5:1, B6:1, B7:1, B8:1>> = <<N>>,
fun({X1, X2, X3}) ->
<<Idx>> = <<0:5, X1:1, X2:1, X3:1>>,
lists:nth(Idx+1, [B8,B7,B6,B5,B4,B3,B2,B1])
end.
#include <stdio.h>
int main(int argc, char *argv[]) {
puts("Hello, world!\n");
return 0;
}
test.l:8: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘yylloc’
@siritori
siritori / get_host.pl
Created June 26, 2011 07:27
auto coins host suggester
#!/usr/bin/perl
my @sources = split(/\t/, `curl -s http://www.open.coins.tsukuba.ac.jp/status/coins/ | sed '32!d'`);
@sources = grep(/(cosmos|burnet|acacia)\d\d.*OK/, @sources);
for(my $i = 0; $i < $#sources+1; $i++) {
$sources[$i] =~ /(cosmos|burnet|acacia)(\d\d)/;
$sources[$i] = "$1$2.coins.tsukuba.ac.jp";
}
print "Content-type: text/html\n\n";
print $sources[rand($#sources)];
@siritori
siritori / gist:961109
Created May 8, 2011 04:34
foldl_sum.c
#include <stdlib.h>
#include <stdio.h>
typedef struct _list {
int d;
struct _list *next;
} list;
typedef int(*func)(list*, int);
list* new_list() {
@siritori
siritori / RecrioVirtualMachine.java
Created March 28, 2011 12:27
とみせかけてぜんぜん仮想機械じゃないデータ型管理まで書いたところ
import java.io.*;
import java.lang.*;
import java.util.*;
import java.util.concurrent.atomic.*;
enum DataType {
// primitive
BOOLEAN(true),
CHARACTER(true),
略語アンケート   該当する数字を答えてください
1.使用する 2.意味は分かるが、使用しない 3.使用しない
たこパ(たこ焼きパーティー)
ネトゲ(インターネットゲーム)
ファミマ(ファミリーマート)
バッシュ(バスケットシューズ)
テレカ(テレホンカード)
コピペ(コピー&ペースト)
とりま(とりあえず、まあ)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int is_last_token(char ch, char *str) {
while((*str != ch)&&(*str != '\0')) ++str;
if(*str == '\0') return 1;
while(*str == ch) ++str;
if(*str == '\0') return 1;
else return 0;
.h8300sx
.section .text
.global _switch_without_restore
.global _switch_with_restore
; void switch_without_restore(char *cur_sp, char *next_sp, function entry);
_switch_without_restore:
mov.l er6,@-er7
mov.l er7,er6
INCLUDES = src src_api src_sys src_usb
AS = h8300-elf-as
CC = h8300-elf-gcc -msx -mint32 -c $(addprefix -I../, $(INCLUDES))
LINK = h8300-elf-gcc -msx -mint32 -nostartfiles -nodefaultlibs
ASFLAGS = -g3
CFLAGS = -O0 -g3 -Wall
LINKFLAGS = -g3
OBJCOPY = h8300-elf-objcopy
LIBS = -lc -lm -lgcc