Skip to content

Instantly share code, notes, and snippets.

View pedrobertao's full-sized avatar
🚀

Pedro Bertao pedrobertao

🚀
  • Brazil
View GitHub Profile
@pedrobertao
pedrobertao / maps.go
Created August 31, 2023 09:36
maps package in golang
package main
import (
"fmt"
"golang.org/x/exp/maps"
)
func main() {
m := map[string]string{
@pedrobertao
pedrobertao / cmp.go
Created August 31, 2023 10:05
cmp package in golang
package main
import (
"cmp"
"fmt"
)
func main() {
var num, num2, num3 int64 = 1, 2, 1
var str, str2, str3 = "ab", "abc", "ab"
@pedrobertao
pedrobertao / standard-media-queries.css
Last active February 21, 2024 09:39
Standard media queries css tricks width height landscape portrait
/* Small screens, laptops (landscape) ----------- */
@media only screen
and (min-device-width : 769px)
and (max-device-width : 1024px) {
/* Styles */
}
/* Desktops & large screens (landscape) ----------- */
@media only screen
and (min-device-width : 1025px)
@pedrobertao
pedrobertao / fibWithRoutines.go
Created September 4, 2024 12:31
fib with go routines
package main
import (
"fmt"
"sync"
)
var wg sync.WaitGroup
func readFib(c <-chan int) {
@pedrobertao
pedrobertao / fib.go
Last active September 22, 2024 14:05
Recursive and Iterative Fibonnaci Sequence
package main
import "fmt"
func fibRecursive(position uint) uint {
if position <= 2 {
return 1
}
return fibRecursive(position-1) + fibRecursive(position-2)
}
@pedrobertao
pedrobertao / main_test.go
Last active September 22, 2024 14:09
Fibonacci Benchmark Test
func BenchmarkFibRecursive(b *testing.B) {
for i := 0; i < b.N; i++ {
fibRecursive(uint(10))
}
}
func BenchmarkFibIterative(b *testing.B) {
for i := 0; i < b.N; i++ {
fibIterative(uint(10))
}
}
@pedrobertao
pedrobertao / main.go
Created March 3, 2025 12:30
IQR Method Claude.ai in Go
package main
import (
"fmt"
"math"
"sort"
)
// RemoveOutliers removes outliers from a slice of prices using the IQR method
// multiplier is typically 1.5 for mild outlier detection or 3 for extreme outliers
@pedrobertao
pedrobertao / main.go
Created March 3, 2025 12:51
Modified Z-Score by Claude.ai
package main
import (
"fmt"
"math"
"sort"
)
// RemoveOutliersSmallDataset removes outliers from a small dataset using the Modified Z-score method
// threshold is typically 3.5 (more conservative) to 3.0 (more aggressive)
@pedrobertao
pedrobertao / pi_with_random.go
Last active July 25, 2025 17:50
Calculating pi with go
package main
import (
"crypto/rand"
"encoding/binary"
"fmt"
"math"
"sync"
)
@pedrobertao
pedrobertao / faninfanout.go
Created July 17, 2025 15:17
Go concurrency demo using fan-out/fan-in pattern with worker goroutines processing jobs through channels.
package main
import (
"fmt"
"time"
)
// doubleIt is a simple work function that doubles the input value
func doubleIt(a int) int {
return a * 2