Skip to content

Instantly share code, notes, and snippets.

View varmil's full-sized avatar
🏠
Working from home

Akihiro Yamamoto varmil

🏠
Working from home
View GitHub Profile
@varmil
varmil / 0_reuse_code.js
Created July 26, 2014 09:49
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@varmil
varmil / default.vcl
Last active August 29, 2015 14:06
Varnish ESIを使うSample。並びに、Varnish設定ファイル
sub vcl_recv {
if (req.request == "POST") {
ban("req.url ~ /");
return (pipe); # pipe is faster than pass
} else if (req.request != "GET") {
return (pipe);
} else {
return (lookup);
}
}

hogeクラスをつくるとき

1

// プロパティ
var hoge = function(arg) {
  this.x = 5;
  this.y = 10;
  this.z = arg;
};
@varmil
varmil / parallel.js
Last active August 29, 2015 14:09
今さら聞けないjQuery.Deferred入門 ref: http://qiita.com/varmil/items/269496d3be071a297d76
// titleとcomment両方が取れるまでPUTを待つ
var title, comment;
var titleDeferred = (function() {
var dInner = new $.Deferred();
self.trigger('getTitle', todo, function(res) {
title = res;
dInner.resolve();
});
return dInner.promise();
@varmil
varmil / file0.txt
Last active August 9, 2016 13:56
【javascript】やさしいクラスの作り方 ref: http://qiita.com/varmil/items/99fd6f2a886fdde4b7fa
// constructor
var hoge = function(arg) {
this.x = 5;
this.y = 10;
this.z = arg;
};
// メソッド
hoge.prototype = {
f1: function() {
@varmil
varmil / error
Last active August 29, 2015 14:10
【Flow】グローバル変数エラー(Unknown global name)を黙らせる ref: http://qiita.com/varmil/items/24aea65e8f6ea1d2a237
logic.js: identifier _ Unknown global name
@varmil
varmil / .bash_profile
Last active June 9, 2019 23:36
「Git補完をしらない」「git statusを1日100回は使う」そんなあなたに朗報【git-completionとgit-prompt】 ref: https://qiita.com/varmil/items/9b0aeafa85975474e9b6
# スクリプト読み込み
source $HOME/.git-completion.bash
source $HOME/.git-prompt.sh
# プロンプトに各種情報を表示
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWUPSTREAM=1
GIT_PS1_SHOWUNTRACKEDFILES=
GIT_PS1_SHOWSTASHSTATE=1
@varmil
varmil / after
Last active August 29, 2015 14:11
昔作ったゲームをJSっぽくリファクタリングした結果【tmlib.js】 ref: http://qiita.com/varmil/items/a01101bb7570bc8c38fd
tm.define("GameScene", {
superClass: "tm.app.Scene",
level: 0, // ゲームレベル(初回0。徐々に上がる)
init: function() {
.....
window.player = Player().addChildTo(this);
player.playerIcon.on('collision', function() {
player.playerIcon.off('collision');
self.timer.off('levelUp');
@varmil
varmil / example.js
Last active August 29, 2015 14:12
今すぐJadeを最新版にして、selfオプションを有効にすればレスポンスが8倍早くなる(かも)【Node.js】 ref: http://qiita.com/varmil/items/887ff9c5e1f9a6a1e24e
res.render('watch', {
id: 777,
self: true
});
@varmil
varmil / file0.js
Last active August 29, 2015 14:13
最速Template EngineのECTは本当に速かった。レスポンスを60倍早くした話【Node.js】 ref: http://qiita.com/varmil/items/d3482418df96197f9f08
Rendering 100000 templates:
ECT
Escaped : 2180ms
Unescaped : 133ms
Total : 2313ms
EJS without `with`
Escaped : 4526ms
Unescaped : 485ms