Skip to content

Instantly share code, notes, and snippets.

danielalvarenga / fileline.go
Last active October 3, 2022 15:20
[ Go / Golang ] Get the current file and line in runtime
package fileline
import (
//Location returns an absolute path of the caller file and the line number.
danielalvarenga /
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 /
Created October 20, 2020 17:25 — forked from asukakenji/
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:

danielalvarenga /
Last active April 8, 2024 09:13
Script to consigure new ubuntu instalation
# Author: Daniel Alvarenga Lima
# Ubuntu version supported: 20.04 LTS amd64
# sudo chmod +x
# ./
danielalvarenga /
Created April 30, 2020 21:38 — forked from joshmosh/
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)
danielalvarenga / gist:129babb555c45a7ec5b772b7b4543482
Created October 1, 2019 19:36 — forked from barelyknown/gist:3692433
Send Email From Rails Console
# Simple approach to sending email from the Rails console
# Implementation idea courtesy of Steve Klabnik
# Create the mailer class with a block and assign to a variable
mailer = do
def example_message
mail(to: "", from: "", subject: "Example Message") do |format|
format.text { render text: "Example message body" }
danielalvarenga /
Created September 30, 2019 18:23 — forked from ziadoz/
Install Chrome, ChromeDriver and Selenium on Ubuntu 16.04
#!/usr/bin/env bash
# Versions
#!/usr/bin/env ruby
require 'benchmark'
MAX = 100000
results = {}
def if_return(attempt)
if attempt == 'primeira'
return 'primeira'