Skip to content

Instantly share code, notes, and snippets.

View Kuniwak's full-sized avatar
💭
I may be slow to respond.

Yuki Kokubun Kuniwak

💭
I may be slow to respond.
View GitHub Profile
@Kuniwak
Kuniwak / test_typedef.js
Created June 21, 2013 15:10
typedefタグのテスト。
/**
* @typedef {string}
*/
var ng = false;
/**
* @type {string}
*/
var ok = true;
@Kuniwak
Kuniwak / test_typedef.js
Created June 22, 2013 07:22
type式のテスト。
/**
* @typedef {{type:string,target:object,bubbles:boolean=}}
*/
var ng = {type:'string',target:{},bubbles:true};
/**
* @type {{type:string,target:object,bubbles:boolean=}}
*/
var ok = {type:'string',target:{},bubbles:true};
@Kuniwak
Kuniwak / join.js
Created June 22, 2013 15:56
Promiseパターンを使ったファイル処理のテスト。 引数の受け渡しと取り扱いが見えにくいのはPromiseパターンの欠点かな。
var fs = require('fs');
var path = require('path');
var promise = require('node-promise');
var fsp = require('node-promise/fs-promise');
const TEXT_DIR_PATH = path.resolve(__dirname, 'texts');
const OUTPUT_FILE_PATH = path.resolve(__dirname, 'output.txt');
var texts = [];
@Kuniwak
Kuniwak / promise_sample.js
Created July 1, 2013 11:44
Promiseのサンプルコード。
// kriszyp/node-promiseを使うので、スクリプトのある場所で下のコマンドを実行してくだし。
// $ npm install node-promise
var Promise = require('node-promise').Promise;
getAccessToken().then(function(token) {
return getImage(token);
}).then(function(image) {
// Processing image
console.log(image);
});
@Kuniwak
Kuniwak / Promises_A_plus_JP.markdown
Last active December 19, 2015 05:19
JavaScript でスマートに非同期なコードを書くための Promise パターンの仕様(改良版)の邦訳です。

JavaScript でスマートに非同期なコードを書くための Promise パターンの仕様のうち、thenメソッドに関する仕様であるPromises/A+の邦訳です。 お約束の文言ですが、この翻訳は間違ってるかもしれません。ご指摘・ご質問は大歓迎です。

原文(英語)


Promise/A+

この提言はPromises/A 仕様の提言の振る舞いを明確にし、かつ事実上の標準をカバーしつつ曖昧・問題のある部分を除いたものである。

@Kuniwak
Kuniwak / jquery_plugin.js
Last active December 21, 2015 08:59
Jsdoc3でjQueryプラグインをアノテーションする。
(function($) {
/**
* @constructor
* @alias Foo
*/
var Foo = function() {
};
/**

Pull Requestの手順書

  1. Forkする
  2. git clone https://github.com/foo/bar.git
  3. git checkout -b hogeSpike
  4. commitする
  • 先頭行は80文字以内
  • 先頭行の頭文字は小文字
  • 先頭行のピリオドは省く
    • 修正した問題点、修正の妥当性を本文に含める
@Kuniwak
Kuniwak / 2013_10_26_nodefest.markdown
Last active December 28, 2015 13:09
東京Node学園祭2013のノート。 http://nodefest.jp/2013/
@Kuniwak
Kuniwak / js_operation_priotity_table.js
Last active December 28, 2015 16:59
JavaScriptの優先順位のチートシート。CodeGolf用。
// | 優先順位 | 演算子の種類 | 結合性 | 各演算子 |
// |:--------:|:----------------:|:--------:|:----------:|
// | 1 | メンバ | 左から右 | . |
// | | | | [] |
// | | new | 右から左 | new |
// | 2 | 関数呼び出し | 左から右 | () |
// | 3 | インクリメント | n/a | ++ |
// | | デクリメント | n/a | -- |
// | 4 | 論理 NOT | 右から左 | ! |
// | | ビットごとの NOT | 右から左 | ~ |
@Kuniwak
Kuniwak / vim_orgachem_profile.txt
Last active December 29, 2015 06:39
vim-splash で表示する用のプロフィールAA。【推奨環境】background=dark guifont=SourceCodePro-Regular
.?????,
??????? ,???:,
:?????????????:
?????????????`
??????????`
_,,,,,,,,,_ ??????`
,.:"'``` ```'":., ?'`
,:`` _,o###8888888###o,_ ``:,
,:` _qEE8888888888888888888EEp_ `:,
,:` ,EEEEEEEEEEEEEEEEEEEEEEEEEEEEE, `:,