Skip to content

Instantly share code, notes, and snippets.

View teramako's full-sized avatar

teramako teramako

View GitHub Profile
@teramako
teramako / test_class.js
Created October 5, 2012 05:37
プロトタイプ内のメソッドから、そのインスタンスのプライベートな値をset/getできるようにするサンプル(WeakMapの使用)
var TestClass = (function(){
var _map = new WeakMap; // private variables
function TestClass() {}
Object.defineProperty(TestClass.prototype, "name", {
configurable: true,
get: function () {
return _map.has(this) ? _map.get(this).name || null : null;
},
set: function (val) {
var m = _map.has(this) ? _map.get(this) : {};
--- messenger.dtd 2010-01-01 00:00:00.000000000 +0900
+++ messenger.dtd.new 2012-09-21 19:46:10.093750000 +0900
@@ -510,6 +510,8 @@
<!ENTITY errorConsoleCmd.label "エラーコンソール">
<!ENTITY errorConsoleCmd.accesskey "E">
<!ENTITY errorConsoleCmd.commandkey "j">
+<!ENTITY clearRecentHistory.label "最近の履歴を削除...">
+<!ENTITY clearRecentHistory.accesskey "H">
<!ENTITY accountManagerCmd.label "アカウント設定...">
<!ENTITY accountManagerCmd.accesskey "S">
@teramako
teramako / jsxml.js
Created September 12, 2012 12:17
ObjectをDOM変換する
/*
* @example
* var tree = {
* body: [
* {$: "p",
* attrs: { "liberator:highlight": "Hint", },
* child: "hoge",
* },
* "text node",
* {$: "p",
@teramako
teramako / gist:3301751
Created August 9, 2012 06:45
FizzBuzz
seq 100 | perl -nle 'print (($_%3?"":"Fizz").($_%5?"":"Buzz")||$_);'
seq 100 | sed -e'0~3s/^.*/Fizz/' -e'0~5s/[0-9]*$/Buzz/'
@teramako
teramako / Makefile
Created July 14, 2012 19:59
XPI 作成用 Makefile
#
# XPI ファイル作成用 Makefile
#
# 事前に以下のファイルを Makefile と同じディレクトリに配置すること(要: python)
# http://mxr.mozilla.org/mozilla-central/source/config/Preprocessor.py
# http://mxr.mozilla.org/mozilla-central/source/config/Expression.py
#
DIST_DIR = dist
@teramako
teramako / android_or_mobile.md
Created June 28, 2012 02:15
Firefoxアドオンのスマートフォン向けGUIDとタブレットPC向けGUID

"Android" なのか "Mobile" なのか?

Firefox携帯版拡張機能を作るにあたって、対象のGUIDを指定する必要があるわけだが、携帯版には2種類ある。

  1. スマートフォンのような小さいモバイル機器
    • JavaによるNativeUIにバージョン14から切り替わっている
  2. タブレットPCのような大き目のモバイル機器
@teramako
teramako / README.md
Created June 20, 2012 14:36
add Listeners Panel to DOM Inspector

DOM Inspector にイベントリスナのパネルを追加

cap

  • プロファイルディレクトリ/extensions/inspector@mozilla.org/chrome/inspector.jar を unzip
  • mkdir content/inspector/viewers/eventListeners/
  • eventListeners.xuleventListeners.jscontent/inspector/viewers/eventListeners/ に配置
  • content/inspector/res/viewer-registry.rdf にパッチを当てる
  • zip inspector.jar -r ... でアーカイブ作成
@teramako
teramako / es5-lazygetter.js
Created June 2, 2012 03:34 — forked from tetsuharuohzeki/es5-lazygetter.js
ES5 lazy getter function
function lazyGetter(aObject, aName, aLambda) {
Object.defineProperty(aObject, aName, {
get: function () {
var val = aLambda.call(aObject);
Object.defineProperty(aObject, aName, { value: val, writable: true });
return val;
},
configurable: true,
enumerable : true,
});
@teramako
teramako / def_param_test.js
Created May 27, 2012 15:21
defult parameter test
function foo() {
return "outer foo";
}
var o = {
func: function (arg = foo()) {
function foo(){
return "inner foo";
}
@teramako
teramako / highlight_selector.html
Created May 1, 2012 13:52
CSS ソースのセレクタ部分をハイライトする
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Highlight Selector</title>
<style>
body > p {
background-color: #DDD;
padding: 0.5em;
}