Skip to content

Instantly share code, notes, and snippets.

View arxdsilva's full-sized avatar
:octocat:
Working from home

Arthur Silva arxdsilva

:octocat:
Working from home
View GitHub Profile
@arxdsilva
arxdsilva / mongoExample.go
Last active November 16, 2016 07:07
MongoDB lib to CRUD Example
// This is a 'lib' that manipulates mongoDB to insert docs with Pokemon's Structure
package main
import (
"fmt"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
@arxdsilva
arxdsilva / Fixes Atom go-find-references.md
Last active September 9, 2016 13:53
Future Reminder (:
go get -u -v github.com/nsf/gocode

go get -u -v github.com/rogpeppe/godef

go get -u -v github.com/golang/lint/golint

go get -u -v github.com/lukehoban/go-outline

go get -u -v sourcegraph.com/sqs/goreturns
@arxdsilva
arxdsilva / tokenGeneratorExample.go
Last active March 22, 2024 06:23
Golang - How to generate a random Token
package main
// https://play.golang.org/p/5VsRVVtyo-J
import (
"crypto/rand"
"fmt"
)
func tokenGenerator() string {
@arxdsilva
arxdsilva / URLvalidatorExample.go
Last active June 24, 2021 09:17
Golang - How to validate URL
import (
"fmt"
"github.com/asaskevich/govalidator"
)
// You can use as well instead of *url.URL a string with your URL, in this case you might drop `u.String()`
// - transformation to string in method call.
func validateURL(u *url.URL) error {
valid := govalidator.IsRequestURL(u.String())
if valid == false {
@arxdsilva
arxdsilva / tsuruEasySetup.md
Last active October 6, 2016 22:26
Tsuru TL;DR

This md is a list of commands to use on terminal after you setup your first Vagrant VM. This is your Copy-Paste easy-steps to start tsuru on a test env. If you want a more advanced setup please visit our documentation!!

 sudo apt-get update
 sudo apt-get install python-software-properties
 sudo apt-add-repository ppa:tsuru/ppa -y
 sudo apt-get update
 sudo apt-get install tsuru-server -qqy
@arxdsilva
arxdsilva / comparer.go
Last active August 16, 2017 13:31
Comparing elements of two string slices in golang
// You can test here: https://play.golang.org/p/zTaNla0oXJ
package main
import (
"fmt"
)
func main() {
x := []string{"a","b","c"}
y := []string{"c", "d"}
@arxdsilva
arxdsilva / working_directory.go
Last active February 12, 2024 13:30
How to get the current working directory in golang
package main
// More info on Getwd()
// https://golang.org/src/os/getwd.go
//
import(
"os"
"fmt"
"log"
)
@arxdsilva
arxdsilva / embed-video-and-chat.md
Created December 14, 2016 16:28
Embedding Twitch LiveStream and chat

##Parameters: Channel: the target live streamer you want to use; height: in pixels the height you want the video to be; width: in pixels the width you want the video to be.

##Video Code:

<iframe src="http://player.twitch.tv/?channel={CHANNEL}" allowfullscreen height="X" width="Y" *class="col-md-12">
</iframe>
@arxdsilva
arxdsilva / recursiveGlob.go
Created February 15, 2017 13:01
Recursive glob in Go
func RecursiveGlob(dirPath string, pattern string) ([]string, error) {
old, err := os.Getwd()
if err != nil {
return nil, err
}
defer os.Chdir(old)
err = os.Chdir(dirPath)
if err != nil {
return nil, err
}
@arxdsilva
arxdsilva / fedora-nvidia-driver-install.md
Last active March 1, 2017 03:01
Installing nvidia drivers on Fedora25

1.Update software & reboot

$ dnf update -y
$ reboot

2.Installing dependencies

$ dnf install kernel-devel-$(uname -r) gcc dkms

3.Add 'nouveau' to the blacklist, install vim to edit 'Grub'