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
/**
* RGBA => HSVA & HSVA => RGBA Converter
* USAGE:
* var canvas = document.getElementById('canvas');
* var ctx = canvas.getContext('2d');
* ctx.fillStyle = (new HSVA(250, 0.5, 1.0, 1.0)).toRGBA().toString();
* ctx.fillRect(0, 0, canvas.width, canvas.height);
* Author: VoQn
* Last Update: 2010/05/05
*/
<?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: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
@VoQn
VoQn / testLeap.hs
Created September 26, 2010 07:29
閏年判定する関数をHUnit使用するテストする開発コア
import Test.HUnit
-- Target Function for Test
leap :: Integral a => a -> Bool
leap year = if d 100 then d 400
else d 4
where divisible = (== 0) . (mod year)
d = divisible
-- Test Method