Skip to content

Instantly share code, notes, and snippets.

View dedemenezes's full-sized avatar

André Menezes dedemenezes

View GitHub Profile
puts 'Welcome to Chritmas Gift List'
user_input = nil
gift_list = [{ name: 'Laptop', status: false }, { name: 'Flamengo Shirt', status: false }]
# indexes 0 1
while user_input != 'quit'
# 1. Give the user a new option (MARK)
puts 'Which action [list|add|delete|mark|quit]?'
# RECAP!
# Data type
# String
"Le Wagon"
# Integer
12
# Float
12.2
git init
-> start using git in a new project folder
git status
-> check which files have been changed
git add filename
git commit --message "your message" || git commit -m "your message"
-> create a commit (save point)
# 1. Define alphabet array
# 2. Split string into array of letters
# 3. Iterate over letters array
# For each letter
# 4. Shift letter three letter behind in the alphabet
# 4.1 Identify the letter index in the alphabet
# 4.2 Subtract 3 from index
# 4.3 Access new alphabet letter
# 6. Join shifted letters array into string

Git Cheatsheet ;)

  • git init -> starts tracking your folder with git
  • git status -> checks what files have been changed
  • git add filename -> stage the changes
  • git commit --message "a meaningful message"
  • git commit -m "a meaningful message" -> create a "savepoint"
  • git push origin master -> pushes the changes (commits) to github
  • git diff filename -> checks the difference from the last commit
  • git log
import Trix from 'trix';
window.Trix = Trix; // Don't need to bind to the window, but useful for debugging.
const { lang } = Trix.config
const initTrix = () => {
console.log("INIT TRIX!");
// Trix.config.blockAttributes.heading1.tagName = 'h3'
Trix.config.toolbar.getDefaultHTML = getDefaultHTML.bind(this)
// this.addForegroundButtonConfig()
import { Controller } from "@hotwired/stimulus"
import Trix from 'trix'
const { lang } = Trix.config
// Connects to data-controller="trix"
export default class extends Controller {
static targets = ['editor']
connect() {
document.addEventListener('trix-before-initialize', () => {
<<~SQL
SELECT * FROM books
WHERE publishing_year < 1985
SQL
<<~SQL
SELECT * FROM books
JOIN authors ON authors.id = books.author_id
WHERE authors.name = "Jules Verne"
ORDER BY books.publishing_year DESC
SELECT * FROM books
WHERE publishing_year < 1985
SELECT * FROM books
JOIN authors ON authors.id = books.author_id
WHERE authors.name = "Jules Verne"
ORDER BY books.publishing_year DESC
LIMIT 3
class CreateAuthors < ActiveRecord::Migration[7.0]

Full MVC Rails app

Model(s)

  • Model -> singular, eg: 'car' , 'child'
  • table -> plural, eg: 'cars', 'children'

Which columns/attributes should we add to our table? After give it a thought ⤵️

rails g model :ModelName : : ...