Skip to content

Instantly share code, notes, and snippets.

View lalizita's full-sized avatar

Laís Lima lalizita

View GitHub Profile
@lalizita
lalizita / iterator-range.go
Created August 21, 2024 21:51
This code is a simple example of range over function and iterators in Go
package main
import (
"fmt"
"iter"
)
type Employee struct {
Name string
Salary int
@lalizita
lalizita / fast_test_pg_connection.go
Created May 16, 2024 23:06
A fast script to test postgres connection
package main
import (
"database/sql"
"fmt"
"log"
_ "github.com/lib/pq" // Importando driver PostgreSQL
)
@lalizita
lalizita / maps.go
Created November 27, 2023 11:23
Maps example
package main
import "fmt"
func main() {
var jogo = map[string]int{"Lais": 10, "Asael": 20}
fmt.Println(jogo)
// Atualiza item
jogo["Lais"] = 50
@lalizita
lalizita / linked_list.go
Created November 27, 2023 11:21
Linked list example
package main
import (
"fmt"
)
type Node struct {
name string
next *Node
}
@lalizita
lalizita / go_arrays.go
Created November 27, 2023 11:16
go_array_op
func main() {
var array [3]string
array[0] = "Lais"
array[1] = "Juliana"
array[2] = "Ricardo"
//Essa operação não é possível pois o tamanho do array é 3
// array[3] = "Joao"
fmt.Printf("%v+\n", array)
@lalizita
lalizita / ffmpeg_video_examples.sh
Created October 24, 2023 22:38
ffmpeg scripts for video processing
# Cut/Trim video
ffmpeg -ss 5 -i input.mp4 -to 10 output.mp4
# Video to gif
ffmpeg -ss 61.0 -t 2.5 -i <input> -filter_complex "[0:v] fps=12,scale=w=480:h=-1,split [a][b];[a] palettegen=stats_mode=single [p];[b][p] paletteuse=new=1" output.gif
# thumbnail
ffmpeg -i mov_bbb.mp4 -ss 00:00:03 -r 1 -s 1280x720 -f image2 thumb_mov.jpeg
#text in video
@lalizita
lalizita / wrong_channel_reading.go
Created March 31, 2023 14:52
Example that shows a channel cant be read more than one time
func main() {
fileUpdated := make(chan string)
go WatchEvents(fileUpdated)
var filename string
go func() {
for range fileUpdated {
filename = <-fileUpdated
@lalizita
lalizita / watcher.go
Last active April 8, 2023 17:31
Watch file changes inside a directory
package main
import (
"fmt"
"io/fs"
"log"
"os"
"path/filepath"
"github.com/fsnotify/fsnotify"
)
@lalizita
lalizita / update-go.sh
Created February 24, 2023 17:42
How to update Go version in your machine with homebrew
## Find go directories and remove
$ which go
/usr/local/go/bin/go
## Install using brew
brew install go
@lalizita
lalizita / anonymous_func_5.go
Created November 2, 2022 00:41
Example of anonymous function with Go for a medium article
func main() {
n := func() int {
return 2
}
x := sumNumber(n())
fmt.Println(x)
}
func sumNumber(number int) int {