いつも使っているOSなので。 VPSコントロールパネルのOS再インストールページからOSを選択して手順通りにインストール。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aaaaa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>fileio</title> | |
</head> | |
<body> | |
<input type="file"> | |
<script src="file.js"></script> | |
<script> | |
window.onload = function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Promise | |
@STATE_PENDING = 2 | |
@STATE_RESOLVED = 1 | |
@STATE_REJECTED = 0 | |
constructor: -> | |
@_onResolved = null | |
@_onRejected = null | |
@_next = null | |
@_state = Promise.STATE_PENDING |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parseLTSVLog(text) { | |
return JSON.parse( | |
'[' + | |
text | |
.trim() | |
.replace(/([^\t\n\r:]+):([^\t\n\r]*)/g, function(all, k, v) { | |
return '"' + k + '":' + (v == +v ? v : '"' + v + '"'); | |
}) | |
.replace(/(.+)/g, '{$1}') | |
.replace(/[\t\n]/g, ',') + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// underscore使う。 | |
// サロゲートペアに関しては考慮していない。 | |
function createNgramList(text, n) { | |
var list = []; | |
for (var i = 0; i <= text.length - n; ++i) { | |
list.push(text.slice(i, i + n)); | |
} | |
return _.uniq(list); | |
} |
Mongoose Middleware v3.8.8の補足。 特に保存するときのpre hook。
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
// こんなスキーマがあったとして
var schema = new Schema({
foo: String,
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// アホすぎ | |
function promisify(fn) { | |
return function() { | |
var d = $.Deferred(); | |
try { | |
d.resolve(fn.apply(this, arguments)); | |
} catch (e) { | |
d.reject(e); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# button or input[submit]で使うように | |
angular.module('foo', []).directive 'clickAndDisable', -> | |
link: (scope, element, attr) -> | |
element.on 'click', -> element.attr 'disabled': true |