Skip to content

Instantly share code, notes, and snippets.

@danielalvarenga
danielalvarenga / script-configure-ubuntu20.04-amd64.sh
Last active April 8, 2024 09:13
Script to consigure new ubuntu instalation
#!/bin/bash
# Author: Daniel Alvarenga Lima
# Ubuntu version supported: 20.04 LTS amd64
# EXECUTE
# sudo chmod +x script-configure-ubuntu18.94-amd64.sh
# ./script-configure-ubuntu20.04-amd64.sh
#INSTRUCTIONS
@danielalvarenga
danielalvarenga / terminal-colors-branch.sh
Last active March 27, 2024 17:34
Show branch in terminal Ubuntu
# Add in ~/.bashrc or ~/.bash_profile
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
RED="\[\033[01;31m\]"
YELLOW="\[\033[01;33m\]"
GREEN="\[\033[01;32m\]"
BLUE="\[\033[01;34m\]"
NO_COLOR="\[\033[00m\]"
@danielalvarenga
danielalvarenga / script-configure-ubuntu18.94-amd64.sh
Created July 17, 2019 23:57
Shell script to configure Ubuntu 18.04.
#!/bin/bash
# Author: Daniel Alvarenga Lima
# Ubuntu version supported: 18.04 LTS 64Bit
# EXECUTE
# sudo chmod +x script-configure-ubuntu18.94-amd64.sh
# ./script-configure-ubuntu18.94-amd64.sh
#INSTRUCTIONS
@danielalvarenga
danielalvarenga / fileline.go
Last active October 3, 2022 15:20
[ Go / Golang ] Get the current file and line in runtime
package fileline
import (
"fmt"
"os"
"runtime"
"strings"
)
//Location returns an absolute path of the caller file and the line number.
@danielalvarenga
danielalvarenga / docker-fast-start-containeres.md
Created May 19, 2022 21:15
Docker fast start containeres

Docker fast start containeres

Start a MySQL DB:

docker run -d --name local-mysql -v mysql:/var/lib/mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql:5.7

Start a PostgresSQL DB:

Golang tests commands

Run tests:

go test

Run verbose tests:

@danielalvarenga
danielalvarenga / puma.rb
Last active October 16, 2021 20:08
Puma config for rails 5 api
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
# More: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#threads
#
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
threads threads_count, threads_count
@danielalvarenga
danielalvarenga / go-os-arch.md
Created October 20, 2020 17:25 — forked from asukakenji/0-go-os-arch.md
Go (Golang) GOOS and GOARCH

Go (Golang) GOOS and GOARCH

All of the following information is based on go version go1.14.7 darwin/amd64.

A list of valid GOOS values

(Bold = supported by go out of the box, ie. without the help of a C compiler, etc.)

  • aix
  • android

mysql2 gem + mariadb + Alpine Linux

tl;dr Use mariadb-dev. In case of Alpine Linux 3.8, 3.9, use mysql2 >= 0.4.10.

Starting with Alpine Linux 3.8 there are basically 2 options to install the mysql2 gem:

1.sh:

@danielalvarenga
danielalvarenga / 01.md
Created April 30, 2020 21:38 — forked from joshmosh/01.md
Using binary UUIDs with Ruby (on Rails) and MySQL

Binary UUIDs are much more efficient in space and lookups compared to VARCHAR or CHAR UUIDs. To better exmplain how they work I have a few examples of raw sql and how that translates in a programming language like Ruby using the UUID tools module. All examples will reference the following database table and schema.

Table name: users

 id          :uuid(16)
 first_name  :string(255)
 last_name :string(255)