See how a minor change to your commit message style can make you a better programmer.
Format: <type>(<scope>): <subject>
<scope>
is optional
# Save this in ~/.screenrc | |
# Use bash | |
shell /bin/bash | |
autodetach on | |
# Big scrollback | |
defscrollback 5000 |
You could have postgre installed on localhost with password (or without user or password seted after instalation) but if we are developing we really don't need password, so configuring postgre server without password for all your rails project is usefull.
Sometimes I want to remove a specific key-value pair from a Ruby hash and get the resulting hash back. If you're using Rails or ActiveSupport you can accomplish this using Hash#except
:
hash = { a: 1, b: 2, c: 3 }
hash.except(:a) # => { b: 2, c: 3 }
# note, the original hash is not modified
hash # => { a: 1, b: 2, c: 3 }
# it also works with multiple key-value pairs
# This simple solution open-classes the controller/model in the main app | |
# to add or overwrite methods. | |
# A drawback of this solution is that you won't be able to access the original | |
# method by using +super+. | |
# engine: app/controllers/myengine/my_controller.rb | |
# This is the controller in our engine with a index method defined. | |
module MyEngine | |
class MyController < ApplicationController | |
def index |
# 1) Create your private key (any password will do, we remove it below) | |
$ cd ~/.ssh | |
$ openssl genrsa -des3 -out server.orig.key 2048 | |
# 2) Remove the password | |
$ openssl rsa -in server.orig.key -out server.key |
To get a private GitHub repo to work on Heroku, you can leverage the netrc buildpack in conjunction with the Heroku Ruby buildpack.
When setting up the Gemfile
, make sure to use the https GitHub URL. This mechanism does not work with git+ssh.
gem "some_private_gem", git: "https://github.com/org/some_private_gem.git"
When querying your database in Sequelize, you'll often want data associated with a particular model which isn't in the model's table directly. This data is usually typically associated through join tables (e.g. a 'hasMany' or 'belongsToMany' association), or a foreign key (e.g. a 'hasOne' or 'belongsTo' association).
When you query, you'll receive just the rows you've looked for. With eager loading, you'll also get any associated data. For some reason, I can never remember the proper way to do eager loading when writing my Sequelize queries. I've seen others struggle with the same thing.
Eager loading is confusing because the 'include' that is uses has unfamiliar fields is set in an array rather than just an object.
So let's go through the one query that's worth memorizing to handle your eager loading.