STONEDSOUL

Jun 14

ImportError: No module named _ctypes

I got the error when I ran my application on localhost which was started via Google App Engine Launcher. It seems to occur on Max OSX and Python 2.6. To fix that, set python path in preference of GAE Launcher as below instruction.

Issue 985 - googleappengine - Import Error: Failed to import ctypes to load dll on windows - Project Hosting on Google Code

Comment 10 by mike.j.dobbs, Feb 11, 2010

Changing preferences—>”my python path” to “/usr/bin/python2.5” and restarting GoogleAppEngineLauncher fixed this on my Snow Leopard.

Comment 11 by kmallea, Mar 22, 2010

Make sure you hit {enter} in the input field, or the Python Path you type in will not save. I believe this is a bug in the GAE GUI; I read this somewhere else, I forgot where exactly.


(Japanese)

OSX で GoogleAppEngineLauncher を使ってて動作確認する時に urllib を使ってる部分でエラーがでた。回避策は上のページにあるように Python 2.5 を使う事だけど、GAE Launcher の設定画面で Python の Path を設定する時は、入力したら Enter キーを押さないと設定が反映されない、というところではまった。。

Jun 13

JavaScript snippets (trim, supplant)

17 Hours of JavaScript from the Masters で紹介されてるビデオの The JavaScript Programming Language の Part 3 にでてきたコードをメモ。

12:40 あたりに出てくる trim

String.prototype.trim = function() {
    return this.replace(
        /^\s*(\S*(\s+\S+)*)\s*$/, "$1");
};

ちなみに SnipplrJavaScript trim で検索するといくつかヒットするけど、それぞれ微妙にやり方が違ってて面白い。

その後、13:00 あたりから出てくる supplant

String.prototype.supplant = function(o) {
    return this.replace(/{([^{}]*)}/g,
        function (a, b) {
            var r = o[b];
            return typeof r === 'string' ? r : a;
        }
    );
};

それの使い方(ビデオでは使い方が先に出てくる)。

var template = '<table border="{border}">' +
    '<tr><th>Last</th><td>{last}</td></tr>' +
    '<tr><th>First</th><td>{first}</td></tr>' +
    '</table>';

var data = {
    first: "Carl",
    last: "Hollywood",
    border: 2
};

mydiv.innerHTML = template.supplant(data);

同じようなものに RND template があって、 これを参考に(ほとんどコピペして)こんなの を書いたりしたけど、やっぱり書き方が微妙に違う。

Jun 05

[video]