The code is obviously from the Linux kernel, specifically managing group memberships and permissions for processes.
*still finds time to write neatly crafted comments on what the code does
Greetings from Novosibirsk!
My man!
class Calculator: def __init__(self): self.history = []
def add(self, num1, num2):
"""Add two numbers"""
result = num1 + num2
self.history.append(f"{num1} + {num2} = {result}")
return result
def subtract(self, num1, num2):
"""Subtract two numbers"""
result = num1 - num2
self.history.append(f"{num1} - {num2} = {result}")
return result
def multiply(self, num1, num2):
"""Multiply two numbers"""
result = num1 * num2
self.history.append(f"{num1} * {num2} = {result}")
return result
def divide(self, num1, num2):
"""Divide two numbers"""
if num2 == 0:
raise ValueError("Cannot divide by zero!")
result = num1 / num2
self.history.append(f"{num1} / {num2} = {result}")
return result
def get_history(self):
"""Get the calculation history"""
return self.history
def main():
calculator = Calculator() while True:
print("\nOptions:")
print("1. Add")
print("2. Subtract")
print("3. Multiply")
print("4. Divide")
print("5. Get History")
print("6. Quit")
choice = input("Choose an option: ")
if choice == "1":
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
print(f"Result: {calculator.add(num1, num2)}")
elif choice == "2":
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
print(f"Result: {calculator.subtract(num1, num2)}")
elif choice == "3":
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
print(f"Result: {calculator.multiply(num1, num2)}")
elif choice == "4":
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
try:
print(f"Result: {calculator.divide(num1, num2)}")
except ValueError as e:
print(e)
elif choice == "5":
print("\nCalculation History:")
for i, history in enumerate(calculator.get_history()):
print(f"{i+1}. {history}")
elif choice == "6":
break
else:
print("Invalid option. Please choose a valid option.")
if __name__ == "__main__":
main()BTW I hate that term with a passion.
As someone who has crafted software for the last 45 years, it’s like implying that learning the alphabet makes you a Tom Robbins.
Writing software is about understanding the problem and the information involved in such a way that you can craft algorithms and data structures to efficiently and reliably solve those problems. Putting that into code is the smallest, least important part of that skill.
That’s why software engineering is mostly language agnostic. Sure, there are paradigms that fundamentally change the way that the problem space is handled, but at least within a paradigm, languages are pretty much interchangeable. Some just have less hidden footguns.
Interface design is another thing altogether, And is either fruitless drudgery or fine art, depending on your predisposition.
There is definitely room for a subclass of brilliant interface designers that do not need deep data manipulation intuition …. But they do need to have a deep understanding of human nature, aesthetic principles, color theory, some understanding of eye mechanics and functional / perception limitations, accessibility/disability engineering, and a good dose of intuition and imagination.
In short, nothing about producing quality software is something that you gain by writing code snippets to solve simple problems. But you do have to learn the alphabet to write, and “coding” it is still a prerequisite to learning to write software. It just shouldn’t be sold to people as if it was some kind of degree lol.
Give me some kid who’s been building things with Arduino in her basement for a few years over a coding bootcamp graduate any day. I can teach her how to write good code. I’ll just pull out more of my non-existent hair trying to reach the “coder” to actually solve problems, unless I get lucky.
EDIT: https://miro.medium.com/v2/resize:fit:786/format:webp/1*3YdG... from https://towardsdatascience.com/teaching-an-rnn-to-write-code...
The thumbnail to this image says "the source code to the Matrix"... so perhaps the movie had used some Linux code, and everybody is copying the movie
I've seen people who are really great at combining "recipes" off the web for anything (including hobby electronics and programming), but never really get to the bottom of things or develop clear understanding of how things work and tie together.
I imagine you'd only get more out of that kid toying with Arduino because of persistence ("few years"), and not because of the type of things they did, but I ultimately believe you'll have similar chances of developing a great software engineer out of any of them in general.
This 'feature' is so infuriating, as many websites have shortcuts that become unusable from this. There is nothing wrong with CTRL + F total idiotic feature to have on by default.
An easy hack would be to use echo, netcat and less to browse either Reddit or HN over Gopher:
echo /live/items | nc hngopher.com 70 | less
echo /live/items/41877513 | netcat hngopher.com 70 | less
The important person would always be very impressed and say what a good job we were doing, and our boss who was showing them around (and knew exactly what we were doing) would have to nod and sweat bullets and then would get furious with us afterwards (but it was worth it and we did it every time we knew someone was coming to do an inspection).
I think it's popular due to hackertyper. If you search for things like "hacker code" on google, hackertyper comes first.
Suddenly, the screen flashes red: "ACCESS DENIED."
> Dammit, they're trying to lock me out.
Fingers fly across the keyboard. Sweat drips from their forehead.
> Not today, FBI...
The warning turns from red to green: "ACCESS GRANTED"
> I'm in.
> Let’s see what you’ve been hiding...
I tried letting my niece and nephew play with this once but they kept hitting the Super key, minimizing the window, alt-tabbing, etc.
cat /dev/random | hexdump -C | grep 'ca fe'
Note that it runs a lot faster now than it used to in the 90s.I wondered how its speed could be adjusted and found `pv` can be used for throttling pipe throughput, so thanks for that too!
Limited to reading 50kB per second:
cat /dev/urandom | pv -q -L 50k | hexdump -C | grep 'ca fe'
You can start anywhere, and coding boot camps are useful, just as following YouTube tutorials. But until you learn to identify, quantify, and characterise the problem and data space you aren’t really doing the job of software engineering.
My experience is that many people are deceived into thinking that language fluency is the core skill of software engineering, and coding bootcamps tend to foster that misrepresentation.
That doesn’t make them bad. It just means that often, thrashing around with no real knowledge of the tools and solving a problem with the tiny set of syntax you can get to work is much, much more educational towards the goal of becoming a software engineer than getting a good grasp of the language as it pertains to solving toy problems that require little effort to characterise.
Anyone that is willing to hack around a problem long enough that the solution emerges is doing the real job.
It doesn’t matter where they start, or how much they “know” about “coding”. The real task is to fully characterise the problem and data structures, and sometimes that emerges from the horrific beast that rises from the tangled mess of a hacking session, a malformed but complete caricature of the actual solution.
Then, all you have left to do is to code the actual solution, the structure of the algorithm and data has been laid bare for you to see by your efforts.
That, I believe, is the essence of software engineering.
cat /dev/urandom | hexdump -C | grep '9 ca fe'
cat /dev/random
causes my terminal to hang and my speakers start emitting a loud buzzing sound until the terminal is force-quit or system is restarted.I can understand the terminal not being able to handle the amount of data from /dev/random but for the speakers to start emitting sounds as a result of this is certainly very strange. Almost like /dev/random was being piped into /dev/audio or something. Anyone have an explanation?
An easy test would be to have something dump that bell character to the terminal as fast as possible and see if that does it, and also try /dev/zero to check that doesn't.
The key is to type ; before and after the answer.
The version I saw those years ago leaned on the god backwards theme, very dark, suggesting that the guy was dealing with obscure forces
PC Speaker - https://en.wikipedia.org/wiki/PC_speaker
ANSI Escape Sequences - https://en.wikipedia.org/wiki/ANSI_escape_code
I've obviously seen people who misjudge this (they can code, hire them), but ultimately, developing someone requires an amenable minds of both a mentor and a mentee on top of talent and persistence.
I just saw this and thought this was pretty cool! Running your command in nushell, and eventually aborting it gives the following output
^CError: nu::shell::terminated_by_signal
× External command was terminated by a signal
╭─[entry #28:1:32]
1 │ cat /dev/random | hexdump -C | grep 'ca fe'
· ──┬─
· ╰── terminated by SIGINT (2)
╰────
Just wanted to random praise the nushell team for this amazing level of detail!Guessing from the rest of your comment there, with the nifty examples that you might be one of those "old-skool hackers" yourself. ;)