Skip to content

Instantly share code, notes, and snippets.

View teramako's full-sized avatar

teramako teramako

View GitHub Profile
@teramako
teramako / extendGeneratorPrototype.js
Last active September 18, 2016 16:09
Generatorのプロトタイプ拡張。ま、やっつけです。
/* Usage
function * gene() {
console.log("iter");
yield 1;
console.log("iter");
yield 2;
console.log("iter");
yield 3;
}
var result = gene
@teramako
teramako / join.vba
Created June 27, 2016 06:14
Excel VBAの標準モジュールに追加してる関数
' ="SELECT ..... FROM ... WHERE column_A in ("&join(A1:A10,",","'")&")" などと式に使うことを想定
' SQLインジェクション可能だが知らん。
Function join(r As Range, Optional delimiter As String = ",", Optional wrap As String = "'") As String
Dim i As Integer
Dim result = As String
result = wrap & r.Cells(1, 1).Value & wrap
For i = 2 To r.rows.Count
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Serial Experimental proceed</title>
<style>
#out { line-height: 1.5; }
#out > p { margin: 0; }
</style>
</head>
@teramako
teramako / proto_test.html
Created July 4, 2013 17:49
__proto__ のテスト
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>__proto__ test</title>
</head>
<body>
<h1>__proto__ test</h1>
<div id="out"></div>
@teramako
teramako / page-nav.js
Last active December 18, 2015 16:59 — forked from anonymous/page-nav.js
[Vimperator]ページ内の見出し的要素へジャンプする奴
"use strict";
/**
* :nav コマンドでテキトウに補完を使いましょう
* :nnoremap v :nav<Space> とかすると快適かも
*/
var selector = "h1, h2, h3, h4, main, [role=main], [role=navigation], [role=search]";
var cache = new WeakMap;
function getJumpList (force) {
@teramako
teramako / paging-completion.js
Created May 26, 2013 05:14
Vimperator-Plugin: page feeder of completion list
/**
* Vimperator-Plugin
* @desc page feeder of completion list
* @author teramako <teramako@gmail.com>
*/
mappings.add([modes.COMMAND_LINE], ["<C-f>"], "Down page of completions",
function () { pagingCompletion(options.maxitems); });
mappings.add([modes.COMMAND_LINE], ["<C-b>"], "Up page of completions",
@teramako
teramako / tabopen.js
Created April 24, 2013 11:03
現タブが about:blank や about:newtab だったら、:tabopen でも現タブに開くモンキーパッチ
commands.get("tabopen").action = function (args) {
let special = args.bang;
args = args.string;
if (options.get("activate").has("all", "tabopen"))
special = !special;
let where = special ? liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB;
if (buffer.URL === "about:blank" ||
@teramako
teramako / chperm_maker.pl
Last active December 16, 2015 12:08
やっつけコード。与えられたファイルリストから chmod, chown をするコードを吐き出す。
#!/usr/bin/perl
=head1 chperm_maker.pl
与えられたファイルリストのパーミッションを
変更するスクリプトを生成する
=head1 例
$ find . -exec ls -d {} + | perl <this script path>
@teramako
teramako / promise.js
Last active December 16, 2015 11:18
テキトウに Promise 実装。WeakMap とか for-of とか、その他 ECMAScript 6th 機能を使っているので、一般には使えないけど。
/*
* @example 1
* Promise.when(
* asyncFunc1(),
* asyncFunc2()
* ).then(
* function done (p1, p2){ console.log("resolved: ", p1.isResolved, p2.isResolved); },
* function reject(p1, p2){ console.log("rejected: ", p2.isRejected, p2.isRejected); }
* );
* function asycFunc1 () {
@teramako
teramako / setPrototypeOf.js
Created March 19, 2013 05:06
Object.setPrototypeOf の作成。Object.prototype.__proto__ が getter/setter として定義されていないと不可。
/**
* @see https://mail.mozilla.org/pipermail/es-discuss/2013-March/029259.html
*
* @name Object.setPrototypeOf
* @function
* @param {Object} aTarget
* @param {Object} aPrototype
*/
(function() {
var protoDesc = Object.getOwnPropertyDescriptor(Object.prototype, "__proto__");