Skip to content

Instantly share code, notes, and snippets.

View piroor's full-sized avatar

YUKI "Piro" Hiroshi piroor

View GitHub Profile
@piroor
piroor / copy-all-visible-logs.js
Created November 9, 2015 10:14
Utility codes for Mozilla Thunderbird's error console (tested on Thunderbird 38)
Components.utils.import('resource://gre/modules/Services.jsm');var text=[];for (var row of Services.wm.getMostRecentWindow('global:console').document.getElementById('ConsoleBox').mConsoleRowBox.children) { if (row.boxObject.height > 0) { text.push(row.toString()); } }; Components.classes['@mozilla.org/widget/clipboardhelper;1'].getService(Components.interfaces.nsIClipboardHelper).copyString(text.join('\n---\n'));
@piroor
piroor / index.html
Last active September 9, 2015 10:47
Link to local file
<!DOCTYPE html>
<title>link to local file</title>
<a href="file:///c:/windows/">c:\windows\</a>
@piroor
piroor / file0.txt
Last active August 29, 2015 14:11
Droongaの分散処理を支える技術:マスター無しでのクラスタ管理 ref: http://qiita.com/piroor/items/20caac6e66ea228585e9
{ "version": 3,
"datasets": {
"Default": {
"volume": { "replicas": [
{ "slices": [
{ "volume": { "replicas": [
{ "address": "node0:10031/droonga.000" },
{ "address": "node1:10031/droonga.000" }
] } },
{ "volume": { "replicas": [
@piroor
piroor / file0.txt
Last active August 29, 2015 14:11
Droongaの分散処理を支える技術:通信プロトコル ref: http://qiita.com/piroor/items/2ca1e722c1bc48b17fce
{
"id": 01234,
"type": "select",
"date": "2014-12-16T00:00:00Z",
"from": "client0:10031/droonga",
"replyTo": "client0:10031/droonga",
"dataset": "Default",
"body": { "table": "Stores",
"output_columns": "name",
"limit": 10 }
@piroor
piroor / morkdump
Last active August 29, 2015 14:00
morkdump
#!/usr/bin/env ruby
#
# Mork Dumper, based on the CPAN module "Mozilla::Mork"
# http://search.cpan.org/~kript/Mozilla-Mork-0.01/lib/Mozilla/Mork.pm
#
# description:
# "Mork" is a format of Mozilla's internal data files, like
# summary files (*.msf) of Thunderbird. This command reports
# all contents of the specified Mork file as a JSON string.
#
/**
* @fileOverview JSDeferred flavoured Promise.jsm
* @author piro.outsider.reflex@gmail.com
* @version 0.1
* @license
* JSDeferred flavoured Promise.jsm Copyright (c) 2014 YUKI "Piro" Hiroshi
* JSDeferred Copyright (c) 2007 cho45 ( www.lowreal.net )
*
* Original: http://github.com/cho45/jsdeferred
*
@piroor
piroor / crash-with-crashreport.js
Last active December 31, 2015 14:49
Crash firefox by js-ctypes (run in the scratch pad or the browser console)
(function(){
Components.utils.import('resource://gre/modules/ctypes.jsm');
var library = ctypes.open(ctypes.libraryName('nss3'));
var PR_Free = library.declare(
'PR_Free',
ctypes.default_abi,
ctypes.void_t,
ctypes.voidptr_t
);
var ptr = new ctypes.voidptr_t(0123);
@piroor
piroor / GroongaStringUtils.js
Created July 18, 2013 07:58
GroongaStringUtils, for extraction of matched terms on the client side.
/**
* Usage:
* var matcher = GroongaStringUtils.getTermsMatcher('検索 OR けんさく');
* // => /(a pattern to match all search terms in the given query)/g
* document.body.innerHTML = document.body.innerHTML
* .replace(matcher, function(term) { return '<em>' + term + '</em>'; });
*
* License: The MIT License
* Copyright (c) 2013 ClearCode Inc.
*/
@piroor
piroor / one-time.js
Last active December 18, 2015 08:39
Stress test with one-time gradients
var canvas = document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas');
canvas.width = 100;
canvas.height = 100;
canvas.setAttribute('style', 'width:100px;height:100px;position:fixed;top:0;right:0;z-index:10000;');
document.documentElement.appendChild(canvas);
var context = canvas.getContext('2d');
function random(max) {
return parseInt(Math.random() * max);
}
@piroor
piroor / Menu.js
Last active January 12, 2017 16:23
Simple dropdown menu component for Sencha Touch 2
/**
* License: The MIT License
* Copyright (c) 2013 ClearCode Inc.
*
* Description:
* Simple dropdown menu component for Sencha Touch 2.
* This works like:
* [Anchor button]
* __/\____
* |Item 1|