Skip to content

Instantly share code, notes, and snippets.

View henvic's full-sized avatar

Henrique Vicente henvic

View GitHub Profile
@henvic
henvic / bash
Last active April 12, 2017 16:52
Weird timezone issue
# changing my timezone on my
# macOS Sierra Version 10.12.4 (16E195)
# see video on https://cl.ly/0o3V1b0o3p0P/timezone-issue.gif
# instead of having timezone = BRT it is showing the current offset to UTC
$ uname -a
Darwin henvic.local 16.5.0 Darwin Kernel Version 16.5.0: Fri Mar 3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64
henvic at henvic in ~/time
$ go run time.go
current: Wed Apr 12 09:32:37 PDT 2017
@henvic
henvic / prompt.go
Created January 3, 2017 21:41
prompt.go
package prompt
import (
"bufio"
"errors"
"fmt"
"io"
"os"
"strconv"
"strings"
@henvic
henvic / time-afterfunc-vs-sleep.go
Created September 17, 2016 06:51
golang question: time.AfterFunc vs. time.Sleep
// golang question: what code is better?
// Scenario: inside a callback you have to take an action - say, send a response - after some time
// How would you accomplish it? Why?
// What if it is test code?
// What if it is production code?
// Would you write the code like this?
mux.HandleFunc("/url", func(w http.ResponseWriter, r *http.Request) {
var e = make(chan struct{}, 1)
time.AfterFunc(800*time.Millisecond, func() {
@henvic
henvic / release.sh
Created September 7, 2016 23:57
example of release.sh for golang project
#!/bin/bash
# CLI tool publishing script
set -euo pipefail
IFS=$'\n\t'
config=${1-}
if [ -z $config ] || [ $config == "help" ] || [ $config == "--help" ]; then
@henvic
henvic / version_pkg
Created July 8, 2016 16:05
WeDeploy CLI version pkg
8WGbGy94JXa
@henvic
henvic / symbolic.sh
Created June 7, 2016 04:43
symbolic.sh
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
if [ `find . -maxdepth 1 -type l -ls | wc -l` -gt 0 ]; then
>&2 echo "Doing nothing. Symbolic links found on directory."
exit 1
fi
@henvic
henvic / goto_example.go
Created April 2, 2016 03:45
goto example in go
package main
import "fmt"
import "strings"
func main() {
var x = "/home/henvic/foo/bar"
var pos int
walk:
@henvic
henvic / update_channel.json
Created January 29, 2016 19:59
Update channel
[
{
"platform": "darwin_amd64",
"version": "0.0.1",
"link": "https://liferay.io/cli/build/launchpad-cli-darwin-v0.0.1"
},
{
"platform": "linux_amd64",
"version": "0.0.2",
"link": "https://liferay.io/cli/build/launchpad-cli-linux-v0.0.2"
@henvic
henvic / random-example.txt
Created November 21, 2015 20:04
Math.random tests
1000000 iterations. Array is reset after first duplicate value.
length: 79775; duplicate: 14631346333771944
length: 45242; duplicate: 16620092559605836
length: 55295; duplicate: 9427159884944558
length: 123993; duplicate: 7038418645970523
length: 15575; duplicate: 8662485890090466
length: 96884; duplicate: 5140431500039995
length: 106546; duplicate: 40411726920865470
length: 54615; duplicate: 9114022604189812
length: 31491; duplicate: 9443272105418146
@henvic
henvic / pig
Created October 1, 2015 02:56
pig
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . ' - ( - ' . _ . . . . _ ........__ . . . _ . . .. __
. . . . . . . ' - ( - ' . . .' . . . . . . . . '. . .| . \ _ / _ |
. . . . . . . . . . ` ' - / . . . . . . . . . . . . \ / . . . . . . \
. . . . . . . . . . . . .|. . . . . . . . . . . . . . ` . . . 6 . 6.|_
. . . . . . . . . . . . .|. . . . . . . . . . . . . . . . . . . . . / .. ..\
. . . . . . . . . . . . . \ . . . . . . .| .. . . . . . . . . . , _\_ _ /
. . . . . . . . . . . . . . / . . . . . / . . . . . /.. . _ _ _ .--'
. . . . . . . . . . . . . < . . . . - ;`- - - -`. .\ . . \ . \
. . . . . . . . . . . . . . \ . . \ . \ . . . . . . . . \ . . \ . \