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
# XXXXXXの部分を書き換えて以下のコマンドを実行して下さい。 | |
# source .env | |
export PIXIV_LOGIN_ID=XXXXXXXX | |
export PIXIV_LOGIN_PASS=XXXXXXX |
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
# 分かりやすく | |
blog = Blog.first | |
article_counts = blog.categories.map { |category| category.articles.count } | |
article_total = article_counts_counts.sum | |
# joinsを使う | |
article_total = Blog.joins(categories: :articles).where(id: 1).count | |
# 別パターン | |
blog = Blog.first | |
article_total = blog.categories.joins(:articles).count |
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
cat log/production.log \ | |
| cut -d ' ' -f2 | awk '{print substr($0, 2, 10)}' \ | |
| grep -v '^\s*$' \ | |
| grep -E '[0-9]{4}-[0-9]{2}-[0-9]{2}' \ | |
| uniq | |
# => | |
# 2016-01-09 | |
# 2016-01-08 | |
# 2016-01-09 |
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
/* | |
下記のindex.htmlのようにスライドを設定した時の変数の中身です。 | |
impress.jsでは、各スライドの要素は、stepsとstepsDataという配列で管理されています。 | |
stepsは、stepクラスを持つDOM要素の配列です。 | |
stepsから、stepsDataを作ります。 | |
*/ | |
// steps 各スライドのDOM要素を管理 | |
[div#step-1.step.slide.future.active, div#step-2.step.slide.future, div#step-3.step.slide.future] |
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
// 全体図が分かるように、initに関係するものだけ抜き取りました。 | |
(function ( document, window ) { | |
'use strict'; | |
// data of all presentation steps | |
var stepsData = {}; | |
// rootには<div id="impress">のDOMツリーが入っています。 | |
var roots = {}; | |
var defaults = { |
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
// console.logのエイリアス | |
var l = function(x) { console.log(x) }; | |
// ラップすることによって、自作のオブジェクトからUndersocre.jsのメソッドを使えるようになります。 | |
numbers_array = [5, 2, 1, 5]; | |
_numbers = _([5, 2, 1, 5]); | |
// ラップしていないオブジェクトを、引数で渡します。 | |
l(_.sortBy(numbers_array)); // [1, 2, 5, 5] |
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
// console.logのエイリアス | |
var l = function(x) { console.log(x); }; | |
prototypeOfConstructor = null | |
function People(name) { | |
this.name = name; | |
prototypeOfConstructor = this.prototype; | |
} |
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
// mixinの挙動をコメントで記したものです。 | |
var people = [{name: 'mike', age: 18}, {name: 'jane', age: 21}, {name: 'lake', age: 32}]; | |
var sortedPeople = _.chain(people) | |
.sortBy(function(poeple){ return people.age; }) | |
.first() | |
.value(); | |
// 下記は、上記のコードを実行した場合のコメントです。 | |
// sortByのところでステップインした時のものです。 |
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 Person(name) { | |
this.name = name; | |
} | |
Person.prototype.getHelloString = function(toName, greet) { | |
this.name + ":" + toName + "さん!" + greet; | |
} | |
tanaka = new Person("田中"); |
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
// console.logのエイリアス | |
var l = function(x) { console.log(x) }; | |
function Person(name) { | |
l(this); | |
this.name = name | |
} | |
Person("田中"); // Window | |
l(name); // 田中 |
NewerOlder