• 3 Posts
  • 74 Comments
Joined 2 years ago
cake
Cake day: June 20th, 2023

help-circle


  • Also look up the modulo operator. It’s similar to integer division but ONLY returns the remainder. It’s useful if you want to have something with multiple division steps for example.

    38 hours is how many days? 38 / 24 = 1 with your current setup

    38 / 24 = 1.583333333 if you use floats

    38 % 24 = 14… % is the modulo operator

    Combine your setup and the modulo you could output something like “there is 1 day and 14 hours over course of 38 hours” which is much more human usable since most people don’t know how long 0.583333333 is but know 14 hours.

    Or doing money… I’ll leave this up to you as a mental exercise for you but say you want to give someone $46.28 in cash. How many and what type of bills and coins would you give? Hint while 4628 pennies would be true it’s not the answer you want.



  • All the other tips are great. I would also recommend checking out a switch statement, for example https://www.geeksforgeeks.org/c/c-switch-statement/

    This will clean up alot of the else if statements. Also I would work on code to organization. For example you test if the choice is greater than or equal to 6 or less than 1, then if it is equal to 5 then check again if it’s less than 5 and greater than 0. You already did that third check.

    If you want to go slightly more advanced I would put the steps to ask for and save the input numbers into a function then just call that function on each of the following choices. Would add a functional call but would remove another if statement. If you name it well it would also help on code readability.

    Also if you want to take this farther like taking more than 2 numbers or more than 1 operation (for example 2 + 3 * 4) look into reverse polish notation. Basically it’s how to store the equation to make executing them correctly easier. That might be a little advanced for you at this stage though.



  • I “tried” Linux but never got it usable. I initially decided to run a vm on virtualbox to experiment. I tried Debian, arch, kali, Ubuntu and all ended up having an input lag of 1-2 seconds. Windows the system was fine. But I found my self unable to do basic tasks it was no bad. I don’t mean I didn’t know a command or unwilling to find a foss software equivalent, I mean it took several tries to get the mouse over the X to close a program due to input lag.

    OK I then decided to try a docker container with Linux. It got so messed up if I open docker desktop it displays an error that the container was unable to start, if you close the error to edit settings or create a new container it closes docker desktop, no way to fix it.

    I was able to get a wsl command line working but all I found it able to do is add 5 steps to everything due to having to start the command, start wsl, log on, elevate permissions etc.





  • That’s not even code grief…

    Two examples that were far worse:

    1. My last company wanted software developers. They offered to send me to code boot camp and give me a promotion. The boot camp was primarily python. I complete and get the promotion. New manager tells me the code base I’ll work on is actually c… Umm ok. New manager retires a week later. I spend a few weeks basically teaching myself c. New manager is assigned. He tells me I should basically assist the senior Dev, ok no problem. Find out the code base is actually c#… Should be doable it’s c based atleast. It’s c# framework 4.8 based on winforns… No one in the building had heard of a unit test…the code was released to production on December of '23. Oh and yeah the senior Dev then announced he was retiring. There are no other c# programmers on the team.

    2. I told this story before recently. On a separate c# code base the “login” function had hard coded credentials in the source, which checked if they existed in a local sql database table with one entry(the hard coded values) and then verified the returned value for “password” was >= than 5. It then logged you in. Didn’t check if the password was correct or even the correct length just that the return of the select statement was greater than or equal to 5 characters… Just for fun remember that false is 5 characters 😂




  • To me the best use of cli is troubleshooting remotely. I don’t mean like ssh I mean like talking over the phone. It’s easier to say “type in this command” then say "at the top of the window there should be a menu bar, near the right, no not all the way to right, no don’t click the red x, it should say tools, move your mouse over tools, God damn it I said DON’T click the red x, now we have to start over, click the icon on the desktop, no I don’t know why it’s called icon, it doesn’t mean anything religious, please just open the application… I don’t care if you are Christian and find the term icon offesive… Hurry up I am late for the AA meeting I need after dealing with people like you. " wait the problem may just be coworkers…






  • Funny story of the at one about 10 years ago I rented a room in a house with these two old(60+) alcoholics. We split the cable/internet bill, normally it was $270 a month ($90 per person). At the time I was about to move across the country and was doing business trips back and and forth. This month I was there for about 1 week. The cable bill came in and it was close to a grand.

    They wanted me to pay $350 and I said no! I called the cable company and asked why it was so high. They said it was from like 14 porn movies being purchased all from one cable box(I never even unboxed mine) over a week end. They gave me the serial of the box and I checked all the boxes. I found out who it was, I payed my $90 dollars and told them to figure out the rest. I moved out the end of the next month, never did learn what happened to the bill(wasn’t in my name thankfully).