Skip to content

Instantly share code, notes, and snippets.

View lalizita's full-sized avatar

Laís Lima lalizita

View GitHub Profile
@lalizita
lalizita / read_csv.go
Last active March 14, 2022 21:16
Reading a csv file with go lang, csv file is in https://gist.github.com/lalizita/84daf831c49191d226c29e44097ec1f5
package main
import (
"encoding/csv"
"fmt"
"io"
"log"
"os"
)
5+5 10
7+3 10
1+1 2
8+3 11
1+2 3
8+6 14
3+1 4
1+4 5
5+1 6
2+3 5
@lalizita
lalizita / nginx.conf
Last active June 23, 2022 15:32
Simple serverse proxy example using NGINX
# The event key is required for nginx
events{
worker_connections 1024;
}
http {
server {
listen 8080;
# location is the key for your endpoint to access nginx configurarion
# example: curl -v http://localhost:8080/ will access this location
@lalizita
lalizita / nginx.conf
Created June 23, 2022 20:47
Cache config for NGINX
events{
worker_connections 1024;
}
http {
# A shared memory zone to keep cache
proxy_cache_path /etc/nginx/cache keys_zone=mycache:10m;
server {
listen 8080;
events{
worker_connections 1024;
}
http {
# A shared memory zone to keep cache
proxy_cache_path /etc/nginx/cache keys_zone=mycache:10m inactive=10m;
server {
listen 8080;
@lalizita
lalizita / main.go
Last active August 9, 2022 18:56
Quiz with timer in Go
package main
import (
"fmt"
"os"
"time"
)
func timer() {
// Cria um ticker, um relógio que retorna um channel com o tempo atual,
@lalizita
lalizita / main.go
Created August 9, 2022 00:09
Simple server with go
package main
import (
"fmt"
"net/http"
)
func main() {
http.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Hello my friend")
@lalizita
lalizita / zero.go
Created October 13, 2022 02:26
default zero values for go
var i int // 0
var f float64 // 0.0
var b bool // false
var s string // ""
fmt.Printf("%v %v %v %q\n", i, f, b, s)
// nil for interfaces, slices, channels, maps, pointers and functions.
var pa *Student // pa == nil
pa = new(Student) // pa == &Student{"", 0}
pa.Name = "Alice" // pa == &Student{"Alice", 0}
@lalizita
lalizita / anonymous_func_1.go
Last active December 28, 2022 14:18
closure example with anonymous function in Go
func status() func() string {
var index int
orderStatus := map[int]string{
1: "TO DO",
2: "DOING",
3: "DONE",
}
// Retorna função que tem acesso à todo o escopo
// da função status, portanto também pode atualizar
// o valor da variável index
@lalizita
lalizita / anonymous_func_2.go
Last active November 2, 2022 00:11
Sample anonymous function example with Golang for medium article
func main() {
sayHi := func() {
fmt.Println("HIIIIIII!")
}
sayHi()
var sayBye func(name string)
sayBye = func(n string) {
fmt.Printf("Bye %s", n)
}