Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / script-configure-ubuntu20.04-amd64.sh
Last active July 19, 2023 12:02
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 / 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)
@danielalvarenga
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
# http://blog.steveklabnik.com/posts/2012-09-09-random-ruby-tricks--class-new
# Create the mailer class with a block and assign to a variable
mailer = Class.new(ActionMailer::Base) do
def example_message
mail(to: "test@test.com", from: "test@test.com", subject: "Example Message") do |format|
format.text { render text: "Example message body" }
end
@danielalvarenga
danielalvarenga / install.sh
Created September 30, 2019 18:23 — forked from ziadoz/install.sh
Install Chrome, ChromeDriver and Selenium on Ubuntu 16.04
#!/usr/bin/env bash
# https://developers.supportbee.com/blog/setting-up-cucumber-to-run-with-Chrome-on-Linux/
# https://gist.github.com/curtismcmullan/7be1a8c1c841a9d8db2c
# http://stackoverflow.com/questions/10792403/how-do-i-get-chrome-working-with-selenium-using-php-webdriver
# http://stackoverflow.com/questions/26133486/how-to-specify-binary-path-for-remote-chromedriver-in-codeception
# http://stackoverflow.com/questions/40262682/how-to-run-selenium-3-x-with-chrome-driver-through-terminal
# http://askubuntu.com/questions/760085/how-do-you-install-google-chrome-on-ubuntu-16-04
# Versions
CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`
#!/usr/bin/env ruby
require 'benchmark'
MAX = 100000
results = {}
def if_return(attempt)
if attempt == 'primeira'
return 'primeira'