Python の日本語ドキュメントをchromeで検索
pythonしたりjavascriptしたりで、どうにも言語を覚えきれない。
http://code.google.com/p/python-doc-ja/downloads/list から日本語のヘルプ(.chm)はダウンロードできるけど、javascriptが無効になってるみたいでスクリプトエラーが出てまともに機能しないし…。
なので、とりあえず常用している chrome から簡単にヘルプを検索できるように omnibox を設定してみた。
omniboxの設定内容
Google で http://www.python.jp/doc/release/ を検索
タイトル: google python キーワード: py URL: https://www.google.co.jp/webhp?ie=UTF-8#hl=ja&q=site:http%3A%2F%2Fwww.python.jp%2Fdoc%2Frelease%2F+%s
http://www.python.jp/doc/release/ の検索ボックスで検索
タイトル: python.jp キーワード: python URL: http://www.python.jp/doc/release/search.html?q=%s
omniboxの設定手順
- アドレスバーで右ボタンクリック
- 検索エンジンの編集(E...)を選択
- [その他の検索エンジン]に上記内容を追加
シンボル系フォントを表示する方法
こんなことでハマってしまったので、メモっておく。
シンボル系フォントの一部を表示できない
Webdings や Wingdings などのシンボル系フォントで
0x21~0xff
を表示する html を書いてみたら。
0x80~0xa0, 0xad が表示されない。
解決策
0xf021~0xf0ffを表示させると、欲しいマークを表示することができる。
for (var code = 0x21; code <= 0xff; ++ code) { ch = String.fromCharCode(0xf000 + code); // 0xf000 を足すのがミソ }
こんなことで何時間使ったんだろ…。
無知ってすんごい時間を無駄にするとシミジミ実感。
Inkscapeでepsを読む
Inkscapeネタついでに。
以下、Windows な話。
ghostscriptを利用すると eps ファイルの読み込む extension が有効になります。
準備
- ghostscript をインストールする。(2012/03/19 時点で 9.05)
以下、C:\Program Files (x86)\gs\gs9.05にインストールしたことを前提に。 - [コントロール パネル] → [システムとセキュリティ] → [システム] を開く
- [システムの詳細設定]を開く
- [環境変数(N)...]を押す
- ユーザ環境変数の Path を編集する (すべてのユーザに適用する場合は、システム環境変数)
- パスの後ろに C:\Program Files (x86)\gs\gs9.05\bin;C:\Program Files (x86)\gs\gs9.05\lib; を追加する
確認
Inkscape の [ファイル]-[開く] のダイアログで、[ファイルの種類]に『Encapsulated PostScript (*.eps)』が追加されていることを確認する。
使い方
Inkscape から eps ファイルを選択すれば開けます。
eps の読み込み extension は、
- eps→pdf変換
- pdf 読み込み
の手順で踏んでいる模様。
モノにもよるんでしょうが、ウチの環境ではeps→pdf変換には時間が掛かります。
しかも無言だから、この間、若干焦った。
Inkscapeが0xc0000005エラーを出して起動しない
昨夜、突然Inkscapeが起動しなくなって慌てた。
google先生に『inkscape 0xc0000005』を尋ねると、こうした症状は多いみたい。
私も個人データを削除したり、インストールし直したり…。
ちなみに私の環境は
です。
で、私のケースでは
「追加したフォントを削除する」
ことで、起動成功。
ひとつひとつチェックすると
SUBWAY: FontopoSUBWAY.otf
をシステム登録しているとうまく行かないみたい。
あー、焦った。
コードの構文解析ツールを作ってみた
この世にコードの構文解析ツールなんぞたくさんあるけど、javascriptやら正規表現やらの勉強がてら作ってみた。
ソースコードをいくつかの正規表現に掛けて、
- 該当する部分
- 該当しない部分
で振り分けしていく方法をとってみた。
これで意外とうまくいっちゃうのでびっくり。
(function() { function re_match(re, text, object, match, unmatch) { var result = '', index = 0, matched; while ((matched = re.exec(text)) != null) { if (index < matched.index) unmatch.call(object, object, text.substring(index, matched.index)); match.call(object, object, matched[0]); index = re.lastIndex; } unmatch.call(object, object, text.substring(index, text.length)); } CodeTokenizer = function(language, code, handler) { this.language = language; this.handler = handler; this.tokens = []; this.index = 0; this.split(code); return this; }; CodeTokenizer.prototype = { next: function() { if (this.index >= this.tokens.length) return null; return this.tokens[this.index ++]; }, push: function(token) { this.tokens.push(token); return this; }, split: function(code) { re_match( this.language.re_comments, code, this, this.handler.token_comment, this.split_bodys ); }, split_bodys: function(tokenizer, code) { re_match( this.language.re_strings, code, this, this.handler.token_string, this.split_codes ); }, split_codes: function(tokenizer, code) { re_match( this.language.re_spaces, code, this, this.handler.token_space, this.split_tokens ); }, split_tokens: function(tokenizer, code) { re_match( this.language.re_symbols, code, this, this.handler.token_symbol, this.split_words ); }, split_words: function(tokenizer, code) { re_match( this.language.re_numerics, code, this, this.handler.token_numeric, this.split_keywords ); }, split_keywords: function(tokenizer, code) { re_match( this.language.re_keywords, code, this, this.handler.token_keyword, this.handler.token_word ); }, }; CodeLanguage = { javascript: function() { var language = {}; language.re_comments = new RegExp([ '/\\*(.|\\n)*?\\*/', '//.*' ].join('|'), 'g'); language.re_strings = new RegExp([ '".*?"', "'.*?'", ].join('|'), 'g'); language.re_spaces = new RegExp('\\s+', 'g'); language.re_symbols = new RegExp('(' + [ '!', '=', '\\(', '\\)', '<', '>', '\\[', '\\]', '\\+', '-', '\\*', '/', '%', '\\.', ',', ';', '\\?', ':', '&', '\\|', ].join('|') + ')+', 'g'); language.re_numerics = new RegExp('^[0-9]+$', 'g'); language.re_keywords = new RegExp('^(' + [ 'abstract', 'boolean', 'break', 'byte', 'case', 'catch', 'char', 'class', 'const', 'continue', 'debugger', 'default', 'delete', 'do', 'double', 'else', 'enum', 'export', 'extends', 'final', 'finally', 'float', 'for', 'function', 'goto', 'if', 'implements', 'import', 'in', 'instanceof', 'int', 'interface', 'long', 'native', 'new', 'null', 'package', 'private', 'protected', 'public', 'return', 'short', 'static', 'super', 'switch', 'synchronized', 'this', 'throw', 'throws', 'transient', 'try', 'typeof', 'var', 'void', 'volatile', 'while', 'with', ].join('|') + ')$', "g"); return language; }, }; })();
jqMobiがいいかも
今さら感満載だけど。
コアだけ見れば jQuery を
- HTML5専用に限定
- 機能を限定
することでコンパクト化、高速化したライブラリ。
UIのコンポーネントはモバイル専用にできてるので、Desktop用のUIを作るには不向き。
このjqMobiのコアだけ使って、業務アプリ用のUIを構築するのはアリだと思う。
IE8だと動かないけど…。
つまり、windows xp の標準状態では動かないけど…。