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 / rebuild-test-run.sh
Created December 13, 2011 03:44
cabal auto build & test run & report
#! /bin/sh
cabal clean
cabal configure --enable-test
cabal build
cabal test
./test-report
@VoQn
VoQn / Sethp.hs
Created December 13, 2011 03:32
Sample cabal configuration for HPC Test Coverage
import Distribution.Simple
main = defaultMain
@VoQn
VoQn / gist:1302942
Created October 21, 2011 02:03
one of why hate javascript
var buttons = document.querySelectorAll('button');
// fool
for (var i = 0, l = buttons.length; i < l; i++){
buttons[i].onclick = function(){
alert(i); // always alert buttons length. not inclemental.
};
}
// should
@VoQn
VoQn / gist:1302910
Created October 21, 2011 01:43
mistake I did
// already loaded jQuery.js
(function(){
function searchHoge(name, list){
var reg = new RegExp('^'+name+'$','m');
return list.filter(function(i, v){
return reg.test($(v).text()); // v -> TopLevelHTMLObject
});
}
@VoQn
VoQn / ff.dart
Created October 19, 2011 04:50
Functional programing for Dart
// Functional list programinng Factory
class FF {
static fold(func(x, r), [init, Iterable it]) =>
init === null ?
(init, [Iterable it]) => FF.fold(func, init, it) :
it === null ?
(Iterable it) => FF.fold(func, init, it) :
(){
var result = init;
@VoQn
VoQn / fibbuzz.hs
Created October 13, 2011 08:57
FibBuzz -- map (FizzBuzz . Fibonacci) [1..100]
main=mapM_(putStrLn.f.(b!!))[0..99];b=1:scanl(+)1b;(%)=mod;f n|n%15<1=f 3++f 5|n%5<1="Buzz"|n%3<1="Fizz"|0<1=show n
@VoQn
VoQn / fizzbuzz.dart
Created October 10, 2011 22:14
Google が Dart 公開したから早速 FizzBuzz
main(){for(var i=0;++i<101;)print((i%3?'':'Fizz')+(i%5?'':'Buzz')||i);}
@VoQn
VoQn / top2hills.c
Created October 9, 2011 22:25
AOJ V0 0001
#include <stdio.h>
int cmp(const void *a, const void *b){
return -(*(int*)a - *(int*)b);
}
int main(void) {
int i, height;
int l = 10;
int hills[l];
@VoQn
VoQn / font-size-conv.scm
Created September 5, 2011 08:52
Font Size Converter (Q, Pt, mm, px) フォントサイズを引数に渡して,それぞれの単位で変換した値を標準出力
#!/usr/bin/env gosh
#|
Font Size Converter
This programm convert font size for each unit, and display standard output.
Usage: gosh font-size-conv.scm [-dpi][-Qpmx][--] [fonr-size]
Example: $ gosh font-size-conv.scm -dpi 300 -p 144
Base Font Size (pt) : 144 pt
@VoQn
VoQn / metallic-split.scm
Created July 12, 2011 17:50
黄金比や白銀比,青銅比などの貴金属比でパラメータを分割して一覧を出力するGaucheスクリプト
#!/usr/bin/env gosh
#|
Metallic Ratio Split
<USAGE>
1. Research Splited Values by metallic ratio
$ gosh metallic-split.scm 960
2. Generate CSS Format
$ gosh metallic-split.scm -c -b 1 -p 10 960 > style.css