Skip to content

Instantly share code, notes, and snippets.

View pedryvo's full-sized avatar
🏠
Working from home

Pedro Ivo Dias pedryvo

🏠
Working from home
  • Brasil
View GitHub Profile
@pedryvo
pedryvo / README.md
Created April 29, 2023 01:46 — forked from equivalent/README.md
Rails 7 importmaps dropzone.js direct upload ActiveStorage

This is simple implementation of technologies in hobby project of mine built in Rails7 where I need direct upload to S3.

class BlogEntity < ApplicationRecord
belongs_to :city
def posts
Post.where(blog_entity_id: self.id).order_by({created_at: -1})
end
def there_is_a_post_with_url(url)
Post.where(url: url).exists?
end
@pedryvo
pedryvo / docker_rails.txt
Created May 7, 2020 18:36
Postgres container for Rails app
docker run --name postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_USER=postgres -p 5432:5432 -d postgres
-------------------
development:
<<: &default
adapter: postgresql
encoding: unicode
database: anything_development
username: postgres
# List all models
ActiveRecord::Base.connection.tables.map do |model|
model.capitalize.singularize.camelize
end
# Get all associations of a model
User.reflect_on_all_associations
@pedryvo
pedryvo / rails http status codes
Created December 1, 2019 06:40 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@pedryvo
pedryvo / extractscript.sh
Created November 19, 2019 22:58
Script to extract file to subfolder with its name
#!/bin/sh
# Extract the archive $1 to a directory $2 with the program $3. If the
# archive contains a single top-level directory, that directory
# becomes $2. Otherwise $2 contains all the files at the root of the
# archive.
extract () (
set -e
archive=$1
case "$archive" in
@pedryvo
pedryvo / paginator.txt
Created July 24, 2019 18:21
Vue paginator
Ha uma chamada para a API direto na renderizacao do componente.
<vpaginator ref="paginator" :options="$defaultPaginatorConfig" resource_url="/atlas/planejamentos" @update="updateResource"></vpaginator>
---------------------------
O script esta assim:
<script>
@pedryvo
pedryvo / portfoliotext
Created June 17, 2019 14:34 — forked from josno/portfoliotext
Portfolio Bio Text & Wireframe
Headline:
"I’m a full-stack software engineer with a focus on education."
Bio:
"I’m a full-stack software engineer with a focus on education. In my past life, I was a digital media strategist and an international English teacher. From products to interactions, I live for creating joyful experiences and thrive in learning something new. You can say my continued passion for technology and learning led me here.
I see problems as opportunities to create and programming as my toolbox. You can often see me wondering out loud about developing better efficiencies on whatever project I am working on. If you are not planning on contacting me about my portfolio, I am also a certified wine taster so we can talk about that too.
@pedryvo
pedryvo / snippets-docker-rails.txt
Last active June 16, 2019 21:14
Snippets to Dockerize Rails App
mkdir nameOfProject
cd nameOfProject
docker run --rm --user "$(id -u):$(id -g)" -v $(pwd):/usr/src -w /usr/src -ti ruby:latest bash
gem install rails
rails new . --database=postgresql --skip-bundle
--------------------- Dockerfile ----------------------
FROM ruby:latest