MarcGyver πŸš€ (@marcboeker) header
MarcGyver πŸš€ (@marcboeker) profile picture

Code Ma(r)cGyver that writes Marcdown on his MarcBook.

eu-central-1
Joined October 2008
Photo by MarcGyver πŸš€ (@marcboeker)Photo by MarcGyver πŸš€ (@marcboeker)Photo by MarcGyver πŸš€ (@marcboeker)Photo by MarcGyver πŸš€ (@marcboeker)Photo by MarcGyver πŸš€ (@marcboeker)Photo by MarcGyver πŸš€ (@marcboeker)Photo by MarcGyver πŸš€ (@marcboeker)Photo by MarcGyver πŸš€ (@marcboeker)Photo by MarcGyver πŸš€ (@marcboeker)Photo by MarcGyver πŸš€ (@marcboeker)
MarcGyver πŸš€ retweeted
whoa, whoa, whoa! Why did no one tell me about the debug tooling for flexbox in Chrome?!
3
1
39
8,105
Yeah, finally Go 1.22 with the new routing pattern support is here. tip.golang.org/doc/go1.22#en… Don't forget to change the Go version in your existing go.mod to 1.22 otherwise it will stick to the old Go version.
46
Are you tired of breaking your fingers writing shell scripts because the syntax is so special? Maybe Go script is something for you. You can use it to write a lot of things in Go that you used to write as a shell script. github.com/bitfield/script
1
4
16
2,982
When working with CGO the chance to produce memory leaks by accident is very high. A simple way besides pprof to locate memory leaks is the "Instruments" App that is shipped with Xcode. As you can see below, I have a memory leak: --> 🧡
1
75
And here is the pendant without the leak: package main // #include <stdlib.h> import "C" import ( "fmt" "unsafe" ) func main() { for { foo := C.malloc(1) fmt.Println(foo) C.free(unsafe.Pointer(foo)) } }
1
49
You can see, the leak has gone.
28
Hey SQLiters, what are your most used PRAGMAs? Mine are: - PRAGMA synchronous=1; (to make sure, changes are synced to the underlying FS on the most critical moments) - PRAGMA journal_mode = wal2; (enable the new write ahead log) sqlite.org/pragma.html#toc
16
As a quick refresher: do you know the difference between length and capacity of slices? Here's a great read on that topic: 100go.co/20-slice/
36
MarcGyver πŸš€ retweeted
The are objectifying the man πŸ˜‚
108
905
101
7,281
367,033
Remove specific elements from a slice with slices.DeleteFunc: DeleteFunc takes the slice and a func that determines wether the element should be deleted or not. In our example, we want to remove all sweets from the slice that does not begin with a capital C.
1
15
Or to find out, if two slices are equal (in regards to their size, elements and order):
1
10
Or some nice helper functions for maps, like getting all keys and values as a slices:
13
Who uses the new slices and maps packages with a lot of helper functions introduced in Go 1.21? Let's play with some examples 🧡 pkg.go.dev/slices pkg.go.dev/maps tip.golang.org/doc/go1.21#sl…
1
1
22
What was the weirdest bug you've ever encountered? Mine was a program, that randomly crashed when I was sitting on the couch in the living room, but ran fine in the office. It turns out that a malfunctioning power supply in my living room produced interfering voltage spikes.
16
Can the EU please also free iOS development from X Code. Every time I use X Code I immediately feel too dumb to use my computer. I know, you can hack VS Code to develop iOS apps, but this is also a pain. Dear EU, may I have an official VS Code extension from Apple, please? Thanks
48
If there were a country called "Land of Bubblesort" @ThePrimeagen would be its president. Awesome, free course about algorithms you definitely need (at least to get a job). Also, they are very well explained, so well that even your mom would understand it. frontendmasters.com/courses/…
1
1
43
Today I stumbled upon fmt.Sprintf(":" + port) and was wondering, why this is so common? Searching Github for this string reveals a lot of repos using this pattern. github.com/search?q=fmt.Spri… Let's benchmark this and discuss alternatives 🧡
1
26
The winner, in this simple case, is of course string concatenation. However, it is not always the best option and does not make sense for larger strings and/or many concatenations. However, for this simple example, it is the fastest method and does not require memory allocation.
1
14
But why is fmt.Sprintf(":" + port) used so often? It is even used in Google's exposure notification server: github.com/google/exposure-n… Is it more readable? Is it idiomatic? Maybe someone with a background in profiling can enlighten me? cc @felixge
1
17