「BASIC」を含む日記 RSS

はてなキーワード: BASICとは

2007-09-14

http://anond.hatelabo.jp/20070914115225

駄文長文注意<

意識されている「きっかけ」が変なので報告してみる。

現在22歳、修士一年情報系。

プログラミング歴約6年。

小学校高学年くらいから、父の職場で使われてたPC98で、Notepadに文字を打つのが単に好きだった。

一文目は、「宇治お茶は美味しい。」

なんでだったかよく覚えてないけど。

で、別にプログラムなんか興味なくて、中学校ときに「技術・家庭」の授業でBASICをいじるのが一回だけあって、女の子数人に「すごーい!教えて!」って寄ってこられたのは気分が良かったが、特に面白いとは感じなかった。

高校は世界系とかファンタジーラノベばっか読んでた。オーフェンとかブギーポップとか、好きだったのはDクラッカーズ

プログラムと何の関係があるの?」

と言われそうだけど、こういうのが原点だったと自覚している。

小説って世界を数百ページの紙の中に構築するわけだ。

僕は想像力が豊かっていうか、ちょっと”イタイ”人っていうか、

読んだあとはラノベの世界がかなり身近に感じられてもうワクワクがとまらない人だったから、

自分も作り手になりたいと思った。

ほどなく、プログラムも、

「世界を作る」ツールだって認識して興味がわいたのね。

その時分は作れるものがかなり限定されていたけど、

大学もVirtual Realityに興味がわいて工学部に入ったわけで、

VR空間をプログラミングできたら!とか思ったんだ。

まあ多くの方はご存知のとおり、そんな段階じゃないんだよねあの分野は。

大学入ってすぐは社会学に興味もったりしてたわけで、興味はプログラムから離れていた。

一年Javaプログラミング授業とかやったけど、別にそんなに楽しくは無かった。

書き忘れたけど、高校とき図書館の本でHot Soup Processorに触れている。

英単語覚えるのが苦手だったので、学習ソフト作っただけ。

”日常を変える”プログラミングの楽しさをはじめて知ったのはこれだった。

そんなこんなで苦手ではなかったけど、大学3年のときプログラミングとかも、

ちんたら遅いし、できることは大して増えないし、面倒だし嫌いだった。

ってか今でもそうだけど、光る箱に一人でカタカタやるってのが性に合わない。

        *'``・* 。
        |     `*。
       ,。∩      *    こんな感じで
      + (´・ω・`) *。+゜
      `*。 ヽ、  つ *゜*
       `・+。*・' ゜⊃ +゜
       ☆   ∪~ 。*゜
        `・+。*・ ゜

プログラム組みたいわけだ。僕は。

で、卒論になって、指導教官希望順の関係でばりばり情報系のとこに配属されて、

Perlでやることになって、まためんどくさいなぁと思いつつやったわけ。

モジュールを使うことを覚えた分、ちょっと理想に近づいたけどね。

昨日まで彼女がいたりした僕は、大学入って4年間でちょっとはリア充さを身につけたので、

”(虚構)世界を作る”から”日常を変える”ほうに興味は移り、今に至る。

そうそう、高校は家から通学だけで2時間半かかる男子校だし、友達も少ないし、「非リア充」だったから、その状況では、”日常を変える”ことで幸せになるより”世界を作る”ことで幸せになるほうが簡単に思えたのね。

今は逆。

だらだら喋ったけど、結局プログラムは僕にとって手段でしかありません。

最近ホットエントリにあがってるマシン語わかんなきゃいけないとか「はぁ?」って感じ。

        *'``・* 。
        |     `*。
       ,。∩      *    こんなプログラミング
      + (´・ω・`) *。+゜
      `*。 ヽ、  つ *゜*
       `・+。*・' ゜⊃ +゜
       ☆   ∪~ 。*゜
        `・+。*・ ゜

が理想なんだから。

自分の手で作りたい何か、変えたい何かがあるって方が、

手段たるプログラミングに興味持つことより重要な気がします。

http://anond.hatelabo.jp/20070914115225

いま21だけど、中学のころ部活プログラミングを始めました。

最初はウィンドウズ上で動く、グラフィックが使えるBASICで簡単なゲームを組むところから入った。

やっぱりゲーム組むのが一番楽しいし、BASICなら難しい言語仕様も覚えなくていい。

大学の授業だとプログラミングはCとかJavaとかから入るけど、サブルーチンとかクラスとかのありがたみは後から知ればいいものだと思う。

取っつき安い言語と面白いテーマがあれば、飛びつく子供はいっぱいいるよ。

今の子供達にどうやってプログラミングの楽しさを教えたらいいのか?

うちはとても貧乏だったというのに、なぜか俺が小学三年生のときに、親父がパソコンを買ってきた。

親父は電気工事屋をやっていたから電気製品が好きだったんだろう。

当時小学六年生だった兄貴機械いじりが好きだった。 電子ブロックなんてのが家にあった。

とはいえ、二十万円もするパソコンコンビニウーロン茶を買うかのように買ってきた親父が、あとでオカンになんて言われたのか、いまとなっては知るよしもない (いや、親父もオカンもまだ生きてるので、聞こうと思えば聞けるが) 。

ともかく、俺が小学三年生の時には家に MZ-2000 というパソコンがあった。

三年生のときはそもそもパソコンとはなにかも知らなかったし、親父も兄貴も壊れものを扱うかのように大事に触るので (実際壊れものだ) 、俺には触らせてもらえなかった。 親父や兄貴の背中越しに見ているだけだった。

当時はパソコン用のソフトなんてのがそこらに売っていたわけではないし、 DSソフトのように気軽に買えるようなものでもなかったので、付属BASICポチポチ入力しては RUN する、これしかなかった。

それでもなにかすごいことがこの銀色の箱の中で起きているということは、子供ながらに理解した。

そのうち学年が進んで小学五年生になるころには、俺も兄貴といっしょにプログラム入力したりしていた、と思う。 六年生ぐらいだったかもしれない。

当時はベーマガという雑誌があった。 毎号買ってきては、短いプログラムだけ選んで入力した。

そういえば、 MZ-2000付属していたオレンジの本も、子供知的好奇心をおおいにあおった。 中西さん挿絵が絶妙だった。

ベーマガには、「アルゴリズム」という単語がわりあい頻繁に登場していたと思う。 体操じゃないよ。

高度な関数も使えない、グラフィックもろくに扱えない当時のパソコンで、おもしろいゲームを作るにはアイデア勝負、とりもなおせばアルゴリズム勝負みたいなところがあった。

サイン関数を使って放物線の動きを表現したり、 X 軸の動きと Y 軸の動きを入れ替えて物体の反射を表現したり。

いまではなんてことはない小手先以下の技だけど、そもそも当時のパソコンではそんなことぐらいしかできなかった。

パソコンサンデーでもアルゴリズムという単語がわりとよく出てきていたと思う。

そんななかで、パソコンというのが魔法の箱ではなく、ちいさな処理を組み合わせてなにかをするものだということを理解した。

そのころすでに親父はパソコンさわりもせず、兄貴と俺のオモチャと化していた。

グラフィックボードと G-RAMカラーディスプレイまで買ってくれたんだから、親父の無駄遣いもここに極まれりというもんだ。

数十しかない BASIC の命令を組み合わせれば、色つきのグラフィックや音まで出せた。 BASICプログラミングは楽しかった。

兄貴夏休みを数日使って I/O に載っていた「フォボス」のダンプリストを打ち込んだりした。 ひとりがリストを読んで、もうひとりがそれをひたすら打ち込んだ。 ダンプリスト呪文雑誌数十ページ分打ち込んだら、ものすごいゲームができた。 楽しかった。

中学に進んで、 Oh! MZ を読んでアセンブラや他の言語にも触れ合えた。 あまり深入りはしなかったけど。

高校商業高校情報理科に進んだ。 校内のホストTSSログインして、 COBOLFORTRAN なんかを習った。 情報処理二種も取った。

で、いまはシステム開発の会社にいる。

さて、現在、俺にも子供がいる。

今年の四月で小学三年生になった。

子供には家の PC はさわらせてない。 たまにマウスで絵を描かせるくらい。

現代っ子らしく、 DSポケモンなんかして遊んでいる。 Wii もある。

さて、この子にプログラミングの楽しさを教えるとしたら、どうしたらいいだろう?

いまの PCBASIC付属してない。 ベーマガもない。

あったとして、今の PC で、当時のような短いリストでなにができる?

エミュレータで古いパソコン環境を再現してプログラムさせるか?

それは、周囲に表現力豊かなゲームがあふれている現代の子供楽しいと思えるものか?

アルゴリズムというものをどうやって説明したらいい?

コンピュータが内部でどうやって動いているか、どうすれば簡潔に説明できるだろう?

そもそも現代の子供は、これだけソフトウェアがあふれているなか、コンピュータプログラム入力して、それを動かすことをおもしろいと思わないのではないか?

子供プログラミングを理解するのに、取っつきやすい本やサイトなんかがあったら、誰か教えてください。

いま、プログラミングを楽しんでいる中学生から高校生くらいの若いひとは、どうやってその世界に入っていったんだろう?

伝えたければ、もう語るのをやめてください。

d:id:shi3z:20070913

言いたいことはわかりますよ。スタックを知っていれば、レジスタを知っていれば、メモリ管理の仕組みを知っていれば… そういう知識があればあるほど、問題に遭遇したときの解決が早くなる。

そういった事の体験学習の道具としてマシン語(というかアセンブリ)を薦めたい気持ちもわかりますよ。

でもね。煽りすぎなんです。あなたの文章は、「これは、こういう仕組みになっています。これの意味は、こういう事です」の後に必ず「こんな事も知らない奴は」「絶対に知っておくべきだ」という脅しをかける。だから攻撃的でイヤミになるんですよ。

あなたは、その文を読んだ人が「チクショウ!」と思って勉強することを期待しているんでしょうが、現実は「こんなイヤミな奴の言うこと聞きたくない」の方じゃないですか? そうして若い人たちがマシン語に背を向けてしまったら悲しくないですか。

思い出してください。マシン語プログラミングの主役だったあの時代、なぜ人々はわざわざマシン語を選んでいたのか。“オールBASIC”のプログラムでは逆立ちしても実現できないことが、マシン語ならできる。家のPC-8001ギャラクシアンが動く。それに感動して、あのスパイ乱数表みたいなリストを打ち込んだんでしょう。どこかのイヤミな野郎にケツを叩かれて始めたわけじゃないでしょう。今はそれがRubyだったりJavascriptだったりするわけです。

マシン語を知らない子供たちも、プログラミングの喜びは知っています。だから、もうやめてください。

かつてのマイコン少年より。

id:motomachi24

匿名相手じゃなくてもキツいことは言えるみたいですね。というか、キツいことを言えるのが嬉しいんですか?

2007-08-15

anond:20070815204308

きたみ氏の書くところによれば、3ヶ月もあればプログラムは書け、SEとして働けるという(『SEのフシギな生態』)。また、センター試験数学BASICレベルだと、上手な人が教えてあげれば、全くの素人でも20分程度で解けるようになる(なので、プログラマならBASIC選択が得)。

でも、自分一人でやって3ヶ月でまともなプログラム作れる人は少ないと思うんだ。どうしてか?

彼らは別にプログラミング技術ダメダメなわけじゃなくて、単にアルゴリズムと設計を知らないだけだと思うんだ。「良い仕様は一人の天才よりも三人の凡人を求める。悪い仕様は百人の凡人よりも一人の天才を求める」(「プログラマの格言」第18)ってやつで、ダメな設計だから作れないだけなんだ。

良い仕様を渡せば良い働きをするプログラマは多いよ。プログラマ集団の働きが優秀でも、そのうちの一人を取り出して、彼一人に良いものを作ってもらおうとしても、成功するとは限らないよ。

2007-08-12

マークアップエンジニアって結局何やる人なの?

何か名前の響きからしてこんな感じの人を想像してたんだけど

でもいままでamachang発言((X)HTML+CSS しか出来ない人は真剣に第二の何かを探したほうがいいとか)の反応ざっと見てきたけどid:amachang(とその周辺)が「マークアップエンジニア = (X)HTML+CSS しか出来ない人」として話を進めてるのにも関わらずそれについて反論があんまりないんだよな。「趣味じゃなくて仕事として(X)HTML(とCSS)を作成するためにはこれこれこういう知識が必要なんだよ」とか「マークアップエンジニアには(X)HTMLCSSしかすることがないとでも思ってんのか馬鹿」とか言ったりするのかと思ったらほとんどそんなことなくて、むしろ同意ですとかそんなこと言われなくてもわかってるよとかJavaScriptだって同じじゃんとか見た感じそんなのばっかり。どうも俺の想像した職業とは違うらしい。

マークアップエンジニアって本当に(X)HTMLCSSの知識だけで(X)HTMLCSS書いてる人なの?反応見ててそもそも(X)HTMLCSSに理解があるのかってこと自体にまで疑問を感じるんだけど。

2007-07-19

/* Ten */
if (typeof(Ten) == 'undefined') {
    Ten = {};
}
Ten.NAME = 'Ten';
Ten.VERSION = 0.06;

/* Ten.Class */
Ten.Class = function(klass, prototype) {
    if (klass && klass.initialize) {
	var c = klass.initialize;
    } else if(klass && klass.base) {
        var c = function() { return klass.base[0].apply(this, arguments) };
    } else {
	var c = function() {};
    }
    c.prototype = prototype || {};
    c.prototype.constructor = c;
    Ten.Class.inherit(c, klass);
    if (klass && klass.base) {
        for (var i = 0;  i < klass.base.length; i++) {
	    var parent = klass.base[i];
            if (i == 0) {
                c.SUPER = parent;
                c.prototype.SUPER = parent.prototype;
            }
            Ten.Class.inherit(c, parent);
            Ten.Class.inherit(c.prototype, parent.prototype);
        }
    }
    return c;
}
Ten.Class.inherit = function(child,parent) {
    for (var prop in parent) {
        if (typeof(child[prop]) != 'undefined' || prop == 'initialize') continue;
        child[prop] = parent[prop];
    }
}

/*
// Basic Ten Classes
**/

/* Ten.JSONP */
Ten.JSONP = new Ten.Class({
    initialize: function(uri,obj,method) {
        if (Ten.JSONP.Callbacks.length) {
            setTimeout(function() {new Ten.JSONP(uri,obj,method)}, 500);
            return;
        }
        var del = uri.match(/\?/) ? '&' : '?';
        uri += del + 'callback=Ten.JSONP.callback';
        if (!uri.match(/timestamp=/)) {
            uri += '&' + encodeURI(new Date());
        }
        if (obj && method) Ten.JSONP.addCallback(obj,method);
        this.script = document.createElement('script');
        this.script.src = uri;
        this.script.type = 'text/javascript';
        document.getElementsByTagName('head')[0].appendChild(this.script);
    },
    addCallback: function(obj,method) {
        Ten.JSONP.Callbacks.push({object: obj, method: method});
    },
    callback: function(args) {
        // alert('callback called');
        var cbs = Ten.JSONP.Callbacks;
        for (var i = 0; i < cbs.length; i++) {
            var cb = cbs[i];
            cb.object[cb.method].call(cb.object, args);
        }
        Ten.JSONP.Callbacks = [];
    },
    MaxBytes: 8000,
    Callbacks: []
});

/* Ten.XHR */
Ten.XHR = new Ten.Class({
    initialize: function(uri,opts,obj,method) {
        if (!uri) return;
        this.request = Ten.XHR.getXMLHttpRequest();
        this.callback = {object: obj, method: method};
        var xhr = this;
        var prc = this.processReqChange;
        this.request.onreadystatechange = function() {
            prc.apply(xhr, arguments);
        }
        var method = opts.method || 'GET';
        this.request.open(method, uri, true);
        if (method == 'POST') {
            this.request.setRequestHeader('Content-Type',
                                          'application/x-www-form-urlencoded');
        }
        var data = opts.data ? Ten.XHR.makePostData(opts.data) : null;
        this.request.send(data);
    },
    getXMLHttpRequest: function() {
        var xhr;
        var tryThese = [
            function () { return new XMLHttpRequest(); },
            function () { return new ActiveXObject('Msxml2.XMLHTTP'); },
            function () { return new ActiveXObject('Microsoft.XMLHTTP'); },
            function () { return new ActiveXObject('Msxml2.XMLHTTP.4.0'); },
        ];
        for (var i = 0; i < tryThese.length; i++) {
            var func = tryThese[i];
            try {
                xhr = func;
                return func();
            } catch (e) {
                //alert(e);
            }
        }
        return xhr;
    },
    makePostData: function(data) {
        var pairs = [];
        var regexp = /%20/g;
        for (var k in data) {
            var v = data[k].toString();
            var pair = encodeURIComponent(k).replace(regexp,'+') + '=' +
                encodeURIComponent(v).replace(regexp,'+');
            pairs.push(pair);
        }
        return pairs.join('&');
    }
},{
    processReqChange: function() {
        var req = this.request;
        if (req.readyState == 4) {
            if (req.status == 200) {
                var cb = this.callback;
                cb.object[cb.method].call(cb.object, req);
            } else {
                alert("There was a problem retrieving the XML data:\n" +
                      req.statusText);
            }
        }
    }
});

/* Ten.Observer */
Ten.Observer = new Ten.Class({
    initialize: function(element,event,obj,method) {
        var func = obj;
        if (typeof(method) == 'string') {
            func = obj[method];
        }
        this.element = element;
        this.event = event;
        this.listener = function(event) {
            return func.call(obj, new Ten.Event(event || window.event));
        }
        if (this.element.addEventListener) {
            if (this.event.match(/^on(.+)$/)) {
                this.event = RegExp.$1;
            }
            this.element.addEventListener(this.event, this.listener, false);
        } else if (this.element.attachEvent) {
            this.element.attachEvent(this.event, this.listener);
        }
    }
},{
    stop: function() {
        if (this.element.removeEventListener) {
            this.element.removeEventListener(this.event,this.listener,false);
        } else if (this.element.detachEvent) {
            this.element.detachEvent(this.event,this.listener);
        }
    }
});

/* Ten.Event */
Ten.Event = new Ten.Class({
    initialize: function(event) {
        this.event = event;
    },
    keyMap: {
        8:"backspace", 9:"tab", 13:"enter", 19:"pause", 27:"escape", 32:"space",
        33:"pageup", 34:"pagedown", 35:"end", 36:"home", 37:"left", 38:"up",
        39:"right", 40:"down", 44:"printscreen", 45:"insert", 46:"delete",
        112:"f1", 113:"f2", 114:"f3", 115:"f4", 116:"f5", 117:"f6", 118:"f7",
        119:"f8", 120:"f9", 121:"f10", 122:"f11", 123:"f12",
        144:"numlock", 145:"scrolllock"
    }
},{
    mousePosition: function() {
        if (!this.event.clientX) return;
        return Ten.Geometry.getMousePosition(this.event);
    },
    isKey: function(name) {
        var ecode = this.event.keyCode;
        if (!ecode) return;
        var ename = Ten.Event.keyMap[ecode];
        if (!ename) return;
        return (ename == name);
    },
    targetIsFormElements: function() {
        var target = this.event.target;
        if (!target) return;
        var T = (target.tagName || '').toUpperCase();
        return (T == 'INPUT' || T == 'SELECT' || T == 'OPTION' ||
                T == 'BUTTON' || T == 'TEXTAREA');
    },
    stop: function() {
        var e = this.event;
        if (e.stopPropagation) {
            e.stopPropagation();
            e.preventDefault();
        } else {
            e.cancelBubble = true;
            e.returnValue = false;
        }
    }
});

/* Ten.DOM */
Ten.DOM = new Ten.Class({
    getElementsByTagAndClassName: function(tagName, className, parent) {
        if (typeof(parent) == 'undefined') {
            parent = document;
        }
        var children = parent.getElementsByTagName(tagName);
        if (className) { 
            var elements = [];
            for (var i = 0; i < children.length; i++) {
                var child = children[i];
                var cls = child.className;
                if (!cls) {
                    continue;
                }
                var classNames = cls.split(' ');
                for (var j = 0; j < classNames.length; j++) {
                    if (classNames[j] == className) {
                        elements.push(child);
                        break;
                    }
                }
            }
            return elements;
        } else {
            return children;
        }
    },
    removeEmptyTextNodes: function(element) {
        var nodes = element.childNodes;
        for (var i = 0; i < nodes.length; i++) {
            var node = nodes[i];
            if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) {
                node.parentNode.removeChild(node);
            }
        }
    },
    nextElement: function(elem) {
        do {
            elem = elem.nextSibling;
        } while (elem && elem.nodeType != 1);
        return elem;
    },
    prevElement: function(elem) {
        do {
            elem = elem.previousSibling;
        } while (elem && elem.nodeType != 1);
        return elem;
    },
    scrapeText: function(node) {
        var rval = [];
        (function (node) {
            var cn = node.childNodes;
            if (cn) {
                for (var i = 0; i < cn.length; i++) {
                    arguments.callee.call(this, cn[i]);
                }
            }
            var nodeValue = node.nodeValue;
            if (typeof(nodeValue) == 'string') {
                rval.push(nodeValue);
            }
        })(node);
        return rval.join('');
    },
    onLoadFunctions: [],
    loaded: false,
    timer: null,
    addEventListener: function(event,func) {
        if (event != 'load') return;
        Ten.DOM.onLoadFunctions.push(func);
        Ten.DOM.checkLoaded();
    },
    checkLoaded: function() {
        var c = Ten.DOM;
        if (c.loaded) return true;
        if (document && document.getElementsByTagName &&
            document.getElementById && document.body) {
            if (c.timer) {
                clearInterval(c.timer);
                c.timer = null;
            }
            for (var i = 0; i < c.onLoadFunctions.length; i++) {
                    c.onLoadFunctions[i]();
            }
            c.onLoadFunctions = [];
            c.loaded = true;
        } else {
            c.timer = setInterval(c.checkLoaded, 13);
        }
    }
});

/* Ten.Style */
Ten.Style = new Ten.Class({
    applyStyle: function(elem, style) {
        for (prop in style) {
            elem.style[prop] = style[prop];
        }
    }
});

/* Ten.Geometry */
Ten.Geometry = new Ten.Class({
    initialize: function() {
        if (Ten.Geometry._initialized) return;
        var func = Ten.Geometry._functions;
        var de = document.documentElement;
        if (window.innerWidth) {
            func.getWindowWidth = function() { return window.innerWidth; }
            func.getWindowHeight = function() { return window.innerHeight; }
            func.getXScroll = function() { return window.pageXOffset; }
            func.getYScroll = function() { return window.pageYOffset; }
        } else if (de && de.clientWidth) {
            func.getWindowWidth = function() { return de.clientWidth; }
            func.getWindowHeight = function() { return de.clientHeight; }
            func.getXScroll = function() { return de.scrollLeft; }
            func.getYScroll = function() { return de.scrollTop; }
        } else if (document.body.clientWidth) {
            func.getWindowWidth = function() { return document.body.clientWidth; }
            func.getWindowHeight = function() { return document.body.clientHeight; }
            func.getXScroll = function() { return document.body.scrollLeft; }
            func.getYScroll = function() { return document.body.scrollTop; }
        }
        Ten.Geometry._initialized = true;
    },
    _initialized: false,
    _functions: {},
    getScroll: function() {
        if (!Ten.Geometry._initialized) new Ten.Geometry;
        return {
            x: Ten.Geometry._functions.getXScroll(),
            y: Ten.Geometry._functions.getYScroll()
        };
    },
    getMousePosition: function(pos) {
        // pos should have clientX, clientY same as mouse event
        if ((navigator.userAgent.indexOf('Safari') > -1) &&
            (navigator.userAgent.indexOf('Version/') < 0)) {
            return {
                x: pos.clientX,
                y: pos.clientY
            };
        } else {
            var scroll = Ten.Geometry.getScroll();
            return {
                x: pos.clientX + scroll.x,
                y: pos.clientY + scroll.y
            };
        }
    },
    getElementPosition: function(e) {
        return {
            x: e.offsetLeft,
            y: e.offsetTop
        };
    },
    getWindowSize: function() {
        if (!Ten.Geometry._initialized) new Ten.Geometry;
        return {
            w: Ten.Geometry._functions.getWindowWidth(),
            h: Ten.Geometry._functions.getWindowHeight()
        };
    }
});

/* Ten.Position */
Ten.Position = new Ten.Class({
    initialize: function(x,y) {
        this.x = x;
        this.y = y;
    },
    subtract: function(a,b) {
        return new Ten.Position(a.x - b.x, a.y - b.y);
    }
});

/*
// require Ten.js
**/

/* Ten.SubWindow */
Ten.SubWindow = new Ten.Class({
    initialize: function() {
        var c = this.constructor;
        if (c.singleton && c._cache) {
            return c._cache;
        }
        var div = document.createElement('div');
        Ten.Style.applyStyle(div, Ten.SubWindow._baseStyle);
        Ten.Style.applyStyle(div, c.style);
        this.window = div;
        this.addContainerAndCloseButton();
        document.body.appendChild(div);
        if (c.draggable) {
            this._draggable = new Ten.Draggable(div, this.handle);
        }
        if (c.singleton) c._cache = this;
        return this;
    },
    _baseStyle: {
        color: '#000',
        position: 'absolute',
        display: 'none',
        zIndex: 2,
        left: 0,
        top: 0,
        backgroundColor: '#fff',
        border: '1px solid #bbb'
    },
    style: {
        padding: '2px',
        textAlign: 'center',
        borderRadius: '6px',
        MozBorderRadius: '6px',
        width: '100px',
        height: '100px'
    },
    handleStyle: {
        position: 'absolute',
        top: '0px',
        left: '0px',
        backgroundColor: '#f3f3f3',
        borderBottom: '1px solid #bbb',
        width: '100%',
        height: '30px'
    },
    containerStyle: {
        margin: '32px 0 0 0',
        padding: '0 10px'
    },
    // closeButton: 'close.gif',
    closeButton: 'http://s.hatena.com/images/close.gif',
    closeButtonStyle: {
        position: 'absolute',
        top: '8px',
        right: '10px',
        cursor: 'pointer'
    },
    _baseScreenStyle: {
        position: 'absolute',
        top: '0px',
        left: '0px',
        display: 'none',
        zIndex: 1,
        overflow: 'hidden',
        width: '100%',
        height: '100%'
    },
    screenStyle: {},
    showScreen: true,
    singleton: true,
    draggable: true,
    _cache: null
},{
    screen: null,
    windowObserver: null,
    visible: false,
    addContainerAndCloseButton: function() {
        var win = this.window;
        var c = this.constructor;
        var div = document.createElement('div');
        win.appendChild(div);
        Ten.Style.applyStyle(div, c.containerStyle);
        this.container = div;
        if (c.handleStyle) {
            var handle = document.createElement('div');
            Ten.Style.applyStyle(handle, c.handleStyle);
            win.appendChild(handle);
            this.handle = handle;
        }
        if (c.closeButton) {
	    var btn = document.createElement('img');
            btn.src = c.closeButton;
            btn.alt = 'close';
            Ten.Style.applyStyle(btn, c.closeButtonStyle);
            win.appendChild(btn);
            new Ten.Observer(btn, 'onclick', this, 'hide');
            this.closeButton = btn;
        }
        if (c.showScreen) {
            var screen = document.createElement('div');
            Ten.Style.applyStyle(screen, Ten.SubWindow._baseScreenStyle);
            Ten.Style.applyStyle(screen, c.screenStyle);
            document.body.appendChild(screen);
            this.screen = screen;
            new Ten.Observer(screen, 'onclick', this, 'hide');
        }
    },
    show: function(pos) {
        pos = (pos.x && pos.y) ? pos : {x:0, y:0};
        with (this.window.style) {
            display = 'block';
            left = pos.x + 'px';
            top = pos.y + 'px';
        }
        if (this.screen) {
            with (this.screen.style) {
                display = 'block';
                left = Ten.Geometry.getScroll().x + 'px';
                top = Ten.Geometry.getScroll().y + 'px';
            }
        }
        this.windowObserver = new Ten.Observer(document.body, 'onkeypress', this, 'handleEscape');
        this.visible = true;
    },
    handleEscape: function(e) {
        if (!e.isKey('escape')) return;
        this.hide();
    },
    hide: function() {
        if (this._draggable) this._draggable.endDrag();
        this.window.style.display = 'none';
        if (this.screen) this.screen.style.display = 'none';
        if (this.windowObserver) this.windowObserver.stop();
        this.visible = false;
    }
});

/* Ten.Draggable */
Ten.Draggable = new Ten.Class({
    initialize: function(element,handle) {
        this.element = element;
        this.handle = handle || element;
        this.startObserver = new Ten.Observer(this.handle, 'onmousedown', this, 'startDrag');
        this.handlers = [];
    }
},{
    startDrag: function(e) {
        if (e.targetIsFormElements()) return;
        this.delta = Ten.Position.subtract(
            e.mousePosition(),
            Ten.Geometry.getElementPosition(this.element)
        );
        this.handlers = [
            new Ten.Observer(document, 'onmousemove', this, 'drag'),
            new Ten.Observer(document, 'onmouseup', this, 'endDrag'),
            new Ten.Observer(this.element, 'onlosecapture', this, 'endDrag')
        ];
        e.stop();
    },
    drag: function(e) {
        var pos = Ten.Position.subtract(e.mousePosition(), this.delta);
        Ten.Style.applyStyle(this.element, {
            left: pos.x + 'px',
            top: pos.y + 'px'
        });
        e.stop();
    },
    endDrag: function(e) {
        for (var i = 0; i < this.handlers.length; i++) {
            this.handlers[i].stop();
        }
        if(e) e.stop();
    }
});

/* Hatena */
if (typeof(Hatena) == 'undefined') {
    Hatena = {};
}

/* Hatena.User */
Hatena.User = new Ten.Class({
    initialize: function(name) {
        this.name = name;
    },
    getProfileIcon: function(name) {
        if (!name) name = 'user';
        var pre = name.match(/^[\w-]{2}/)[0];
        var img = document.createElement('img');
        img.src = 'http://www.hatena.ne.jp/users/' + pre + '/' + name + '/profile_s.gif';
        img.alt = name;
        img.setAttribute('class', 'profile-icon');
        img.setAttribute('width','16px');
        img.setAttribute('height','16px');
        with (img.style) {
            margin = '0 3px';
            border = 'none';
            verticalAlign = 'middle';
        }
        return img;
    }
}, {
    profileIcon: function() {
        return Hatena.User.getProfileIcon(this.name);
    }
});

/* Hatena.Star */
if (typeof(Hatena.Star) == 'undefined') {
    Hatena.Star = {};
}

/*
// Hatena.Star.* classes //
**/
if (window.location && window.location.host.match(/hatena\.com/)) {
    Hatena.Star.BaseURL = 'http://s.hatena.com/';
} else {
    Hatena.Star.BaseURL = 'http://s.hatena.ne.jp/';
}
Hatena.Star.Token = null;

/* Hatena.Star.User */
Hatena.Star.User = new Ten.Class({
    base: [Hatena.User],
    initialize: function(name) {
        if (Hatena.Star.User._cache[name]) {
            return Hatena.Star.User._cache[name];
        } else {
            this.name = name;
            Hatena.Star.User._cache[name] = this;
            return this;
        }
    },
    _cache: {}
},{
    userPage: function() {
        return Hatena.Star.BaseURL + this.name + '/';
    }
});

/* Hatena.Star.Entry */
Hatena.Star.Entry = new Ten.Class({
    initialize: function(e) {
        this.entry = e;
        this.uri = e.uri;
        this.title = e.title;
        this.star_container = e.star_container;
        this.comment_container = e.comment_container;
        this.stars = [];
        this.comments = [];
    },
    maxStarCount: 11
},{
    flushStars: function() {
        this.stars = [];
        this.star_container.innerHTML = '';
    },
    bindStarEntry: function(se) {
        this.starEntry = se;
        for (var i = 0; i < se.stars.length; i++) {
            if (typeof(se.stars[i]) == 'number') {
                this.stars.push(new Hatena.Star.InnerCount(se.stars[i],this));
            } else {
                this.stars.push(new Hatena.Star.Star(se.stars[i]));
            }
        }
        if (se.comments && !this.comments.length) {
            for (var i = 0; i < se.comments.length; i++) {
                this.comments.push(new Hatena.Star.Comment(se.comments[i]));
            }
        }
        this.can_comment = se.can_comment;
    },
    setCanComment: function(v) {
        this.can_comment = v;
    },
    showButtons: function() {
        this.addAddButton();
        this.addCommentButton();
    },
    addAddButton: function() {
        if (this.star_container) {
            this.addButton = new Hatena.Star.AddButton(this);
            this.star_container.appendChild(this.addButton);
        }
    },
    addCommentButton: function() {
        if (this.comment_container) {
            this.commentButton = new Hatena.Star.CommentButton(this);
            this.comment_container.appendChild(this.commentButton.img);
        }
    },
    showStars: function() {
        var klass = this.constructor;
        // if (this.stars.length > klass.maxStarCount) {
        //     var ic = new Hatena.Star.InnerCount(this.stars.slice(1,this.stars.length));
        //     this.star_container.appendChild(this.stars[0]);
        //     this.star_container.appendChild(ic);
        //     this.star_container.appendChild(this.stars[this.stars.length - 1]);
        // } else {
        for (var i = 0; i < this.stars.length; i++) {
            this.star_container.appendChild(this.stars[i]);
        }
    },
    showCommentButton: function() {
        if (this.can_comment) {
            this.commentButton.show();
            if (this.comments.length) this.commentButton.activate();
        } else {
            // this.commentButton.hide();
        }
    },
    addStar: function(star) {
        this.stars.push(star);
        this.star_container.appendChild(star);
    },
    addComment: function(com) {
        if (!this.comments) this.comments = [];
        if (this.comments.length == 0) {
            this.commentButton.activate();
        }
        this.comments.push(com);
    },
    showCommentCount: function() {
        this.comment_container.innerHTML += this.comments.length;
    }
});

/* Hatena.Star.Button */
Hatena.Star.Button = new Ten.Class({
    createButton: function(args) {
        var img = document.createElement('img');
        img.src = args.src;
        img.alt = img.title = args.alt;
        with (img.style) {
	    cursor = 'pointer';
	    margin = '0 3px';
            padding = '0';
            border = 'none';
            verticalAlign = 'middle';
        }
        return img;
    }
});

/* Hatena.Star.AddButton */
Hatena.Star.AddButton = new Ten.Class({
    base: ['Hatena.Star.Button'],
    initialize: function(entry) {
        this.entry = entry;
        this.lastPosition = null;
        var img = Hatena.Star.Button.createButton({
            src: Hatena.Star.AddButton.ImgSrc,
            alt: 'Add Star'
        });
        this.observer = new Ten.Observer(img,'onclick',this,'addStar');
        this.img = img;
        return img;
    },
    ImgSrc: Hatena.Star.BaseURL + 'images/add.gif'
},{
    addStar: function(e) {
        this.lastPosition = e.mousePosition();
        var uri = Hatena.Star.BaseURL + 'star.add.json?uri=' + encodeURIComponent(this.entry.uri) +
            '&title=' + encodeURIComponent(this.entry.title);
        if (Hatena.Star.Token) {
            uri += '&token=' + Hatena.Star.Token;
        }
        new Ten.JSONP(uri, this, 'receiveResult');
    },
    receiveResult: function(args) {
        var name = args ? args.name : null;
        if (name) {
            this.entry.addStar(new Hatena.Star.Star({name: name}));
            //alert('Succeeded in Adding Star ' + args);
        } else if (args.errors) {
            var pos = this.lastPosition;
            pos.x -= 10;
            pos.y += 25;
            var scroll = Ten.Geometry.getScroll();
            var scr = new Hatena.Star.AlertScreen();
            var alert = args.errors[0];
            scr.showAlert(alert, pos);
        }
    }
});

/* Hatena.Star.CommentButton */
Hatena.Star.CommentButton = new Ten.Class({
    base: ['Hatena.Star.Button'],
    initialize: function(entry) {
        this.entry = entry;
        this.lastPosition = null;
        var img = Hatena.Star.Button.createButton({
            src: Hatena.Star.CommentButton.ImgSrc,
            alt: 'Comments'
        });
        img.style.display = 'none';
        this.observer = new Ten.Observer(img,'onclick',this,'showComments');
        this.img = img;
    },
    ImgSrc: Hatena.Star.BaseURL + 'images/comment.gif',
    ImgSrcActive: Hatena.Star.BaseURL + 'images/comment_active.gif'
},{
    showComments: function(e) {
        if (!this.screen) this.screen = new Hatena.Star.CommentScreen();
        this.screen.bindEntry(this.entry);
        var pos = e.mousePosition();
        pos.y += 25;
        this.screen.showComments(this.entry, pos);
    },
    hide: function() {
        this.img.style.display = 'none';
    },
    show: function() {
        this.img.style.display = 'inline';
    },
    activate: function() {
        this.show();
        this.img.src = Hatena.Star.CommentButton.ImgSrcActive;
    }
});

/* Hatena.Star.Star */
Hatena.Star.Star = new Ten.Class({
    initialize: function(args) {
        if (args.img) {
            this.img = args.img;
            this.name = this.img.getAttribute('alt');
        } else {
            this.name = args.name;
            var img = document.createElement('img');
            img.src = Hatena.Star.Star.ImgSrc;
            img.alt = this.name;
            with (img.style) {
                padding = '0';
                border = 'none';
            }
            this.img = img;
        }
	new Ten.Observer(this.img,'onmouseover',this,'showName');
	new Ten.Observer(this.img,'onmouseout',this,'hideName');
	if (this.name) {
            this.user = new Hatena.Star.User(this.name);
            this.img.style.cursor = 'pointer';
            new Ten.Observer(this.img,'onclick',this,'goToUserPage');
        }
        if (args.count && args.count > 1) {
            var c = document.createElement('span');
            c.setAttribute('class', 'hatena-star-inner-count');
            Ten.Style.applyStyle(c, Hatena.Star.InnerCount.style);
            c.innerHTML = args.count;
            var s = document.createElement('span');
            s.appendChild(img);
            s.appendChild(c);
            return s;
        } else {
            return this.img;
        }
    },
    ImgSrc: Hatena.Star.BaseURL + 'images/star.gif'
},{
    showName: function(e) {
        if (!this.screen) this.screen = new Hatena.Star.NameScreen();
        var pos = e.mousePosition();
        pos.x += 10;
        pos.y += 25;
        this.screen.showName(this.name, pos);
    },
    hideName: function() {
        if (!this.screen) return;
        this.screen.hide();
    },
    goToUserPage: function() {
        window.location = this.user.userPage();
    }
});

/* Hatena.Star.InnerCount */
Hatena.Star.InnerCount = new Ten.Class({
    initialize: function(count, e) {
        this.count = count;
        this.entry = e;
        var c = document.createElement('span');
        c.setAttribute('class', 'hatena-star-inner-count');
        Ten.Style.applyStyle(c, Hatena.Star.InnerCount.style);
        c.style.cursor = 'pointer';
        c.innerHTML = count;
        new Ten.Observer(c,'onclick',this,'showInnerStars');
        this.container = c;
        return c;
    },
    style: {
        color: '#f4b128',
        fontWeight: 'bold',
        fontSize: '80%',
        fontFamily: '"arial", sans-serif',
        margin: '0 2px'
    }
},{
    showInnerStars: function() {
        var url = Hatena.Star.BaseURL + 'entry.json?uri=' +
        encodeURIComponent(this.entry.uri);
        new Ten.JSONP(url, this, 'receiveStarEntry');
    },
    receiveStarEntry: function(res) {
        var se = res.entries[0];
        var e = this.entry;
        if (encodeURIComponent(se.uri) != encodeURIComponent(e.uri)) return;
        e.flushStars();
        e.bindStarEntry(se);
        e.addAddButton();
        e.showStars();
    }
});

/* Hatena.Star.Comment */
Hatena.Star.Comment = new Ten.Class({
    initialize: function(args) {
        this.name = args.name;
        this.body = args.body;
    }
},{
    asElement: function() {
        var div = document.createElement('div');
        with (div.style) {
            margin = '0px 0';
            padding = '5px 0';
            borderBottom = '1px solid #ddd';
        }
        var ico = Hatena.User.getProfileIcon(this.name);
        div.appendChild(ico);
        var span = document.createElement('span');
        with(span.style) {
            fontSize = '90%';
        }
        span.innerHTML = this.body;
        div.appendChild(span);
        return div;
    }
});

/* Hatena.Star.NameScreen */
Hatena.Star.NameScreen = new Ten.Class({
    base: [Ten.SubWindow],
    style: {
        padding: '2px',
        textAlign: 'center'
    },
    containerStyle: {
        margin: 0,
        padding: 0
    },
    handleStyle: null,
    showScreen: false,
    closeButton: null,
    draggable: false
},{
    showName: function(name, pos) {
        this.container.innerHTML = '';
        this.container.appendChild(Hatena.User.getProfileIcon(name));
        this.container.appendChild(document.createTextNode(name));
        this.show(pos);
    }
});

/* Hatena.Star.AlertScreen */
Hatena.Star.AlertScreen = new Ten.Class({
    base: [Ten.SubWindow],
    style: {
        padding: '2px',
        textAlign: 'center',
        borderRadius: '6px',
        MozBorderRadius: '6px',
        width: '240px',
        height: '120px'
    },
    handleStyle: {
        position: 'absolute',
        top: '0px',
        left: '0px',
        backgroundColor: '#f3f3f3',
        borderBottom: '1px solid #bbb',
        width: '100%',
        height: '30px',
        borderRadius: '6px 6px 0 0',
        MozBorderRadius: '6px 6px 0 0'
    }
},{
    showAlert: function(msg, pos) {
        this.container.innerHTML = msg;
        var win = Ten.Geometry.getWindowSize();
        var scr = Ten.Geometry.getScroll();
        var w = parseInt(this.constructor.style.width) + 20;
        if (pos.x + w > scr.x + win.w) pos.x = win.w + scr.x - w;
        this.show(pos);
    }
});

/* Hatena.Star.CommentScreen */
Hatena.Star.CommentScreen = new Ten.Class({
    base: [Ten.SubWindow],
    initialize: function() {
        var self = this.constructor.SUPER.call(this);
        if (!self.commentsContainer) self.addCommentsContainer();
        return self;
    },
    style: {
        width: '280px',
        height: '280px',
        overflowY: 'auto',
        padding: '2px',
        textAlign: 'center',
        borderRadius: '6px',
        MozBorderRadius: '6px'
    },
    handleStyle: {
        position: 'absolute',
        top: '0px',
        left: '0px',
        backgroundColor: '#f3f3f3',
        borderBottom: '1px solid #bbb',
        width: '100%',
        height: '30px',
        borderRadius: '6px 6px 0 0',
        MozBorderRadius: '6px 6px 0 0'
    },
    containerStyle: {
        margin: '32px 0 0 0',
        textAlign: 'left',
        padding: '0 10px'
    },
    getLoadImage: function() {
        var img = document.createElement('img');
        img.src = Hatena.Star.BaseURL + 'images/load.gif';
        img.setAttribute('alt', 'Loading');
        with (img.style) {
            verticalAlign = 'middle';
            margin = '0 2px';
        }
        return img;
    }
},{
    addCommentsContainer: function() {
        var div = document.createElement('div');
        with (div.style) {
            marginTop = '-3px';
        }
        this.container.appendChild(div);
        this.commentsContainer = div;
    },
    showComments: function(e, pos) {
        var comments = e.comments;
        if (!comments) comments = [];
        this.commentsContainer.innerHTML = '';
        for (var i=0; i<comments.length; i++) {
            this.commentsContainer.appendChild(comments[i].asElement());
        }
        if (e.starEntry && !e.can_comment) {
            this.hideCommentForm();
        } else {
            this.addCommentForm();
        }
        var win = Ten.Geometry.getWindowSize();
        var scr = Ten.Geometry.getScroll();
        var w = parseInt(this.constructor.style.width) + 20;
        if (pos.x + w > scr.x + win.w) pos.x = win.w + scr.x - w;
        this.show(pos);
    },
    bindEntry: function(e) {
        this.entry = e;
    },
    sendComment: function(e) {
        if (!e.isKey('enter')) return;
        var body = this.commentInput.value;
        if (!body) return;
        this.commentInput.disabled = 'true';
        this.showLoadImage();
        var url = Hatena.Star.BaseURL + 'comment.add.json?body=' + encodeURIComponent(body) +
            '&uri=' + encodeURIComponent(this.entry.uri) +
            '&title=' + encodeURIComponent(this.entry.title);
        new Ten.JSONP(url, this, 'receiveResult');
    },
    receiveResult: function(args) {
        if (!args.name || !args.body) return;
        this.commentInput.value = ''; 
        this.commentInput.disabled = '';
        this.hideLoadImage();
        var com = new Hatena.Star.Comment(args);
        this.entry.addComment(com);
        this.commentsContainer.appendChild(com.asElement());
    },
    showLoadImage: function() {
        if (!this.loadImage) return; 
        this.loadImage.style.display = 'inline';
    },
    hideLoadImage: function() {
        if (!this.loadImage) return; 
        this.loadImage.style.display = 'none';
    },
    hideCommentForm: function() {
        if (!this.commentForm) return;
        this.commentForm.style.display = 'none';
    },
    addCommentForm: function() {
        if (this.commentForm) {
            this.commentForm.style.display = 'block';
            return;
        }
        var form = document.createElement('div');
        this.container.appendChild(form);
        this.commentForm = form;
        with (form.style) {
            margin = '0px 0';
            padding = '5px 0';
            // borderTop = '1px solid #ddd';
        }
        //if (Hatena.Visitor) {
        //    form.appendChild(Hatena.Visitor.profileIcon());
        //} else {
        //    form.appendChild(Hatena.User.getProfileIcon());
        //}
        var input = document.createElement('input');
        input.type = 'text';
        with (input.style) {
            width = '215px';
	    border = '1px solid #bbb';
            padding = '3px';
        }
        form.appendChild(input);
        this.commentInput = input;
        var img = this.constructor.getLoadImage();
        this.loadImage = img;
        this.hideLoadImage();
        form.appendChild(img);
        new Ten.Observer(input,'onkeypress',this,'sendComment');
    }
});

/* Hatena.Star.EntryLoader */
Hatena.Star.EntryLoader = new Ten.Class({
    initialize: function() {
        var entries = Hatena.Star.EntryLoader.loadEntries();
        this.entries = [];
        for (var i = 0; i < entries.length; i++) {
            var e = new Hatena.Star.Entry(entries[i]);
            e.showButtons();
            this.entries.push(e);
        }
        this.getStarEntries();
    },
    createStarContainer: function() {
        var sc = document.createElement('span');
        sc.setAttribute('class', 'hatena-star-star-container');
        sc.style.marginLeft = '1px';
        return sc;
    },
    createCommentContainer: function() {
        var cc = document.createElement('span');
        cc.setAttribute('class', 'hatena-star-comment-container');
        cc.style.marginLeft = '1px';
        return cc;
    },
    scrapeTitle: function(node) {
        var rval = [];
        (function (node) {
            if (node.tagName == 'SPAN' &&
                (node.className == 'sanchor' ||
                 node.className == 'timestamp')) {
                     return;
            } else if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) {
                return;
            }
            var cn = node.childNodes;
            if (cn) {
                for (var i = 0; i < cn.length; i++) {
                    arguments.callee.call(this, cn[i]);
                }
            }
            var nodeValue = node.nodeValue;
            if (typeof(nodeValue) == 'string') {
                rval.push(nodeValue);
            }
        })(node);
        return rval.join('');
    },
    headerTagAndClassName: ['h3',null],
    getHeaders: function() {
        var t = Hatena.Star.EntryLoader.headerTagAndClassName;
        return Ten.DOM.getElementsByTagAndClassName(t[0],t[1],document);
    },
    loadEntries: function() {
        var entries = [];
        //var headers = document.getElementsByTagName('h3');
        var c = Hatena.Star.EntryLoader;
        var headers = c.getHeaders();
        for (var i = 0; i < headers.length; i++) {
            var header = headers[i];
            var a = header.getElementsByTagName('a')[0];
            if (!a) continue;
            var uri = a.href;
            var title = '';
            // Ten.DOM.removeEmptyTextNodes(header);
            var cns = header.childNodes;
            title = c.scrapeTitle(header);
            var cc = c.createCommentContainer();
            header.appendChild(cc);
            var sc = c.createStarContainer();
            header.appendChild(sc);
            entries.push({
                uri: uri,
                title: title,
                star_container: sc,
                comment_container: cc
            });
        }
        return entries;
    }
},{
    getStarEntries: function() {
        var url = Hatena.Star.BaseURL + 'entries.json?';
        for (var i = 0; i < this.entries.length; i++) {
            if (url.length > Ten.JSONP.MaxBytes) {
                new Ten.JSONP(url, this, 'receiveStarEntries');
                url = Hatena.Star.BaseURL + 'entries.json?';
            }
            url += 'uri=' + encodeURIComponent(this.entries[i].uri) + '&';
        }
        new Ten.JSONP(url, this, 'receiveStarEntries');
    },
    receiveStarEntries: function(res) {
        var entries = res.entries;
        if (!entries) entries = [];
        for (var i = 0; i < this.entries.length; i++) {
            var e = this.entries[i];
            for (var j = 0; j < entries.length; j++) {
                var se = entries[j];
                if (!se.uri) continue;
                if (encodeURIComponent(se.uri) == encodeURIComponent(e.uri)) {
                    e.bindStarEntry(se);
                    entries.splice(j,1);
                    break;
                }
            }
            if (typeof(e.can_comment) == 'undefined') {
                e.setCanComment(res.can_comment);
            }
            e.showStars();
            e.showCommentButton();
        }
    }
});

/* Hatena.Star.WindowObserver */
Hatena.Star.WindowObserver = new Ten.Class({
    initialize: funct


  

2007-07-13

KEREM SHALOM, Israel, July 11 ?? Real life has a way of intruding into the airy absolutes of the Israeli-Palestinian conflict. Each side may deny the other’s historical legitimacy, or plot the other’s demise, but somehow, the gritty business of coexistence marches on.

Skip to next paragraph

Enlarge This Image

Rina Castelnuovo for The New York Times

An Israeli man signaled for a truck to move toward Gaza at Sufa on Wednesday. Commerce continues despite the Hamas takeover.

The New York Times

For the past month, since the Islamic militants of Hamas took over the Gaza Strip, Israel has kept the main commercial crossing point at Karni shuttered, squeezing the life out of the limp Gazan economy. Israel bans contact with Hamas, and Hamas seeks Israel’s destruction, making border crossing etiquette more precarious than elsewhere.

Yet at this small crossing near the Egyptian border on Wednesday, between mortar attacks by Hamas and other militants, about 20 truckloads of milk products, meat, medicines and eggs passed from Israel into Gaza, part of the effort to keep basic commodities reaching the 1.5 million Palestinians of the largely isolated strip. Most of the supplies are not humanitarian relief, but are ordered by Palestinian merchants from Israeli suppliers, relying on contacts built up over years.

The mechanics of the crossover manage to answer Israel’s security needs while avoiding contact with Hamas. At Kerem Shalom, Israeli trucks transfer their goods to what Israeli military officials describe as a “sterile” Palestinian truck. Driven by a carefully vetted Palestinian driver, the truck never leaves the terminal, carrying the goods to the Palestinian side, where they are transferred onto ordinary Palestinian trucks that drive into Gaza.

Kerem Shalom, which means “vineyard of peace,” is surrounded by fences and concrete barriers. It can process only about 20 trucks a day, so it is reserved for products that require refrigeration.

The hardier goods, which make up the bulk of the supplies, go through another crossing, at Sufa, to the north. About 100 Israeli trucks a day come from Israel, swirling up clouds of dust before dumping thousands of tons of dry products, bales of straw and crates of fruit on “the platform,” a fenced-in patch of baked earth. At 3 p.m. the Israeli suppliers leave. Like drug dealers picking up a “drop,” the Gaza merchants send in trucks from a gate on the other side and take the products away.

Other products make their way into Gaza with virtually no human interaction. At the fuel depot at Nahal Oz, Israeli tankers pour diesel, gasoline and cooking gas into Gaza through pipes that run beneath the border. And even at Karni, the main crossing that closed for normal operations on June 12, the Israelis have adapted a 650-foot-long conveyor belt, which was previously used for gravel, to send in grain.

“It is better all around from a security point of view that commodities go in,” said Maj. Peter Lerner of the Coordination and Liaison Administration, the Israeli military agency that deals with the civilian aspects of the Gaza border. “More despair doesn’t serve anyone.”

Israeli officials cite security reasons for having shut Karni, the only crossing equipped to send containers into Gaza, or to handle exports out of the strip. “Karni was based on the concept of two sides operating together,” said Col. Nir Press, the head of the coordination agency.

Colonel Press noted that in April 2006, a vehicle loaded with half a ton of explosives got through three of four checkpoints on the Palestinian side of Karni, and was stopped at the last security position by members of the American-backed Presidential Guard, loyal to the Palestinian president, Mahmoud Abbas of Fatah.

But the Presidential Guard is no longer there, having been routed, along with all other Fatah forces in Gaza, by Hamas.

Instead, the military wing of Hamas and other Palestinian factions have been firing mortar shells at Kerem Shalom. On Tuesday, 10 of them landed in and around the terminal as two trucks of milk were passing. The crossing was closed for the rest of the day. [Another barrage of mortar shells hit areas around Kerem Shalom on Thursday.]

Hamas suspects that Israel wants to use Kerem Shalom to replace the Rafah crossing on the Egypt-Gaza border, which has been closed since June 9. The Palestinians had symbolic control at Rafah. At Kerem Shalom, Israel can better supervise who ?? and what ?? is going in and out of the strip.

“Kerem Shalom is a military post, a place from which Israeli tanks begin their incursions into Gaza,” said Fawzi Barhoum, a Hamas spokesman, justifying the mortar attacks. “How can we consider it a safe and legitimate crossing to replace Rafah?”

But when it comes to food, rather than principle, Hamas is proving itself pragmatic as well. On Sunday, Palestinian merchants, trying to press Israel to reopen Karni, told the Israelis that Hamas had barred the import of Israeli fruit. But by Wednesday, the Israeli fruit was ordered again. “Hamas does not want to lose the private sector,” a Gaza businessman explained.

Tellingly, the exposed Sufa crossing, through which most of the food comes, has not been attacked with mortars so far. Without Karni, however, and with the smaller crossings operating on a one-way basis, Gaza can barely subsist. With hardly any raw materials going in, and no products from Gazan farms, greenhouses and factories so far allowed out, Gaza’s tiny industrial base is on the verge of collapse.

Hamas officials say they want to start negotiations with Israel about reopening the formal crossings. Major Lerner said that Hamas had “a few things to do” first, including recognizing Israel’s right to exist and freeing Gilad Shalit, the Israeli soldier captured and taken to Gaza in a raid more than a year ago.

But the ultimate test of pragmatism may come in September when the Hebrew calendar enters what is known in Jewish law as a “shmita” year. Then the fields of Israel are supposed to lie fallow, and observant Jews seek agricultural products grown elsewhere. Before the Hamas takeover, Israel’s rabbis had reached agreements with Palestinians to import vegetables from Gaza, Major Lerner said. Given the needs of both sides, it may still happen.

不満をつらつらと

  1. 二十歳過ぎた男を女と勘違いする奴って何なの?そりゃ髪がイエうたのハルみたいだったり色白だったりチビだったりするけどさ、肩幅が異様に広かったり声が低すぎたり髭の跡が見えたりナイムネ過ぎたりで、普通気付くでしょが。ボーイッシュって、そりゃ当たり前だ。
  2. トイレット行くとき、直接的表現だと気分を害するかなーと思って婉曲的に表現したのだから、その辺りの意図を汲み取ってよ。そりゃ「ちょっとキヤノン会長のところに行ってきます」って言ったのはマズかったよ。でもさ、前「花を摘みに行ってきます」って言ったら「どんな野薔薇を散らすんですか?」って茶化したのは誰だよ。
  3. 知らないプログラミング言語の課題を訊かないでよ。PHPとかJavaとかBasicとかRubyとかC#とか訊かれても答えられないよ。出来るのはC(とC++)とPascalPerlだけって言ってるのに、何でそれらは訊かないで、未知の言語ばっかり質問するのさ。しかもこれからの時代はPHPだとかJavaだとかRubyだとかC#だって説教するんなら自分で解いてよ。
  4. スズメバチの退治なんてやらせないでよ。恐いよ。しかもさ、ハチスプレー高いんだよ、数千円とか。そりゃ何度かアシナガバチ退治したことあるって言ったけどさ、アシナガバチスズメバチじゃ雲泥の差だよ。だって奴ら、アシナガバチ狩るし。アシナガバチ倒せるのは相手も同じってことだよ。しかも、見るとキイロスズメバチじゃん。凶暴な種じゃん。恐いよー毛深いよー。
  5. 何でも知ってるデータベースか何かみたいに扱わないでよ。いきなり小狼シャオラン)とか言われてもわからないよ。CLAMPは、せいぜいちょびっツ知ってるくらいだよ。柚姫イイよね。School Daysがどうとか言われても、付いていけないよ。つかどんだけアニメ見てるんだよ。そのくせ何で「デスラー総統万歳」を知らないんだよ。往年の名作じゃないか。
  6. 八つ当たりしないでよ。あいつが悪いって言われても、現場に居なかったんだしわからないよ。どっちの味方だって尋ねられたって、どっちとも答えようがないよ。非同盟政策ってやつだよ、栄光なき孤立。そしたら八方美人みたいに言うし。どっちにも肩入れしてない……っていうか、出来るはずもないじゃない。八方美人はどっちにも肩入れする場合でしょが。

2007-06-30

俺とプログラミング

http://anond.hatelabo.jp/20070630181251

触発されて、俺もプログラミングとのかかわりを考えてみた。

小学生時、家にはFM-TOWNSがあり、PCには触る機会が多かった。当時、ソフトウェアというものはメーカーが作るものだという思い込みがあったが、フリーソフトというのものの存在を知り、どうやってそれが作られているのか気になる。プログラムがしたいと思うが、開発環境が手に入らず断念。

おかんがPC9801を仕事で借りてきた。マニュアル群の中にROM-BASICの説明書(文法解説付き)がありいじりまくる。しかし、ROM-BASICは保存が出来ないので、毎日プログラムを一から組みなおしていた。作っていたのは、ほぼIFとGOTOのみからなるアドベンチャーゲームもどき。

中学生時、友人家にN88BASICを見つけて借りて帰る。今は無きBASICマガジンを毎月買って、載っているプログラムを打ち込み、それを参考にしてゲームを作っていた。

高校に入り、この頃から家にWindowsマシンがあったので、VisualBasic適当プログラムを組みまくる。いま考えたら恥ずかしいホームページを作って、ソフトを公開する。いくつかのソフトがWindows100%なんかの雑誌に載ったりする。Cとかもちょっとだけ触る。受験とともにプログラミングから離れる。

大学4年目、研究室に配属されてプログラムに久しぶりに触る。いろいろな言語の開発環境が揃っているので、適当に遊んでみる。

今はハードウェア記述言語Verilog-HDLを書いてる。結構面白い。

2007-05-24

http://anond.hatelabo.jp/20070524103441

俺は「作りたいものをひたすら作り続ける」ってやり方で乗り切ってた。まあ中学生の頃に FM-7BASICゲーム作ってただけだけど。君が言うような鍛錬に近い努力は経験がないなあ。いつも楽しい目標を追ってた気がするよ。

今も仕事が選べるようになってきたのでつまらないものは弾いてるし。そりゃ目標があっても大変だったり単調だったりすることは山ほどあるけど、純粋な苦痛にしか感じなくなったら終わりだ。

Enjoy your hacking!

http://anond.hatelabo.jp/20070523230747

プログラミングなんて、人に教わろうなんて思っちゃ駄目だぜ。師匠はいてもいい。人には、わからないところを聞くもんだぜ。プログラミングなんて習うより慣れろ、だぜ。

とりあえず、目に見える形が出るものをやってみるのが一番だぜ。昔なら、Basicマガジンゲームソースを打ち込んで、改造したけど、これって、目に見えて、変化するから、覚えられるんだぜ。

つまりだな、以下のプログラミング環境を触ってみるのがいいんだぜ。

とにかく、わからなくても、サンプルとかネットコードを弄ってみて、改造して、覚えるもんだぜ。

とりあえず、プログラミングに詳しいリアル友達がいなかったら、2ch初心者スレで聞きまくるんだぜ。聞くコツは、「初心者ですが、よろしくお願いします」なんてわかりきったこと言わないことだぜ。あとは、エラー内容とかは、詳細まで貼り付けることだぜ。

プログラミング言語」なんだけど。

言語が覚えれないのかな?

用語や文法みたいなレベルで既に躓くというか。なんというか、「言葉」って何で言葉って言うの?みたいな変な疑問ばかり湧いてきて進まないんだよね。

http://anond.hatelabo.jp/20070523230747

英語とかどうだったの?

"This is a pen." "Yes, It is."

そんな事いわねーよ、とか思った?

ペンてなに、鉛筆、ポールペン?マジックマジックだよね、とか思った?

"a"ってなんだよアって。どこ行ったの?とか。

とりあえず、細かい事はいいんだ。ノリだよノリ。で覚えた気がするけど……

あと、数学も。

Σとかλとか、dxとか∫とか、どうしたの?

[追記]

そうそう、プログラムの組み立て方を学ぶ前の、とりあえず試すために覚える言語ってなにがいいのかな?

BASIC?でも今時サラのBASICってのもちょっとだし、VBはアク強いし。

Cは色々おまじないが多過ぎるし、perlは癖が強過ぎるし。rubyってどうなん?それともやっぱりpascal

2007-04-12

俺記法感想

増田職業プログラマっぽいのが、結構な割合で居そうなのが判った。

そして自分も楽しめた。ありがとう

こういう話大好き。

こうやってみんなスタイル見ると、どのスタイルも大して見づらい事もないんだよね。

でも実際の引継ぎ仕事やら、全面改修やらで回ってくるソースって、ありえない事になっちゃってる率があまりに高いよね。

ああいう、訳の判らない事態に陥る原因とかがやんわり判ったりすると、ちょっと面白いのかもなぁって思った。

例として、過去に自分が死にかけた(と言うかぶちきれて、仕事放り投げたくなった)ソース

・一般のパソコン向けパッケージソフト(C言語ベース

関数が10個程度しかない

関数一つ当たりの行数が1万越え

・内switch文が占める割合9割

おまえはBASICか(いや、basicでももっとましだけど)と突っ込みたくなった。

用はswitch文一つ一つが関数の役割を果たしてて、それをグローバル変数一つで切り替えて制御していると言う…言っててむなしくなってきた。

2007-03-19

http://anond.hatelabo.jp/20070319213624

西武労働レストラン。あ、それはBASICだった(恥

そういえばハンドアセンブルしたことあったなぁ・・・(遠い目

ログイン ユーザー登録
ようこそ ゲスト さん