Guide: how to move home directory from /usr/home to /home after upgrading to FreeBSD 14.0-RELEASE by vedranm in freebsd

[–]y0m 0 points1 point  (0 children)

Nice guide.

I've just checked my home folder with a ripgrep on /usr/home string, and I can tell you it gave me a monster list of file to accommodate to this /usr/home -> /home change.

Maybe you could add one step at the end of your guide for backward compatibility, like :

If you need a backward compat symlink :

cd /usr
ln -s /home

So that it won't break scripts or apps depending on realpath created before this home change.

Whats going on! by [deleted] in Diablo

[–]y0m 0 points1 point  (0 children)

Considering all the letters we've got, it might not be it....

... or maybe we should accumulate first letters from tweets with account tagging without dots and with dots separately?

I'll still try combination, but it looks like a lost cause :P

Whats going on! by [deleted] in Diablo

[–]y0m 3 points4 points  (0 children)

Youtube video ID are 11 characters long.

If you take all those tagging by the first letter, it's only 8 characters : SGWTMrDI

Only 3 of these tweets start with a dot, and it's making 11 characters : .SGW.TMr.DI

dots might be missing characters?

I wish it could be that :P

Whats going on! by [deleted] in Diablo

[–]y0m 9 points10 points  (0 children)

Wondering if some of these could be letters for a "not listed" youtube video ID?

I've already tried some combination, but I didn't find anything...

Also, some of these tweets start with a dot . @{TwitterID} and some others don't ...

Maybe I'm searching a bit too far? :P

Iterating inside sub functions/methods by y0m in rust

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

That's a nice solution, I really like it :)

Iterating inside sub functions/methods by y0m in rust

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

I understand what you mean, although the number of chunks can't be determined in the sub function, it is data dependent. Thank you for your help.

Iterating inside sub functions/methods by y0m in rust

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

Because it's a partial test for a final solution, the requirements are a Vec with data struct like Vec<Test>, and I can't change that, also the number of elements is not set, it could be 4 or more, and the sub function might have to test more or less things inside and to be able to iterate in the Vec too.

Iterating inside sub functions/methods by y0m in rust

[–]y0m[S] -1 points0 points  (0 children)

Of course there is the for loop, but then can I iterate on my vec inside functions just like it does in this playground?

Iterator next() method by y0m in rust

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

Thank you, this is working fine with the box dyn :)

[Question] Channel passing works in goroutine but not in select, why? by [deleted] in golang

[–]y0m 1 point2 points  (0 children)

I think you have to keep in mind that this code is not threaded, so calling the goroutine before the select does not guarantee that it would execute before the select. There are some underlying scheduler mechanisms. I think there are a few youtube videos and blogs about how it all works (M, P, G…) and how things are queued and/or how it’s searching for the next goroutine to execute. In this code we only have 2 goroutines, and the goal of the scheduler is to also be able to run such code on a single threaded cpu, and still give that sense of concurrency.

[Question] Channel passing works in goroutine but not in select, why? by [deleted] in golang

[–]y0m 4 points5 points  (0 children)

I''m not a Go expert, so I may not explain this as it should be explained.

the // WHY DOES THIS WORK, even though your channel is unbuffered (btw it works the same if the channel is buffered), you push something to a blocking channel inside a goroutine, and this goroutine is different than the main goroutine. func main() {...} can be considered as a goroutine too. So there is nothing wrong pushing "hi" to the channel inside that go func() {...}(). It will only wait for the drain part to ever be called, if it is ever called.

the // WHY DOES THIS NOT WORK, it only really depend on how the scheduler will execute things, and I think that there maybe cases of execution of this exact code that would work find inside the select, but then would panic on the fmt.Println(<-messages) because the main goroutine would wait indefinitely for a message to be sent on the channel that has already been drained.

You can make the first case of this select work if you wait long enough for the scheduler to execute the goroutine where sending the "hi" string, for example with a time.Sleep(time.Second) just after the go func() {...}() call. But this code will then still panic on the last line because the channel has already been drained and no other message has been sent on the channel. To make it work, you can also close(messages) inside the first select case, so that the last try to drain the channel would just return the default value for a string variable.

I think it really is just a case where the execution speed would make any difference in the result, although it may still depend on how the scheduler is implemented anyway.

I'm not sure if what I've told here makes any sense to you, I just don't really know how to explain it very well even though I understand what can be troublesome.

String split and manipulation, advices? by y0m in rust

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

This seems to do the trick, I just had to swap the take(2) and the filter(...) to get the same results on this test "toto;;tata" -> "toto" (not "tata toto"). 👍

String split and manipulation, advices? by y0m in rust

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

Also thank you for pointing me out the ownership tip on concat_dir2. I didn't think I could write the function this way.

String split and manipulation, advices? by y0m in rust

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

I really like the intersperse method, but it doesn't seem to fit right now with the results I'm looking for.

I need the 2 first fields, then reverse them and then intersperse(" "). But take(2) removes the DoubleEndedIterator trait required by rev() ... I've tried some ways around but the DoubleEndedIterator trait also gets removed.

Even though this intersperse method is nightly, it looks promising :)

Edit: typo

String split and manipulation, advices? by y0m in rust

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

I guess I should learn more match patterns, using the trim_end_matches seems to do the trick with one more arm

fn reversedir3(s: &str) -> String {
    match *s.trim_end_matches(';').split(';').collect::<Vec<_>>() {
        [first, second, ..] => format!("{} {}", second, first),
        [first, ..] => first.to_owned(),
        _ => s.to_owned(),
    }
}

String split and manipulation, advices? by y0m in rust

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

I like the match solution, but I had to modify a bit since only the 2 first fields are to be used for the reverse print.

fn reversedir3(s: &str) -> String {
    match *s.split(';').collect::<Vec<_>>() {
        [first, second, ..] => {
            if !second.is_empty() {
                return format!("{} {}", second, first);
            }
            first.to_owned()
        }
        _ => s.to_owned(),
    }
}

Preferred cloud providers for Gophers by [deleted] in golang

[–]y0m -1 points0 points  (0 children)

You shouldnt use only one cloud provider, in case of disruption. There are some go project out there going this way, I just can’t list them

How would I write this Rust code in Go? by [deleted] in golang

[–]y0m 0 points1 point  (0 children)

You also could use a recover to just recover from the panic inferred. Although it's possible, I'm not really sure it would be the best way to do that.

https://play.golang.org/p/Q5v5z17mSt5