このGistは以下のリポジトリへ移動されました。
以後、ここは更新されません。
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
var account = { | |
'email': '', | |
'password': '' | |
}; | |
var bridgeid = ''; | |
var initializeParameter = { | |
'devicetype' : 'GAS', | |
'username' : 'newdeveloper' | |
}; |
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
// 銀行口座 | |
var BankAccount = function (balance) { this.balance = balance; }; | |
BankAccount.prototype.increase = function (money) { this.balance += money; }; | |
BankAccount.prototype.decrease = function (money) { this.balance -= money; }; | |
// ロール: 送信側 | |
var Sender = function () {}; | |
Sender.prototype.send = function (money, to) { | |
this.decrease(money); | |
to.onReceived(money, this); |
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
trait Node { | |
val number: Int | |
def max: Int = this.number | |
def min: Int = this.number | |
def sum: Int = this.number | |
def avg: List[Int] = List(this.number) | |
def find(e: Int): Option[Node] = if (this.number == e) Some(this) else None | |
} | |
case class Branch(left: Node, number: Int, right: Node) extends Node { | |
override def max: Int = List(left.max, this.number, right.max).max |
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
import scala.util._ | |
def binarySearch(number: Int, numbers: List[Int]): Try[Int] = { | |
def Y[A,B]( f:((A => B), A ) => B, x:A ):B = f( (y:A) => Y(f,y),x) | |
Success(Y( (f: ((Int, Int)) => (Int, Int), n: (Int, Int)) => { | |
if (n._1 == n._2) return Failure(new NoSuchElementException) | |
((mid: Int) => { | |
((numbers(mid), number) match { | |
case (l, r) if l > r => f(n._1, mid) | |
case (l, r) if l < r => f(mid + 1, n._2) | |
case _ => (mid, -1) |
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
'use strict'; | |
module.exports = function (grunt) { | |
var _ = grunt.util._; | |
var esprima = require('esprima'); | |
var licenseRegExp = /BSD|MIT|License/i; | |
grunt.registerTask('save-license', 'Save the license', function () { | |
this.files.forEach(function (file) { | |
var valid = file.src.filter(grunt.file.exists.bind(grunt.file)); | |
_.difference(file.src, valid).forEach(function (filepath) { |
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
chrome.webRequest.onHeadersReceived.addListener(function (details) { | |
for (var i = 0, l = details.responseHeaders.length; i < l; i++) { | |
var res = details.responseHeaders[i]; | |
if (res.name.toLowerCase() !== 'content-security-policy') | |
continue; | |
res.value = ''; | |
} | |
return { | |
'responseHeaders': details.responseHeaders | |
}; |
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 () { | |
var result = {}; | |
[].slice.apply(arguments).forEach(function (val) { | |
Object.keys(val).forEach(function (key) { | |
result[key] = val[key]; | |
}) | |
}); | |
return result; | |
})({1: 2}, {3: 4}); | |
// Object {1: 2, 3: 4} |
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
head = [ | |
'HTTP/1.1 200 OK', | |
'Connection: close', | |
'Content-Length: 1', | |
'Content-Type: text/plain', | |
'Cache-control: private' | |
].join('\r\n'); | |
body='1'; |
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
// Before WebStorm AutoIndent | |
({ | |
'method': function () { | |
} | |
}).method(function () { | |
// hoge | |
}); | |
/* After WebStorm AutoIndent | |
({ | |
'method': function () { |