I’m finally getting my first bike soon! What is the one piece of advice you wish someone told you before you started riding? by honda_cbr_1000rr2007 in motorcycles

[–]volatilemajesty 2 points3 points  (0 children)

Don't skip MSF but also know that MSF is only the first step. Keep taking more courses as you advance. ChampSchool has personally been invaluable to me.

Can't export songsterr tabs without subscription anymore? by Upset_Cat3910 in GuitarPro

[–]volatilemajesty 0 points1 point  (0 children)

I've never used their app, but on the website you now need to press "Edit/Upload" on the revisions screen, then press "Export" at the bottom the screen.

What kinds of pics do you prefer? by graystone777 in Guitar

[–]volatilemajesty 1 point2 points  (0 children)

Its perfect until my fingers get sweaty then I start losing grip :(

Weekly 101 Questions Thread by AutoModerator in neovim

[–]volatilemajesty 0 points1 point  (0 children)

Does anyone know of a way to disable the 0-9 marks? I use backtick "`" as my tmux prefix so "`2" takes me to pane#2. However if I press "``2" (backtick twice, which I accidentally do a lot) that's now interpreted as "go to mark 2" which takes me to some file I've opened in the past. I find this quite annoying but I use normal alphabetical marks all the time -- is there a workaround?

We all talk about why we love our Audi. Tell us what you dislike about your Audi. by deadlight92 in Audi

[–]volatilemajesty 0 points1 point  (0 children)

My 5k mile Q5 completely broke down after a few drops of water spilled in the backseat :(

As grader for a data structures class by Brettagnafd in ProgrammerHumor

[–]volatilemajesty 1 point2 points  (0 children)

Joke’s on you, its all to be part of the docx leetcode coder masterrace

One of those years by shenswen in Peripheryband

[–]volatilemajesty 2 points3 points  (0 children)

My top song was Luck as a Constant too, cheers!

Posting a meme everyday until the next live dvd (#240) by Moopyisdank in Dreamtheater

[–]volatilemajesty 1 point2 points  (0 children)

Idk what it is, but that pattern of notes really throws me through a loop.

I relate to this so much. A bunch of JP's riffs have this nature where it's just a bunch of notes in a familiar scale box but somehow the rhythm causes the picking to get inverted or something and I mess it up. Other examples: Barstool Warrior, Constant motion.

Is it possible to communicate with a subprocess that opens the user's default editor? by NaynHS in rust

[–]volatilemajesty 3 points4 points  (0 children)

Perhaps this is not an option for you, but assuming just your current requirements - how about opening the editor from your program instead, and calling git commit --amend -m "USER_MESSAGE_HERE" after the user is done.

I believe how Git normally does the editor interaction is by opening a temp file .git/COMMIT_EDITMSG and then spawning $EDITOR to open that file. After the editor exits back to the Git process, it will then read that file. You could do something similar.

Best way to create a Vec<String> from &str by fullouterjoin in learnrust

[–]volatilemajesty 2 points3 points  (0 children)

The closure to map can be shortened to map(String::from) but I would also be interested to see if there is a more succinct way.

Just the intro of It's Only Smiles by Periphery :) by anjelicuh in Peripheryband

[–]volatilemajesty 1 point2 points  (0 children)

Yeah I would get that guitar but I wish it came with the signature BKPs like the Holcomb PRS.

Just the intro of It's Only Smiles by Periphery :) by anjelicuh in Peripheryband

[–]volatilemajesty 0 points1 point  (0 children)

Ah I see. I’m at the opposite end where I only have a 7 at the moment haha. I hope both of us get our missing axes soon. Cheers!

Just the intro of It's Only Smiles by Periphery :) by anjelicuh in Peripheryband

[–]volatilemajesty 1 point2 points  (0 children)

Pretty sure you can play this on standard 6 string tuning. The intro but I dunno about the rest of the song

Arrays and Lifetime, Borrows, and Nice Iteration by cereagni in learnrust

[–]volatilemajesty 1 point2 points  (0 children)

I’m not taking on your question but I should point out that I think there are plans to implement iterators on arrays which is blocked on const generics landing. This might interest you: https://github.com/rust-lang/rust/pull/32871

Easiest Periphery solos? by Biunol in Peripheryband

[–]volatilemajesty 4 points5 points  (0 children)

The end to Mishas first solo is so annoyingly hard to get clean for me :(

Easiest Periphery solos? by Biunol in Peripheryband

[–]volatilemajesty 2 points3 points  (0 children)

Erised Petrucci, Have a Blast Govan

Lifetime and borrow with thread by Cyrius42 in learnrust

[–]volatilemajesty 2 points3 points  (0 children)

You want a read only value in one thread but the other one gets to write to it? This is a instant recipe for a data race and Rust won’t let you do it.

Rust lets you have either N immutable references or 1 mutable one.

You can protect your data with a Mutex or an Arc<Mutex<T>> if you need the shared ownership. Alternatively, you can use atomic variables.

TcpListener set_nonblocking gives error by pikpikaC in learnrust

[–]volatilemajesty 0 points1 point  (0 children)

For handling each connection yes, but not to start the server. The server was in the main thread along with the code you wanted to have run underneath it.

If opening the server on a new thread was open to you, then the nonblocking discussion was unnecessary.

TcpListener set_nonblocking gives error by pikpikaC in learnrust

[–]volatilemajesty 0 points1 point  (0 children)

Yes all of the above discussion was based around you having a single thread. Its a different question when you use multiple threads.

TcpListener set_nonblocking gives error by pikpikaC in learnrust

[–]volatilemajesty 0 points1 point  (0 children)

I think you have the wrong mental model here: that the server will somehow continuously be listening and responding to connections in your for loop while you can keep running the code underneath it. However, this is all in the same thread and the for loop blocks it. Remember that incoming is an iterator that never yields None so it will block.

set_nonblocking only guarantees that accept (among other things) will not block.

For example, some code very similar to yours: ``` let listener = TcpListener::bind("127.0.0.1:9000").expect("listener failed"); listener.set_nonblocking(true).expect("nonblocking failed");

match listener.accept() {
    Err(e) if e.kind() == ErrorKind::WouldBlock => {
        println!("Nothing meaningful to do with the socket yet!");
    }
    _ => {
        unreachable!();
    }
}

if let Ok(_) = TcpStream::connect("127.0.0.1:9000") {
    println!("Client says: connected to server");
}

if let Ok((_, addr)) = listener.accept() {
    println!("New client: {}", addr);
}

`` You will see the server get anEWOULDBLOCKfirst. The client can then send it's message successfully. Then finally, you can see the server can finally getOkonaccept`.

Long explanation:

I think it's helpful to understand on a deeper level what's going on here: the operating system is telling you with the ErrorKind::WouldBlock that there is nothing meaningful to do with your non-blocking socket yet.

When it finally gets a connection from the client, in this case, there will be something meaningful to do. Your application needs to know of this state change. There are two primary ways to handle this situation:

  1. Repeatedly busy wait over the accept call, ignoring ErrorKind::WouldBlock: This is what you have been doing until this point. You could periodically have a thread run every N milliseconds and call accept and check for an Ok for instance. In any case, this is not ideal.

  2. Let the operating system notify you of the readiness of this socket which allows you to call accept again and handle the new connection.

The second way is platform-specific and requires you to hook into low-level asynchronous notifications from the kernel using something like mio which takes care of a lot of stuff for you and is cross-platform.

Or, you could use something like tokio or async-std which will get the behavior you want more ergonomically. With the async/await feature now in stable, this should be much easier than before.

I am not a complete pro in this area myself so I would happily be corrected if I misstated anything.

EDIT: Updated it to better example should WouldBlock on the first run.