Skip to content

Instantly share code, notes, and snippets.

View tanakahx's full-sized avatar
🏠
Working from home

Hiroyuki Tanaka tanakahx

🏠
Working from home
View GitHub Profile
@tanakahx
tanakahx / bm.lisp
Last active September 27, 2015 13:13
Simple Boltzmann Machine Simulation
(in-package :cl-user)
(eval-when (:compile-toplevel :load-toplevel :execute)
(ql:quickload '(:cl-num-utils :lla :array-operations) :silent t))
(defpackage :bm
(:use :cl)
(:import-from :clnu
:e*
:transpose)
(:import-from :clnu.mx
:mx)
@tanakahx
tanakahx / led_timer.c
Created August 23, 2015 07:49
LED blinking with timer interrupt
#include "stm32f4xx.h"
#include "lib.h"
#define PLL_M 8
#define PLL_N 336
#define PLL_P 2
#define PLL_Q 7
void EnablePll()
{
@tanakahx
tanakahx / json-parser.lisp
Last active August 30, 2021 12:20
JSON parser implemented with cl-lex and CL-Yacc
#|
JSON parser implemented with cl-lex and CL-Yacc
USAGE:
JSON-PARSER> (parse-with-lexer (json-lexer
"{\"foo\":\"bar\",\"baz\":\"bang\",\"bing\":100,\"bingo\":1.1,\"bazo\": [1,2,\"foo\"]}")
json-parser)
(:OBJ ("foo" . "bar") ("baz" . "bang") ("bing" . 100) ("bingo" . 1.1) ("bazo" 1 2 "foo"))
JSON-PARSER> (with-open-file (*standard-input* "test.json")
@tanakahx
tanakahx / unit-neuron.lisp
Last active August 29, 2015 14:26
単一ニューロンを使った関数近似
;; 勾配法の更新係数
(defparameter *epsilon* 0.5)
(defun grad (f dfs ws xs)
"勾配法により更新後の重みベクトルを計算する。
f - 誤差関数
dfs - n番目の重みの更新関数
ws - 重みベクトル
xs - 入力ベクトル
"
@tanakahx
tanakahx / prob-unit.lisp
Created July 30, 2015 17:25
ニューロンの確率的2値モデルのシミュレーション
;; 試行回数
(defconstant +N+ 1000)
;; 入力値
(defparameter x (list 1 0 1))
;; 結線重み
(defparameter w (list 3 2 -1))
;; 閾値
(defparameter th 1)
@tanakahx
tanakahx / 8q.lisp
Created July 26, 2015 16:54
8 Queens Problem
;; ゲーム盤のサイズ
(defparameter N 8)
;; 各行にはどの列に駒を置いたか?
(defparameter *pos* (make-array N :initial-element nil))
;; 列方向の利き筋判定
(defparameter *col* (make-array N :initial-element nil))
;; 右斜め上方向の利き筋判定
(defparameter *up* (make-array (1- (* 2 N)) :initial-element nil))
;; 左斜め下方向の利き筋判定
@tanakahx
tanakahx / how-to-build-qemu-system-arm.markdown
Last active August 29, 2015 14:24
How to build qemu-system-arm in Linux

QEMU のバージョン

QEMU 2.3.0

ビルド手順

$ sudo apt-get install pkg-config libglib2.0-dev autoconf libtool
$ ./configure --target-list=arm-softmmu,arm-linux-user
$ make
@tanakahx
tanakahx / git_e83c5163.patch
Created August 29, 2014 16:18
Patch for initial git (e83c5163) to make it to be built successfully with gcc 4.2.1 (x86_64-apple-darwin13.2.0)
diff --git Makefile Makefile
index a6bba79..2dad8ff 100644
--- Makefile
+++ Makefile
@@ -8,7 +8,7 @@ all: $(PROG)
install: $(PROG)
install $(PROG) $(HOME)/bin/
-LIBS= -lssl
+LIBS= -lcrypto -lz
@tanakahx
tanakahx / update-md.lisp
Created August 29, 2014 16:17
Update date and time in a octopress's markdown file.
;;; Update date and time in a octopress's markdown file.
;;; This script also updates date in the file name.
(load "~/quicklisp/setup.lisp")
(ql:quickload :cl-ppcre)
;; Temporary file created in the current directory
(defparameter *temp-filename* "temp.txt")
(defun time-string (&optional detail)