Skip to content

Instantly share code, notes, and snippets.

@rwehresmann
rwehresmann / git_commands.md
Last active August 7, 2017 01:58
Git beyound the basics

Stash altearions

  • git stash -u: store all your current changes to check in another time. For instance, you are in branch A and need to go to branch B, but haven't finished the alterations in branch A yet. -u enforces that non tracked files are stashed too.
  • git stash drop: pull away your stashed changes.
  • git stash pop: restore your stashed changes.

Trace alterations and rewind

  • git reflog: show all explicit changes made in your repo.
  • git reflog show [BRANCH]: show all explicit changes made in your branch.

Backup

No server:

  1. Pegue o ID do container mais recente do rodrigoeh/farma_alg_reborn:latest:

sudo docker ps -a

  1. Realize o backup:
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
ruby '2.6.3'
...
class CreateUsers < ActiveRecord::Migration[5.2]
def change
create_table :users do |t|
t.string :auth0_uid, null: false
t.string :email, null: false
t.timestamps
end
end
end
class User < ApplicationRecord
validates_presence_of :auth0_uid, :email
end
...
group :development do
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
# Manage env variables.
gem 'dotenv-rails'
end
...
# Handle JWT with auth0
gem 'knock', '~> 2.0'
# To perform http requests.
gem 'http'
...
Knock.setup do |config|
if Rails.env.test?
config.token_secret_signature_key = -> { Rails.application.credentials.read }
else
config.token_audience = -> { ENV['AUTH0_AUDIENCE'] }
# Auth0 uses RS256.
config.token_signature_algorithm = 'RS256'
# API secret from Auth0.
module Auth0
class Signup
def self.perform(email, password)
HTTP.headers(accept: 'application/json')
.post(
"https://#{ENV['AUTH0_DOMAIN']}/dbconnections/signup",
form: {
client_id: ENV['AUTH0_CLIENT_ID'],
email: email,
password: password,
module Auth0
class Signin
def self.perform(email, password)
ctx = OpenSSL::SSL::SSLContext.new
ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE
HTTP.headers(accept: 'application/json')
.post(
"https://#{ENV['AUTH0_DOMAIN']}/oauth/token",
ssl_context: ctx,