Skip to content

Instantly share code, notes, and snippets.

View diligasi's full-sized avatar
🚀
Always learning...

Diogo de Lima Gama da Silva diligasi

🚀
Always learning...
View GitHub Profile
@diligasi
diligasi / Dockerfile.ci
Created August 7, 2023 19:25 — forked from dja/Dockerfile.ci
Codeship Rails on Jet
# Article for Dockerfile at ADD_URL_FOR_THIS
# We're using the Ruby 2.3.1 base container and extend it
FROM ruby:2.3.1
# We install certain OS packages necessary for running our build
# Node.js needs to be installed for compiling assets
# libpq-dev is necessary for installing the pg gem
# libmysqlclient-dev is necessary for installing the mysql2 gem
RUN apt-get update && \
apt-get install -yq \
@diligasi
diligasi / MAC M1 | M2.md
Last active September 9, 2022 03:54
Fighting the M1-M2 Architecture

Setting up a new Rails development environment on MAC M1/M2

Introduction

Hello buddy, if you are here, it is probably because you have just acquired a new computer equipped with a new chip from Apple, the M1/M2. Know that in addition to being a marvel of modern technology and engineering, this super machine is also capable of keeping you awake with a multitude of crazy, and sometimes inexplicable, problems that will prevent the correct installation of various software.

This guide assumes that the machine has not yet had any systems installed, and all the steps for installing them will be described here in the order in which they were done by me until I was successful in this endeavor.

This guide also assumes that you’re using zsh. If not, replace any references to .zshrc in the steps below with .bash_profile (if you’re using Bash) or the appropriate shell.

require 'csv'
file = "#{Rails.root}/public/user_data.csv"
products = Product.order(:first_name)
headers = ["Product ID", "Name", "Price", "Description"]
CSV.open(file, 'w', write_headers: true, headers: headers) do |writer|
products.each do |product|
@diligasi
diligasi / Dump proccess
Last active October 15, 2019 17:05
Generates a dump file from Heroku database, download it and restore locally
heroku pg:backups capture
heroku pg:backups public-url
curl "http://[url]" > production.dump
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb file.dump
@diligasi
diligasi / Facebook and Devise Token Auth.md
Last active April 17, 2019 04:01
Here you have a really brief HOWTO for the needed setup to authenticate through Facebook on your Rails API using devise_token_auth gem.

Implementation steps

Step #01

First, add the devise token auth gem to your Gemfile and run bundle to install it

Gemfile
gem 'devise_token_auth'
git log --graph --oneline --all
@diligasi
diligasi / Interchanging Heroku app db.sh
Created April 1, 2019 14:21
How to Import/Export a Database from One Heroku App to Another Heroku App
heroku pg:backups:restore production-app-name::b001 DATABASE_URL --app staging-app-name
@diligasi
diligasi / reset_pk_sequence!
Created March 18, 2019 14:16
Reset table sequences to it's max value
ActiveRecord::Base.connection.tables.each do |table_name|
ActiveRecord::Base.connection.reset_pk_sequence!(table_name)
end
@diligasi
diligasi / .tmux.conf
Created March 10, 2019 22:14
My awesome tmux config
# -----------------------------------------------------------------------------
# This config is targeted for tmux 2.1+ and should be placed in ~/.tmux.conf
# Read the "Plugin Manager" section (bottom) before trying to use this config!
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# Change the default prefix key from CTRL+b to CTRL+a
# -----------------------------------------------------------------------------
set -g prefix C-a
bind C-a send-prefix
@diligasi
diligasi / tmux.md
Created February 7, 2019 17:06
A guide for install and/or update tmux on Ubuntu and similar distros

Prepare system for new installation

# Before start, make sure you've killed all old tmux servers that
# could be still running in the background
sudo killall -9 tmux

# Remove any previous installation
sudo apt-get -y remove tmux

Install needed dependences