Ember's official documentation describes a number of low-level APIs, but doesn't talk much about how to put them together. As a result, a simple task such as creating a simple CRUD application is not obvious to a newcomer.
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 Ember from 'ember'; | |
export default Ember.Component.extend({ | |
tagName: "section", | |
page: 1, | |
paginateBy: 10, | |
paginatedItems: Ember.computed('amenities', 'page', function(){ | |
var i = (parseInt(this.get('page')) - 1) * parseInt(this.get('paginateBy')); | |
var j = i + parseInt(this.get('paginateBy')); | |
return this.get('items').slice(i, j); |
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
# start a server on Digital Ocean | |
# https://docs.docker.com/machine/drivers/digital-ocean/ | |
docker-machine create \ | |
--driver digitalocean \ | |
--digitalocean-access-token <YOUR API KEY> \ | |
--digitalocean-size 2gb \ | |
reaction | |
# tell Docker to run commands on that server |
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 Ember from 'ember'; | |
export default Ember.Component.extend({ | |
resetToken: null | |
}); |
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
module RequestMacros | |
def login_user(user = nil) | |
user = create(:user, password: 'password') unless user | |
# ensure password is valid when `user` is provided | |
expect(user.valid_password?('password')).to be(true) | |
# ensure user is confirmed | |
user.confirm! |
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
module ActiveRecord | |
module Querying | |
delegate :or, :to => :all | |
end | |
end | |
module ActiveRecord | |
module QueryMethods | |
# OrChain objects act as placeholder for queries in which #or does not have any parameter. | |
# In this case, #or must be chained with any other relation method to return a new relation. |
hipchat-notify用の設定。werckerのApplication Settings (右上の歯車アイコン) → Environment variables から、HIPCHAT_TOKEN
とHIPCHAT_ROOM_ID
を追加する。
- HIPCHAT_TOKEN
- Text, Protected
- https://www.hipchat.com/account/api で作ったAPIトークンを設定
- Label: てきとう
Basically, if you prefer to use DATABASE_URL in your application better than creating the whole database.yml thing, set the following ENV variable in your wercker app settings:
- APP_POSTGRES_PASSWORD (required)
- APP_POSTGRES_USER (optional)
- APP_POSTGRES_DB (optional)
- DATABASE_URL (value below)
name: DATABASE_URL
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
// Implementation in ES6 | |
function pagination(c, m) { | |
var current = c, | |
last = m, | |
delta = 2, | |
left = current - delta, | |
right = current + delta + 1, | |
range = [], | |
rangeWithDots = [], | |
l; |