Skip to content

Instantly share code, notes, and snippets.

View fdocr's full-sized avatar
🤓

Fernando Valverde fdocr

🤓
View GitHub Profile
@fdocr
fdocr / postgres_container.sh
Last active October 29, 2018 15:06
Create postgres Docker container & simple management commands
###################
# Docker COMMANDS #
###################
# Create volume for persistance
docker volume create pgdata
# Create the container
docker run --name pg -e POSTGRES_USER=test -e POSTGRES_PASSWORD=test -d -v pgdata:/var/lib/postgresql/data -p 5432:5432 postgres
@fdocr
fdocr / new_rails_app.rb
Last active April 8, 2024 03:35
New Rails app with RSpec
# Terminal
# OLD -> rails new app_name -T --webpack=stimulus --skip-sprockets
rails new app_name -a propshaft --skip-jbuilder -T
cd app/
# OLD -> yarn add bootstrap jquery popper.js
# Basic Gemfile (DOWN BELOW)
# Terminal
@fdocr
fdocr / Common Docker images.md
Last active December 17, 2018 17:47
Common Docker commands & images. Includes Swagger, PostgreSQL & Redis

Common Docker parameters explained

  • -it
    • Execute using "interactive tty", i.e. execute the command and hold the session until the command ends (with possible keyboard input).
  • -p 8080:3000
    • Bind the port 3000 from the container to the local network interface on port 8080. The port that is closer to the container image name (see below) is the one that refers to the container port, the other one refers to the local network port.
  • -d
    • Run the container as daemon (instead of interactively with -it).
  • -v /opt/postgres/data:/var/lib/postgresql/data
    • Attach a local volume to a container for data persistance. Follow the same logic as with the ports to know which one refers to the container and which one to the local filesystem.
@fdocr
fdocr / Setting up WiFi dongle on Raspberry Pi.md
Created November 8, 2018 15:46
Setting up WiFi dongle on Raspberry Pi
  1. Check for the WiFi dongle (making sure it's available) with dmesg | more

  2. Edit /etc/network/interfaces

auto lo
iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
```
heroku restart -a APP_NAME
heroku pg:reset -a APP_NAME DATABASE --confirm=APP_NAME
heroku run rake db:migrate -a APP_NAME
heroku run rake db:seed -a APP_NAME
```
One liner:
`heroku restart -a APP_NAME; heroku pg:reset -a APP_NAME DATABASE --confirm=APP_NAME; heroku run rake db:migrate -a APP_NAME; heroku run rake db:seed -a APP_NAME`
heroku restart -a APP_NAME
heroku pg:reset -a APP_NAME DATABASE --confirm=APP_NAME
heroku run rake db:migrate -a APP_NAME
heroku run rake db:seed -a APP_NAME

One liner:

heroku restart -a APP_NAME; heroku pg:reset -a APP_NAME DATABASE --confirm=APP_NAME; heroku run rake db:migrate -a APP_NAME; heroku run rake db:seed -a APP_NAME

@fdocr
fdocr / heroku_migrations.gist
Last active November 4, 2019 17:16
Ruby on Rails Database management using Rake on Heroku
heroku run DISABLE_DATABASE_ENVIRONMENT_CHECK=1 rake --trace db:schema:load
heroku run rake --trace db:migrate
heroku run rake --trace db:seed
# Find PID of process
lsof -n -i4TCP:3000
kill -9 [PID]
@fdocr
fdocr / rPi Temperature
Created July 26, 2020 03:47
Raspberry Pi parsed Temperature measurement
vcgencmd measure_temp | egrep -o '[0-9]*\.[0-9]*'