Or on the stock market or gambling which this is basically a mix of.
Or on the stock market or gambling which this is basically a mix of.
🤔 I think the vt100 protocols (where the escape code come from) predate windows and I think all modern terminals still use those as the base. So I think they are cross platform. From a quick search it looks like they are the same codes on windows. So I dont think the libraries are doing anything special for cross platform support.
Coloured text does not require a dep. It is just about printing the right colour codes like:
const BLACK: &'static str = "\u{001b}[30m";
const RED: &'static str = "\u{001b}[31m";
const GREEN: &'static str = "\u{001b}[32m";
const YELLOW: &'static str = "\u{001b}[33m";
const BLUE: &'static str = "\u{001b}[34m";
const MAGENTA: &'static str = "\u{001b}[35m";
const CYAN: &'static str = "\u{001b}[36m";
const WHITE: &'static str = "\u{001b}[37m";
const CLEAR: &'static str = "\u{001b}[0m";
fn main() {
println!("{RED}red! {BLUE}blue!{CLEAR}");
}
The libraries just make it easier so you don’t need to remember or know what those codes mean.
Declare input in the loop. That limits scope which is basically always a good idea.
There is good reason to not do this. Though in this case it won’t make much difference as performance is not an issue. But by having it outside the loop it allows the allocation of the string to be reused and in more complex programs is typically what you would want to do - allocate once outside the loop and reuse that inside.
In this case waiting on user input is going to outweigh any performance benefit I would not call it out as bad practice either.
The biggest/only real problem is the .unwrap()
. This will cause the program to exit with an error message if the user inputs an invalid value. Which is not a great user experience. Better to reject the input and ask them again (aka start the loop again). You can do this with a match
on the returned value of parse with a message and a continue on Err
(good time to learn about enums and pattern matching as well).
A minor improvement can be done to this:
input = input.to_string().replace("\n", ""); // removing the \n
let user_input: u32 = input.parse::<u32>().unwrap();
By replacing it with:
let user_input: u32 = input.trim().parse::<u32>().unwrap();
Which has a few advantages:
These are more nitpicks than anything substantial - would lead to nicer code in more complex situations but negligible at best in this code base (only really pointing out to give you some things to think about):
Since you break in the win condition the attempts += 1;
can be moved out of the other branches at the same level as the input.clear()
.
Rand has a gen_range function which can be used like:
rand::thread_rng().gen_range::<u32>(0..=100);
Though typically you would save the thread_rng() output to a local and reuse that throughout your program instead of creating one each time - here you only need one number so that matters less. The Rng trait has a lot more convenience function on it as well so it is generally worth using over just the random()
function. Though in this case it makes very little difference overall here - typically you would want to opt for one of those methods instead so is worth knowing about.
I dislike the name x
as it is very ambiguous. IMO short letters should be used only in smaller scopes or when they represent some sort of mathematical value. Here I would use secret_number
or secret_value
or something more descriptive. Though in this case there is not a much better domain name here, more often there is.
This assumes people are rational and that what they say they are willing to pay matches what they are actually willing to pay. And that is just the people not trying to abuse the system.
Oh, misses that bit… Seems there is a third party plugin that does something similar.
It does exist with docker debug.
Generally speaking you shouldn’t be poking around running containers. It is rare that I have ever needed to do that. If you want to inspect the contents of an image then tools like dive are helpful. If the container produces some useful output that you might need then put that into a volume, you can then mount that volume to a debug/inspect container to read the files without messing around with the rest of the container.
Shell-less containers are a great security feature - it is extremely hard to get a reverse shell on something that does not have any shell. And if you must have a shell to debug something docker already has a feature for that docker debug which works for shell-less containers as well.
Any surface that looks/feels flat will be good enough for this use case, no need to find a bit of glass. Most table tops will do. You might need something better for flattening heat sinks, but for 3d prints you don’t need to be that accurate. The plastic will deform far more under light pressure then the difference in any relatively flat surface you can find.
If you have one then there is no harm in using it - but also not need to explicitly look for something that flat. Any table will likely be good enough.
It looks like the gap is a whole perimeter missing likely caused by the infill being printed first? Or something else inside stopping it from being flush on the outside. This might not help now (unless you can separate the parts without damaging the outer perimeter) but before gluing it up it would have been best to get some sandpaper on a flat surface and sand the whole top flat until you have one complete outer perimeter. Or cut away the infill so the outer perimeter is the highest point.
If you cannot separate them without damage to the outer perimeters then you have a few options. First you could deform the plastic near then seam to cover it up. This can be done by heating the seam up with a hot air gun or hair dryer and pressing the layers together to close up the gap. You would really want to be gentle with the heat, just enough to let it start plasticity deforming with moderate/light pressure but not enough so it deforms under its own weight. Too much heat will also start to melt the surface edges of the layers rounding them over and making them look shiny which can look very obvious as well. So you really need to take it slow and apply as little heat as you can until it is just soft enough to deform.
The other options are to fill the gap. This can be done with any old filler but requires lots of sanding and painting afterwards. Or you can try to fill it with more plastic. You can use your printer to print small lines to give you something the right shape to fill the gaps, then it is just a matter of gluing or melting it in place. Super glue/CA glue will not be a good option here as it tends to leave white smear on 3d prints if you get any over spill which is very likely with a small gap. There are some glues designed for PLA that don’t do this but I have never tried them myself. You could also heat the patch first until it can deform and press it in quickly though this can be tricky to do quickly enough before it cools and may not stick in well. There are also solvents you can get that dissolve the plastic and let it weld together, best way to use that is to dip the patch peace in it and press that into the gap trying to get as little on the print as you can - any spillage will start to dissolve the layer lines smoothing them over and making them look shiny.
Each of these does require some skill to do well and are easy to mess up making the print look worst - so i would try them out on some scraps first. Though you can always opt to use any filler and sand/paint the model after but that requires quite a bit of work to make it look good but is the only real option that you can keep going until it looks good.
I believe it only shows them if you have played on more than one device.
I saw that when playing a game, it counted the time since it was opened while playing. But always saw it correct itself to actual time running withing a few seconds/minutes of closing the game on the deck.
That is a lot of contradictory sets of requirements. If it is important to have on the deck then it is going to be trivially searchable online. Something that is niche that others are not really doing is going to be very subjectively interesting or useful. That makes it impossible to recommend anything without violating one of those requirements.
Instead here is some advice for finding project ideas: Look at your own interests/hobbies/things you need to do and start taking note of problems you encounter, grievances or annoyances you have or just things you think could be made/done easier. Out of those you can look at ones that you think a steam deck could help solve and from that you can start to investigate ways to use the steam deck to solve those problems. That is essentially how you find niche and interesting/useful things that are specific to you to work on. It can take time, but the more you think about it and write things down the easier it becomes to find projects to do.
Things that I can just easily stop.
Technically any non-online game will work since you can just put the steam deck to sleep with the tap of the power button when ever you want and resume later on. It takes a couple of seconds to go to sleep and so the only times it is annoying is when you are directly in the middle of some action - which is generally easy to avoid in most games if you know you are coming up to your stop.
Personally I have been playing monster hunter world like this which works quite well - especially since there is quite a bit of less action packed stuff you can do between the main story line.
Anyway, yeah why would I watch someone else play a game when I can just play it myself?
I think some of it is watching people do things you cannot do. Competitive play, in both sports and gaming, is quite a different thing to watch people with skill vs what you could do yourself. Plus I suspect there is a lot of the psychology that goes with routing for a team and the feeling of being part of something bigger or something.
Personally I don’t really get it myself but I can see why people would. IMO it is not much different from why so many people like watching sporting events rather than going out and playing themselves.
For games I haven’t played yet, I would spoiler it for myself. Games I’ve already played… well, don’t need to watch that anymore, right?
That is true for single player games, but not for match making/competitive ones. I suspect that people are more so watching competitive ones than single player story driven games.
That is a month to fully cure. It should be dry to the touch before then, though that can still take weeks at worst. Keep it in a warmer and dryer place if you can as that will speed it up.
I have updated arch systems that had not been powered on for years before. It was fine. No issues what so ever. Arch is not some flaky distro that breaks if you look away for a minute. My main system has had had the same install for over 5 years now and I regularly forget to update it for months at a time. Again, no issues.
Or just glue it in… The glue is likely to be stronger then the thin layers of the 3d printed plug so you won’t get much from a mechanical interlock. And then there is no pressure or risk of deforming anything.
You could also print 2 layer circles/rectangles to cap the hole. Then melt/glue/weld the edges. Could use a soldering iron, hot knife, any glue or the 3dpen to do that and I would think it would give you a more consistent surface than the pen alone (and may not requite it at all). Worth trying at least.
Might even be worth creating a stepped hole to give better gluing surface like:
Structs are the AND data type in rust (ie it contains all the fields defined). As opposed to Enums which are the OR type (which can only be one of the variants defined). You also have ananomous data types like tuples or arrays.
The point about methods applies to any type in rust, structs are not unique or special there. Rust does not revolve around the struct type like other languages revolve around the class type.