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 / prototyping.js
Created July 3, 2012 16:12
はいそうですね
var arr = {
0: 10,
1: 9,
2: 8,
3: 7,
length: 4
};
arr.__proto__ = Array.prototype;
@VoQn
VoQn / try_catch.js
Created July 3, 2012 11:49
ジョークです
;(function(hello){
while(!hello) {
try {
hello.world;
} catch (god) {
console.log(hello = god.message = 'Hello, world!');
}
}
})();
@VoQn
VoQn / gist:2960607
Created June 20, 2012 15:52
test Object.create
var clone = function( object ) {
var copied = Object.create( Object.getPrototypeOf( object ) ),
properties = Object.getOwnPropertyNames( object ),
index = 0,
name;
for ( ; name = properties[ index ]; index++ ){
Object.defineProperty( copied,
name,
Object.getOwnPropertyDescriptor( object, name ) );
}
@VoQn
VoQn / singleton.js
Created May 23, 2012 12:25
Singleton
var Singleton = (function(){
var Singleton = function(){}
, privates
, method
, name
, self = new Singleton();
privates = { // ここはプラベートスコープにできる
isSingleton: true
, name: 'singleton'
@VoQn
VoQn / ExactNum.hs
Created March 29, 2012 15:35
すごい乱暴な方法で小数を割かし正確な有理数にする
--
-- Problem
-- > toRational 1.1 -- 2476979795053773 % 2251799813685248 I want `11 % 10`
-- > fromRational $ toRational 1.1 -- 1.1
-- > (toRational 1.1) == (11 % 10) -- False
--
import Numeric ( floatToDigit, fromRat )
import Data.Ratio ( (%), denominator )
-- | exact ratio number from Real `a`
Sat Mar 10 14:38 2012 Time and Allocation Profiling Report (Final)
basicFib +RTS -p -RTS
total time = 1.82 secs (91 ticks @ 20 ms)
total alloc = 7,947,854,776 bytes (excludes profiling overheads)
COST CENTRE MODULE %time %alloc
CAF Main 100.0 100.0
@VoQn
VoQn / OutPuts
Created March 9, 2012 07:21
My Test Utility Module
RGB data: #ff0033:
it should get RED value : [OK]
it should get GREEN value: [OK]
it should get BLUE value : [OK]
\rgb -> red rgb:
λ (RGB 256 0 51) -> 256 : [OK]
λ (RGB 85 0 68) -> 85 : [OK]
Properties Test Cases Total
Passed 0 5 5
@VoQn
VoQn / gist:1962459
Created March 2, 2012 23:44
My .ctags file
--langdef=js
--langmap=js:.js
--regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\{/\1/o,object/
--regex-js=/([A-Za-z0-9._$()]+)[ \t]*[:=][ \t]*function[ \t]*\(/\1/f,function/
--regex-js=/function[ \t]+([A-Za-z0-9._$]+)[ \t]*([^)])/\1/f,function/
--regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\[/\1/a,array/
--regex-js=/([^= ]+)[ \t]*=[ \t]*[^"]'[^']*/\1/s,string/
--regex-js=/([^= ]+)[ \t]*=[ \t]*[^']"[^"]*/\1/s,string/
--regex-js=/([^= ]+)[ \t]*=[ \t]*[\-]*[0-9]+/\1/n,number/
--regex-js=/([^= ]+)[ \t]*=[ \t]*(true|false)/\1/b,boolean/
--langdef=js
--langmap=js:.js
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*\{/\5/,object/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*function[ \t]*\(/\5/,function/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*\[/\5/,array/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*[^"]'[^']*/\5/,string/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*(true|false)/\5/,boolean/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*[0-9]+/\5/,number/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*.+([,;=]|$)/\5/,variable/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*[ \t]*([,;]|$)/\5/,variable/
@VoQn
VoQn / quickcheck.js
Created February 18, 2012 14:20
prototyping quickcheck for js
var TestEnvironment = (function(){
return {
seed: 1,
count: 100,
current: {
args: [],
isPassed: false,
isSkipped: false,
set: function( args, prop ){