Skip to content

Instantly share code, notes, and snippets.

@teramako
teramako / paranorama-svg-clock.js
Created December 5, 2010 11:59
Show SVG Clock in Panorama
/**
*@see http://realtech.burningbird.net/graphics/svg/experiments-svg-clock
*/
let SVG_NS = "http://www.w3.org/2000/svg";
let XHTML_NS = "http://www.w3.org/1999/xhtml";
let CLOCK_SVG =
<svg version="1.1" width="250" height="250" xmlns={SVG_NS} viewBox="0 0 3 3" id="svg_clock">
<defs>
<style type="text/css"><![CDATA[
@teramako
teramako / xmlToDOM.js
Created December 13, 2010 11:48
E4X to DOM
var XHTML = new Namespace("xhtml", "http://www.w3.org/1999/xhtml");
function xmlToDom (xml, xmlns) {
XML.prettyPringing = false;
XML.ignoreWhitespace = true;
var doc = (new DOMParser).parseFromString(
<root xmlns={xmlns || XHTML}>{xml}</root>.toXMLString(),
"application/xml"
);
var imported = document.importNode(doc.documentElement, true);
var range = document.createRange();
@teramako
teramako / fixBug618563_1.patch
Created December 24, 2010 02:06
Vimpreator patch: fix wrong completion
diff -r 145d4c50d6b4 common/content/commandline.js
--- a/common/content/commandline.js Fri Dec 24 10:23:40 2010 +0900
+++ b/common/content/commandline.js Fri Dec 24 11:04:18 2010 +0900
@@ -1118,7 +1118,7 @@
*/
Completions: Class("Completions", {
init: function (input) {
- this.context = CompletionContext(input.editor);
+ this.context = CompletionContext(input);
this.context.onUpdate = this.closure._reset;
@teramako
teramako / .vimperatorrc
Created January 11, 2011 07:35
goo.glの短縮URLに変換するvimperatorの設定
" http://code.google.com/intl/ja/apis/urlshortener/v1/getting_started.html
cabbrev -javascript ggl ggl(buffer.URI)
js <<EOM
userContext.ggl = function getGoogleShortenURL(url, callback) {
let uri = "https://www.googleapis.com/urlshortener/v1/url";
let xhr = new XMLHttpRequest();
xhr.open("POST", uri, !!callback);
if (callback) {
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
// userChorme.js
// @see https://bugzilla.mozilla.org/show_bug.cgi?id=593388
window.addEventListener("tabviewframeinitialized", function (event) {
this.removeEventListener(event.type, arguments.callee, false);
var win = TabView._window;
var tabViewRootElement = win.document.documentElement;
function updateBackground (isLwthemeActive) {
var imageStyle = "";
// ==UserScript==
// @name GM_test_01
// @description GM test 01
// @include *
// ==/UserScript==
window.FOO = "BAR";
if (this.sharedObject)
sharedObject.FOO = "SHARED BAR";
@teramako
teramako / xraywrapper-test.js
Created February 4, 2011 13:50
Firefox3.6のXPCNativeWrapperとFirefox4.0のXrayWrapperの違い
/*
簡易テストのため、Vimperatorの:sourceで実行
wrapされたSandbox上で一方(sd1)に値を代入、もう一方(sd2)で参照をするテスト
Firefox3.6 の場合:
sd1でevalInSandboxした値はsd2からも参照可能。
また、Chrome特権上からも参照可能
Firefox4.0bの場合:
diff -r d1cf77d3a834 common/content/commandline.js
--- a/common/content/commandline.js Sat Feb 12 15:58:01 2011 +0100
+++ b/common/content/commandline.js Mon Feb 14 20:04:45 2011 +0900
@@ -132,6 +132,7 @@
this._commandWidget = document.getElementById("liberator-commandline-command");
this._messageBox = document.getElementById("liberator-message");
+ this._messageBox.addEventListener("transitionend", this.close.bind(this), false);
this._commandWidget.inputField.QueryInterface(Ci.nsIDOMNSEditableElement);
@teramako
teramako / nsproxy.js
Created February 22, 2011 15:39
only Firefox4, E4X hack:: Namespace accessor
/*
// Example::
(function(ns){
ns.foo = "abc";
// => window["teramako.github.com::foo"] == "abc"
})(NS("github", "teramako.github.com"));
*/
@teramako
teramako / validateHost.js
Created March 21, 2011 16:40
URIにきちんとTLDが付いているか検証する
/**
* @example
* validateHost("http://hogehoge"); // false
*/
var io = window.Services.io,
eTLD = window.Services.eTLD,
fixup = Cc["@mozilla.org/docshell/urifixup;1"].getService(Ci.nsIURIFixup);
function makeURI (aURL, aCharset, aBaseURI) {