Skip to content

Instantly share code, notes, and snippets.

View teramako's full-sized avatar

teramako teramako

View GitHub Profile
@teramako
teramako / README.md
Last active December 12, 2015 09:09
何となく Node.js 的な EventEmitter を実装してみた。 ES.next とか使いまくりで普通じゃ使えないけど。

#Example

function Foo () {
  EventEmitter.call(this);
}
Foo.prototype = mixin(Object.create(EventEmitter.prototype), {
  doSomeThing: function () {
    var data = {};
 //....
@teramako
teramako / extend.js
Created January 29, 2013 12:48
作ってみたけど、あまり格好良い __super__ じゃなかったorz
var [mixin, extend] = (function() {
var wm = WeakMap();
function mixin(aTarget, ...aSources) {
for (let source of aSources) {
for (let key of Object.getOwnPropertyNames(source)) {
let desc = Object.getOwnPropertyDescriptor(source, key);
Object.defineProperty(aTarget, key, desc);
}
}
return aTarget;
function defineProperties (aTarget, aSource) {
var key, desc;
for (key of Object.getOwnPropertyNames(aSource)) {
desc = Object.getOwnPropertyDescriptor(aSource, key);
desc.enumerable = false;
Object.defineProperty(aTarget, key, desc);
}
return aTarget;
}
@teramako
teramako / README.md
Last active December 11, 2015 17:28
FxHTTPD https://github.com/teramako/fxHttpd 用の CDドライブを eject するやつ。 FxHTTPD 使ってると良く CD-ROM を取り出したくなりますよね。 ならないとしたら、今すぐこの記事を読むのをやめて病院に行って下さい。

eject

  1. chrome://fxhttpd/content/options.xul をひらいて
  2. File Handlers の add ボタンをクリックして
  3. eject を入力し、select ボタンからこのファイルを選ぶ
  4. 右下のOKを押して登録
  5. Server を再起動する
  6. http://localhost:8090/eject?path=/media/cdrom 等でeject
@teramako
teramako / hateb_rm_sameTitleComment.user.js
Created January 17, 2013 08:21
はてなブックマークコメントでタイトルと同じ無意味なコメントを除去するスクリプト
// ==UserScript==
// @id hateb_rm_sameTitleComemnts
// @name hateb_rm_sameTitleComemnts.js
// @version 1.0
// @namespace teramako
// @author teramako
// @description
// @include http://b.hatena.ne.jp/entry/*
// @run-at document-end
// ==/UserScript==
const EXPORTED_SYMBOLS = ["eject"];
Components.utils.import("resource://gre/modules/ctypes.jsm");
const UINT = ctypes.unsigned_int;
const DWORD = ctypes.uint32_t;
const LPCWSTR = ctypes.jschar.ptr;
if (ctypes.size_t.size == 8) {
var WinABI = ctypes.default_abi;
@teramako
teramako / mutationObserverAndCustomEvent.html
Created January 4, 2013 11:45
MutaionObserver で監視し、CustomEvent を投げるサンプル
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Mutation Observer and Custom Event</title>
</head>
<body>
<h1>Mutation Observer and Custom Event</h1>
<button onclick="insertNode()">Node Insert</button>
@teramako
teramako / debuggableBind.js
Created November 6, 2012 14:13
[デバッグ用]Function.prototype.bind を修正して source プロパティに元関数を仕込む
/**
* debaggable bind
* set the original function to 'source' property on bind()
*/
(function(){
var bind = Function.prototype.bind;
Function.prototype.bind = function () {
var bound = bind.apply(this, arguments);
bound.source = this.source || this;
@teramako
teramako / markdown.js
Created November 1, 2012 14:12
Markdown ファイルを HTML 出力するやつ
/**
* Markdown generator
* @example
* node markdown.js <file.md> [ file.md ... ]
*/
const fs = require("fs"),
libxml = require("libxmljs"),
pagedown = require("pagedown");
const markdown = new pagedown.Converter;
@teramako
teramako / orion.js.patch
Created October 16, 2012 01:29
Source-Editor(Scratchpad, Stylish等のエディタ)のOrionで日本語入力ができなくなった件のメモ

Source-Editor(Scratchpad, Stylish等のエディタ)のOrionで日本語入力ができなくなった件

  1. 630810 – Should convert from native keycode to DOM keycode for every keys on Windows が mozilla-15 に対してコミットされる
  2. 772073 – Can't input Chinese in scratchpad にて中国語が入力できないというリグレッションが登録される

変更内容