Skip to content

Instantly share code, notes, and snippets.


Henrique Vicente henvic

View GitHub Profile
henvic /
Last active May 27, 2022
Migrating to a new Mac

Here are the steps I took for migrating from a early-2013 MacBook Pro Retina 15-inch to a late-2013 one.

  1. Disconnected from the Internet (at least it will simplify
  2. Updated my TimeMachine (TM) backup ("Back Up Now" on the status bar)
  3. Disconnected my TM hard drive and connected it to the new Mac
  4. Turned off the TM backup and Backblaze from the old machine
  5. Connected the TM backup disk to the new Mac
  6. Selected the TM restore process on the install process, but it never showed up, so I restarted it with the 'option' key down and selected the TM code, entered its password and continued with the installer from there
  7. Waited about 3 hours till the data transfer (about 200GB from a stock external drive) was done
  8. Logged in my account
henvic / middleware.go
Created Nov 22, 2021
httpretty logger middleware
View middleware.go
// HTTPLogger for
// to provide useful debugging info when running:
// $ DEBUG=api go run
func HTTPLogger() func(http.Handler) http.Handler {
if !strings.Contains(os.Getenv("DEBUG"), "api") {
return nil
_, noColor := os.LookupEnv("NO_COLOR") // See
if !noColor {
if fileInfo, _ := os.Stdout.Stat(); (fileInfo.Mode() & os.ModeCharDevice) == 0 {
henvic / pgxinterface.go
Last active Oct 24, 2021
Interface containing a subset of the API from *pgx.Conn and *pgxpool.Pool
View pgxinterface.go
package postgres
import (
henvic / searchtest.go
Created Oct 15, 2021
search test infrastructure with Replica still using testing.TB (to be replaced)
View searchtest.go
// Package searchtest can be used to write integration tests with OpenSearch and search-replica.
// You can set the following environment variables to control logging:
// VERBOSE_OPENSEARCH=true to enable logging of requests and responses made with the OpenSearch client.
// VERBOSE_SEARCH_REPLICA=true to print verbose output from the search-replica process.
// Use If search-replica isn't on your $PATH or to run a different command, you can set the environment variable:
// SEARCH_REPLICA_COMMAND=search-replica
// search-replica works subscribing to a PostgreSQL publication using logical replication.
henvic / factorial-cli.js
Created Dec 21, 2013
Factorial example
View factorial-cli.js
/*jslint node: true */
module.exports = function () {
'use strict';
var math = require('./math'),
if (!process.argv[2]) {
console.log('Use "node factorial-cli.js <number>" to get the factorial');
henvic / .zshrc
Last active Aug 21, 2021
my ~/.zshrc
View .zshrc
# Path to your oh-my-zsh configuration.
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
# Example aliases
View base58.go
func new11RandomID() string {
const (
alphabet = "123456789ABCDEFGHJKLMNPQRSTUWVXYZabcdefghijkmnopqrstuwvxyz" // base58
size = 11
var id = make([]byte, size)
if _, err := rand.Read(id); err != nil {
henvic / description
Last active Aug 12, 2020
picel failure on newer go 1.15
View description
go tests are failing on the latest version of Go.
Still need to investigate. Using -race flag didn't detect any race condition, and this failure is happening with Mutual TLS.
henvic /
Created Jul 17, 2020
market server example
$ ./market
Usage: market <command> [flags] [arguments]
serve run the market server
check-config check and print configuration
users manage users
-config (string) configuration path (default "market.ini")
View .vimrc
set backspace=indent,eol,start
nnoremap <BS> X
if version >= 703
set undofile
set undodir=$HOME/.vim/undo
set undolevels=1000
set undoreload=10000