素人がプログラミングを勉強していたブログ

プログラミング、セキュリティ、英語、Webなどのブログ since 2008

連絡先: twitter: @javascripter にどうぞ。

2009-10-01から1ヶ月間の記事一覧

メモ

sprintfっぽい物を先頭に書いておくと、けっこう便利。 function sprintf() { // limited implementation of sprintf. var format = arguments[0], argv = arguments, i = 1; return format.replace(/%([s%])/g, function (all, type) { return type == "%" …

Selectors APIのmatchesSelectorと、動的なページでのイベント処理

Selectors APIのDraftに、matchesSelectorというAPIが定義されていて、現在、WebKitとMinefieldのNightlyに搭載されている。 ただし、ドラフトなのでベンダープレフィックスがついていて、Element#webkitMatchesSelectorやElement#mozMatchesSelectorを使わ…

Firefox trunkにtransitionとかが入った

CSS Transitionsと呼ばれる機能で、CSSでアニメーションとかを実現する物。Safariには前からあった。 <style> body { -moz-transition: 5s all linear 0s; -webkit-transition: 5s all linear 0s; transition: 5s all linear 0s; text-align: center; text-shadow: </style>…

リストがソート済みかどうか

isSorted :: (Ord a) => [a] -> Bool isSorted [] = True isSorted [_] = True isSorted l = and $ zipWith (<) l (tail l) こんな感じに書ける。最近、zipやzipWith、mapといった基本的な高階関数が最初から(もしくは、builtinのモジュールとして)存在し…