Skip to content

Instantly share code, notes, and snippets.

@nanto
nanto / app.psgi
Created March 5, 2013 15:56
$SIG{__DIE__} の設定如何で Text::Xslate の投げる例外が変化するかもしれないというメモ
use Our::App;
use Try::Tiny;
use Devel::StackTrace::WithLexicals;
builder {
enable sub {
my $app = shift;
sub {
my $trace;
local $SIG{__DIE__} = sub {
@nanto
nanto / jquery-deferred-test-runner.js
Created January 23, 2013 15:50
jQuery のビルドはできないが SpiderMonkey JavaScript Shell が利用できる環境で jQuery Deferred のテストを実行するためのスクリプト。
var window = this;
if (typeof JSON === 'undefined') {
this.JSON = {};
}
load('src/core.js');
load('src/callbacks.js');
load('src/deferred.js');
function module() {}
@nanto
nanto / router.js
Created July 4, 2012 16:51
Router: a router that can be combined with jquery.pjax.js
// Router: a router that can be combined with jquery.pjax.js [1]
//
// [1] https://github.com/defunkt/jquery-pjax
//
// This file is in the public domain.
//
//
// var router = new Router();
// $(document).on('pjax:end', function () { router.dispatch(location); });
// $(function () { router.dispatch(location); });
@nanto
nanto / chrome-files.js
Created January 11, 2011 16:40
Get a list of files from a chrome URL.
/*
* This code is in the public domain.
*
* ChromeFiles.get("chrome://browser/content/")
* => [ "chrome://browser/content/NetworkPanel.xhtml",
* "chrome://browser/content/aboutDialog.css",
* ...,
* "chrome://browser/content/browser.css",
* "chrome://browser/content/browser.js",
* "chrome://browser/content/browser.xul",
@nanto
nanto / consumer.pl
Created December 21, 2010 09:52
はてなブックマークの OAuth 対応 API 利用サンプル。 Run | $ perl consumer.pl daemon | and access http://localhost:3000/.
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use Mojolicious::Lite;
use OAuth::Lite::Consumer;
use XML::Atom::Feed;
use XML::Atom::Entry;
use URI::Escape qw/uri_escape_utf8/;
#!/usr/bin/perl
$i=1;
start:
goto print_fizz if $i % 3 == 0;
goto print_buzz if $i % 5 == 0;
print $i;
goto print_newline;
print_fizz: print 'Fizz';
goto print_buzz if $i % 5 == 0;
goto print_newline;
@nanto
nanto / read-selection.uc.js
Created February 19, 2010 04:07
A userChrome.js script to read selected text with js-ctypes.
// ==UserScript==
// @name Read Selection
// @namespace http://nanto.asablo.jp/blog/
// @description Read selection text.
// @include chrome://browser/content/browser.xul
// @author nanto_vi
// ==/UserScript==
({
// http://www.a-quest.com/products/aquestalk2.html
@nanto
nanto / convertToHTMLString.js
Created February 5, 2010 00:09
covertToHTMLString
// Original code by Constellation
// http://d.hatena.ne.jp/Constellation/20100203/1265207970
function convertToHTMLString(source, safe) {
if (!source || (source.getRangeAt && source.isCollapsed)) return '';
var range = source.getRangeAt ? source.getRangeAt(0) : null;
var node = range ? range.cloneContents() : source.cloneNode(true);
if (safe) {
var root = range && range.commonAncestorContainer.cloneNode(false)
if (!root || root.nodeType !== root.ELEMENT_NODE)
/*
* HTMLParser for Greasemonkey by snaka(http://d.hatena.ne.jp/snaka72/)
*
* Original coode written by swdyh(http://d.hatena.ne.jp/swdyh/)
* This code includes part of AutoPagerize(http://userscripts.org/scripts/show/8551)
*
* Released under the GPL license
* http://www.gnu.org/copyleft/gpl.html
*/
// ==UserScript==
// @name bit.ly referred
// @namespace http://nanto.asablo.jp/blog/
// @include http://*
// @require http://svn.coderepos.org/share/lang/javascript/jsdeferred/trunk/jsdeferred.userscript.js
// ==/UserScript==
D = D();
const XHTML_NS = 'http://www.w3.org/1999/xhtml';