- User model
rails g model user username:string password_hash:string
- user_id foreign key in tables (user has many cars)
generate a migration
rails generate migration addUserId
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.
TRUNCATE TABLE songs CASCADE; | |
TRUNCATE TABLE artists CASCADE; | |
ALTER SEQUENCE songs_id_seq RESTART WITH 1; | |
ALTER SEQUENCE artists_id_seq RESTART WITH 1; | |
INSERT INTO artists (name, photo_url, nationality) VALUES ('Weird Al Yankovich', 'http://i.huffpost.com/gen/1952378/images/o-WEIRD-AL-facebook.jpg', 'American'); | |
INSERT INTO songs (title, album, preview_url, artist_id) VALUES ('White & Nerdy (Parody of "Ridin"")', 'Straight Outta Lynwood', 'http://a1748.phobos.apple.com/us/r1000/062/Music/ce/3d/70/mzm.hmiurdzp.aac.p.m4a', 1); | |
INSERT INTO songs (title, album, preview_url, artist_id) VALUES ('Ebay (Parody of "I Want It That Way" By the Backstreet Boys)', 'Poodle Hat', 'http://a920.phobos.apple.com/us/r1000/160/Music5/v4/17/ef/0b/17ef0bd4-2428-71ac-f1c4-2abf7eff7d9e/mzaf_5868025817010222762.plus.aac.p.m4a', 1); | |
INSERT INTO songs (title, album, preview_url, artist_id) VALUES ('Canadian Idiot (Parody of "American Idiot" By Green Day)', 'Straight Outta Lynwood', 'http://a699.phobos.apple.com/us/r1000/079/Music/a9/ |
var opts = { | |
retries: 10, | |
factor: 2, | |
minTimeout: 1 * 1000, | |
maxTimeout: Infinity, | |
}; | |
{ | |
"editor.formatOnSave": true, | |
"editor.formatOnPaste": true, | |
"eslint.codeAction.showDocumentation": { | |
"enable": true | |
}, | |
"eslint.format.enable": true, | |
"eslint.lintTask.enable": true, | |
"eslint.migration.2_x": "off" |
["โ","๐","๐","๐","๐ฑ","๐","๐","๐ป","๐ฅ","๐","โ","๐","๐น","๐","๐","โฝ","๐พ","๐","๐ก","๐ฟ","๐ป","๐ถ","๐ฌ","๐","๐","๐","๐","๐","๐","๐","๐","โค","๐","๐","๐","๐ณ","๐ช","๐ฉ","๐ธ","๐","๐","๐","๐","๐บ","๐ถ","๐ ","๐","โพ","๐","๐ฝ","๐","๐ต","๐ฎ","๐ฉ","๐","๐ฃ","๐","๐","๐","๐","๐","๐","๐","๐","๐","๐ต","๐","๐","๐ฝ","๐","๐","๐","๐","๐","โ","๐","โต","๐","๐ฑ","๐ฐ","๐ถ","๐ธ","๐ฐ","๐ท","๐","๐ซ","๐ซ","๐","๐ฒ","๐","๐","๐"] |
import path from 'path'; | |
import { readdirSync, statSync } from 'fs'; | |
function recFindByExt(base,ext,files,result) | |
{ | |
files = files || readdirSync(base) | |
result = result || [] | |
files.forEach( | |
function (file) { |
Magic words:
psql -U postgres
Some interesting flags (to see all, use -h
or --help
depending on your psql version):
-E
: will describe the underlaying queries of the \
commands (cool for learning!)-l
: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS){ | |
"editor.defaultFormatter": "esbenp.prettier-vscode", | |
"editor.formatOnSave": true, | |
"editor.formatOnPaste": true, | |
"editor.minimap.enabled": false, | |
"editor.tabSize": 2, | |
"editor.wordWrap": "on", | |
"eslint.format.enable": true, | |
"eslint.lintTask.enable": true, | |
"eslint.migration.2_x": "off" |