Skip to content

Instantly share code, notes, and snippets.

View VoQn's full-sized avatar
:shipit:
I may be slow to respond.

Kazuhiro Mizushima VoQn

:shipit:
I may be slow to respond.
View GitHub Profile
@VoQn
VoQn / ColorSpaceModel.js
Created May 13, 2010 13:36
Color model definission and Convert function each color models for HTML Canvas Element
// -*- mode: js2; coding: utf-8; -*-
/**
* colorspace.js
* Color Space Utility Functions for HTML Canvas Element
*
* Author: VoQn
*/
/** Utility Functions */
<?xml version="1.0" encosing="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml/DTD/xhtml1-transitinal.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8;" />
<meta http-equiv="Content-Language" content="en" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<title>Hoge</title>
<?xml version="1.0" encosing="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml/DTD/xhtml1-transitinal.dtd">
<html xmlnx="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8;" />
<meta http-equiv="Content-Language" content="en" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<title>Hoge</title>
;; -*- mode:scheme; coding:utf-8 -*-
;; 2.3.2 Derivation
(define (deriv exp var)
(cond ((number? exp) 0)
((variable? exp)
(if (same-variable? exp var) 1 0))
((sum? exp)
(make-sum (deriv (addend exp) var)
(deriv (augend exp) var)))
((product? exp)
@VoQn
VoQn / gist:563601
Created September 3, 2010 08:18 — forked from fuba/gist:563583
## お好み焼き
+ 小麦粉をだし汁で溶く
+ 刻んだキャベツを入れる
+ 卵を入れる
+ 混ぜる
+ フライパンで焼く
+ ソースかける
+ かつおぶしをふりかける
+ 青海苔をちらす
+ 好みで紅生姜をのせる
@VoQn
VoQn / gist:573092
Created September 10, 2010 04:24
フィボナッチ計算アルゴリズム比較のアレ
#!/opt/local/bin/gosh
;;;
;;; Source Code
;;;
;; Sequential T transform O(log(n))
(define (fib-t n)
(let iter [(a 1) (b 0) (p 0) (q 1) (count n)]
@VoQn
VoQn / gist:573114
Created September 10, 2010 04:48
FizzBuzz(3の倍数ならFizz, 5の倍数ならBuzz, 15の倍数ならFizzBuzzに文字を置換する問題のアレ)
;; Shortest? FizzBuzz
(use srfi-1)
(let1 ? (.$ zero? (pa$ mod))
(for-each
(.$ print (^i (cond [(? i 15) 'FizzBuzz]
[(? i 5) 'Buzz]
[(? i 3) 'Fizz]
[else i])))
(cdr (iota 101))))
@VoQn
VoQn / gist:573155
Created September 10, 2010 05:34 — forked from aerith/gist:573142
for i in range(1,101):print(i%3<1)*'Fizz'+(i%5<1)*'Buzz'or i
@VoQn
VoQn / test_gauche_gl.scm
Created September 23, 2010 11:37
Gauche-glを使ってウインドウを出すだけ
#! /usr/bin/env gosh
(use gl)
(use gl.glut)
;; Util Procedure
(define (assq-ref entry alist)
(cdr (assq entry alist)))
(define (slot-list obj getter-list)
@VoQn
VoQn / leapYear.hs
Created September 25, 2010 14:40
閏年判定とかいうの
leap :: Integral a => a -> Bool
leap y = let m = (== 0) . (mod y) in if m 100 then m 400 else m 4
{-
leap 3 -- False
leap 4 -- True
leap 5 -- False
leap 96 -- True
leap 100 -- False
leap 104 -- True