# ルートディレクトリ
/
# ホームディレクトリ
/Users/shuhei
This file contains hidden or 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
# Paste this to Rails console. | |
def get_inner(app, middlewares) | |
middlewares << app.to_s | |
if inner = app.instance_variable_get(:@app) | |
get_inner(inner, middlewares) | |
end | |
end | |
def collect_middlewares(app) |
This file contains hidden or 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
require 'mechanize' | |
require 'date' | |
def nap | |
sleep(3 + rand(10) / 10) | |
end | |
def org_list_item(org, i) | |
"#{i + 1}. [#{org[:name]}](#{org[:link]}): #{org[:posts]} posts, #{org[:stocks]} stocks" | |
end |
This file contains hidden or 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 data = [ | |
['Prefecture', 'A', 'B', 'C'], | |
['Tokyo', '1', '2', '3'], | |
['Kanagawa', '4', '5', '6'] | |
]; | |
var labels = data[0]; | |
var dataSet = data.slice(1).reduce(function(acc, row) { | |
var item = {}; | |
item[labels[0]] = row[0]; |
This file contains hidden or 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
// Create an Array from an Array-like Object such as NodeList. | |
function toArray(arrayLike) { | |
return Array.prototype.slice.call(arrayLike); | |
} | |
// Create an Object from an Array of objects. | |
function toObject(objects, keyName, valueName) { | |
return objects.reduce(function(acc, obj) { | |
acc[obj[keyName]] = obj[valueName]; | |
return acc; |
This file contains hidden or 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 colike(genFunc) { | |
var gen = genFunc(); | |
var thunk = gen.next().value; | |
function done() { | |
// We don't know the number of arguments. | |
var err = arguments[0]; | |
var values = Array.prototype.slice.call(arguments, 1); | |
if (err) { |
gulp uses orchestrator to run tasks. orchestrator ignores error events of stream that task function returns. robrich/orchestrator#46
The author says that it is because the inconsistent implementations of gulp plugin streams. Some streams emit error event and emits end event later.
Where to put models in Angular?
- http://stackoverflow.com/questions/11112608/angularjs-where-to-put-model-data-and-behaviour
- http://stackoverflow.com/questions/16607874/where-should-model-state-be-stored-in-angular-js
If Backbone, Backbone Relational's global model store seems to be a good idea.