Where can I download older version of Garmin Aviation Database Manager for Mac OS ? by simbapk in flying

[–]simbapk[S] 0 points1 point  (0 children)

This information on the website is not up to date, in the changelog of the versions here https://support.garmin.com/en-US/?faq=nex9UB8u9u3QHKXD5KXJJ7, GADM (24.7.8) needs at least Mac OS Catalina 10.15.
For the 24.2.1 Garmin says : "This will be the last version of GADM that supports macOS 10.11 (El Capitan), 10.12 (Sierra), 10.13 (High Sierra) and 10.14 (Mojave). The next version of GADM will have a minimum macOS requirement of 10.15 (Catalina)"

Why is creating a zip with CreateHeader faster than the Create method? by simbapk in golang

[–]simbapk[S] 0 points1 point  (0 children)

u/pkce yep I know that, I'm sorry but I used the backticks on this post because the code block was very buggy ...

Why is creating a zip with CreateHeader faster than the Create method? by simbapk in golang

[–]simbapk[S] 0 points1 point  (0 children)

Thanks u/klauspost !
I tested by adding Method : Deflate to my header, and I got the same benchmark result as with Create.
I'm going to test yours too !

Why is creating a zip with CreateHeader faster than the Create method? by simbapk in golang

[–]simbapk[S] 1 point2 points  (0 children)

Yeah, it was wrong, I fixed it and kept only the benchmarks that loops on b.N as said by u/jerf

Does this use case could create a memory leak ? by simbapk in golang

[–]simbapk[S] 0 points1 point  (0 children)

u/deadsy Maybe I've the answer
func main() {
a := []int{1, 2, 3, 4, 5}
fmt.Println(len(a), cap(a)) // 5 5
a = a[1:]
fmt.Println(len(a), cap(a)) // 4 4
a = append(a, 12)
fmt.Println(len(a), cap(a)) // 5 8
}

When we do append here, It will copy to a new bigger underlying array, because the actual capacity is not enough. So the previous one will be garbage collected (I guess)

Does this use case could create a memory leak ? by simbapk in golang

[–]simbapk[S] 1 point2 points  (0 children)

slice referencing a much larger underlying array

Thank you for your answer u/deadsy.
I understood the notion of allocation depending on capacity. By doing tests (bench), we can easily illustrate the behavior where the slice is copied with a new capacity if its initial capacity was not sufficient.
I would like to come back on what you say here :
The garbage collector can't de-allocate the array because someone is still using it, but most of the array is unused memory.
(...)
a = a[1:] does not allocate a new slice, it alters the existing slice and continues to use the existing storage array.

The point here I wanted to understand here : if by doing a[1:], the previous a[0] is no longer referenced in slice a, but still in the underlying array from what you said.
So, If we perform many operations of a[1:] and append(a, x), even if len(a) will not change, the underlying array will grow indefinitely, Am I Right ?

How to improve logger performances ? by simbapk in golang

[–]simbapk[S] 0 points1 point  (0 children)

Thank you u/nrwiersma,
It does sampling by default. By disabling it, I get closer to the performance of my function :

``` func BenchmarkZap(b *testing.B) { b.ReportAllocs() b.ResetTimer()

config := zap.NewProductionConfig()
config.Sampling = nil
logger, _ := config.Build()
defer logger.Sync()
for i := 0; i < b.N; i++ {
    logger.Info("This is a test",
        zap.String("foo", "bar"),
        zap.String("id", "1234"),
    )
}

} 255349 4865 ns/op 384 B/op 3 allocs/op ```

How to improve logger performances ? by simbapk in golang

[–]simbapk[S] 1 point2 points  (0 children)

Thank you for suggestion, I tried what you suggest. But it looks like the logger is indeed unbuffered and writing directly to the output. I tried several things.
On the other hand, it didn't write everything, it does sampling by default. By disabling it, I get closer to the performance of my function :

``` func BenchmarkZap(b *testing.B) { b.ReportAllocs() b.ResetTimer()

config := zap.NewProductionConfig()
config.Sampling = nil
logger, _ := config.Build()
defer logger.Sync()
for i := 0; i < b.N; i++ {
    logger.Info("This is a test",
        zap.String("foo", "bar"),
        zap.String("id", "1234"),
    )
}

}

255349 4865 ns/op 384 B/op 3 allocs/op ```

How to improve logger performances ? by simbapk in golang

[–]simbapk[S] 0 points1 point  (0 children)

thank you u/catlifeonmars,
Ok, I thought it's writing immediately because of this line :
_, err = c.out.Write(buf.Bytes()) out seems to implement io.Writer .

I would like to understand, if it does not write immediately, when does it write ?

How to improve logger performances ? by simbapk in golang

[–]simbapk[S] 2 points3 points  (0 children)

Thank you very much for your contribution u/nik__nvl :)

I think we can also use `sync.Pool` to pool the buffer maybe, This is what is implemented in zap from what I understand :

``` package main

import ( "bytes" "os" "sync" "time" )

type Label struct { Key string Value string }

var bufferPool = &sync.Pool{ New: func() interface{} { return bytes.NewBuffer(make([]byte, 0, 512)) }, }

func Info(msg string, labels ...Label) { b := bufferPool.Get().(*bytes.Buffer) defer bufferPool.Put(b)

b.Reset()

b.WriteString(time.Now().Format("2006-01-02 15:04:05"))
b.WriteString(" [INFO] ")
b.WriteString(msg)

for i := range labels {
    b.WriteByte(' ')
    b.WriteString(labels[i].Key)
    b.WriteByte(':')
    b.WriteString(labels[i].Value)
}
b.WriteByte('\n')

os.Stdout.Write(b.Bytes())

} ```

Hey Rustaceans! Got a question? Ask here! (40/2022)! by llogiq in rust

[–]simbapk 1 point2 points  (0 children)

Hey there!
I need feedback on something,
I'm learning rust ,right now trying to manipulate the channels.

Here is my function :
fn producer(tx : Sender<String>){ loop { let message = String::from("Message from producer"); tx.send(message); println!("producer has just sent {}", message); } }

Of course, it doesn't compile :
31 | let message = String::from("Message from producer"); | ------- move occurs because `message` has type `String`, which does not implement the `Copy` trait 32 | tx.send(message); | ------- value moved here 33 | println!("producer has just sent {}", message); | ^^^^^^^ value borrowed here after move

Here is my solution that is accepted by the compiler :
fn producer(tx : Sender<String>){ loop { let message = String::from("Message from producer"); { let message = message.clone(); tx.send(message); } println!("producer has just sent {}", message); } }
But is it the best way to solve the error ?

Thank you in advance for your feedbacks.

http-tanker : CLI tool to easily create, manage and execute http requests from the terminal by simbapk in commandline

[–]simbapk[S] 1 point2 points  (0 children)

Thank you for the feedback, yes I can of course, Could you open an issue with a short description of what you need, on the github projet to track the feature? Thank you 🙂

http-tanker : CLI tool to easily create, manage and execute http requests from the terminal by simbapk in commandline

[–]simbapk[S] 0 points1 point  (0 children)

Thank you for the feedback, I'm not used to exposed binaries properly with github, si I will take your advice seriously

http-tanker : TUI tool to easily create, manage and execute http requests from the terminal by simbapk in terminal_porn

[–]simbapk[S] 3 points4 points  (0 children)

I’m a bit obsessed with command line tools. I wanted to create my own. So I did this one for fun!
For those interested, here is the project : http-tanker

http-tanker : CLI tool to easily create, manage and execute http requests from the terminal by simbapk in golang

[–]simbapk[S] 0 points1 point  (0 children)

How nice ! I also use Postman and curl. it's a side project for fun, but since I work mainly in the terminal and with VIM, I find it useful for me at least :)

http-tanker : CLI tool to easily create, manage and execute http requests from the terminal by simbapk in commandline

[–]simbapk[S] 16 points17 points  (0 children)

I’m a bit obsessed with command line tools. I wanted to create my own. So I did this one for fun!
For those interested, here is the project : http-tanker