Skip to content

Instantly share code, notes, and snippets.

View brunoocasali's full-sized avatar

Bruno Casali brunoocasali

View GitHub Profile
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);
@jshimko
jshimko / docker-ssl-deployment.sh
Last active February 25, 2022 10:11
Deploy Reaction Commerce on Digital Ocean with Nginx and a Let's Encrypt SSL certificate
# 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
@pablobm
pablobm / README.md
Last active June 3, 2022 10:07
A clear convention for a CRUD with standard Ember + Ember Data

CRUD with Ember (+ Data)

Compatible with Ember 1.13.0+ Compatible with Ember Data 1.13.0+

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.

@NullVoxPopuli
NullVoxPopuli / components.my-component.js
Last active November 7, 2018 14:44 — forked from chrism/controllers.application.js
Testing Query Parameter Binding
import Ember from 'ember';
export default Ember.Component.extend({
resetToken: null
});
@Rodrigora
Rodrigora / request_macros.rb
Created September 19, 2015 21:50
Helper for requests specs with authenticity token
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!
@craigweston
craigweston / or_scopes.rb
Last active March 26, 2020 23:22 — forked from j-mcnally/or_scopes.rb
OR'ing scopes
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.
@francois-blanchard
francois-blanchard / error_capistrano_deploy_could_not_parse_object.md
Last active January 13, 2021 10:05
Error Capistrano deploy - fatal: Could not parse object 'xx...xx'

Error Capistrano deploy - fatal: Could not parse object 'xx...xx'

  1. Connect you to your server $ ssh user@myserver
  2. Go to your deploy path and select the shared directorycd /your/directory/deploy/shared
  3. Remove the git cache rm -rf cached-copy
  4. Retry to deploy & have fun ;)
@tarot
tarot / Readme.md
Last active February 28, 2018 13:21
rails, postgres, redis, hipchat-notify, heroku-deployなwercker.yml

Werckerの設定

Environment variables

hipchat-notify用の設定。werckerのApplication Settings (右上の歯車アイコン) → Environment variables から、HIPCHAT_TOKENHIPCHAT_ROOM_IDを追加する。

@selaromi
selaromi / rails-postgres-wercker-database_url.md
Last active June 26, 2017 08:27
wercker.yml for Rails with Postgresql and DATABASE_URL (docker stack)

RAILS & POSTGRES WITH WERCKER AND DATABASE_URL

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

@kottenator
kottenator / simple-pagination.js
Created July 13, 2015 20:44
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;