I found this diagram on SO at one point but I can’t find the post and it is the best explanation I have found for how all of the files work for bash and zsh, each color is an individual path of execution (eg, follow the red line).
Bottom line though, it only really matters if you are overriding something that is already defined, for example I tell my users to use zshrc and I provide defaults and common things in zprofile because zshrc is executed last when they login.
I bet each step/arrow/decision had a good reason at some point, but most of them probably back when computers lived in caves and hunted their tapes using spears and rocks.
I feel like we’re slowly reaching a point where the complexity is collapsing in on itself - just look at the absolute chaos a modern web app is.
Is this a diagram for how it should work? Not how it actually works? Like I put my stuff in the ~/.bashrc, mostly because I think the debian one says like “put your fun stuff below here” or something. The green and grey lines go through the ~/.bashrc, but both of them go through the “no login” bubble in the diagram. But I know my ~/.bashrc works, so the diagram is a suggestion?
A lot of systems will call various inits from others to give you a more simplified flow. (Closer to what zsh does.) Check out some of those files in /etc/ it is calling as well as ~/.bash_profile. Or, you might not even be in a login shell!
Select the color which matches the steps before filenames ((non-)login and (non-)interactive), then follow that arrow the rest of the way. There’s more colors in Bash because Bash makes a distinction between remote and local shells.
Another way to look at the same data for Zsh (note: $ZDOTDIR will be used instead of $HOME if it’s defined at any step along the way):
File
neither
interactive
login
both
/etc/zshenv
x
x
x
x
${ZDOTDIR:-$HOME}/.zshenv
x
x
x
x
${ZDOTDIR:-$HOME}/.zprofile
x
x
${ZDOTDIR:-$HOME}/.zshrc
x
x
${ZDOTDIR:-$HOME}/.zlogin
x
x
${ZDOTDIR:-$HOME}/.zlogout
x
x
One confusion on the Bash side of the diagram is that you see branching paths into ~/.profile, ~/.bash_profile and ~/.bash_login. Bash will use for
And what’s confusing is that many times those files still manually call the others to make it more logical like zsh. That’s what I remember at least, it’s been quite a while since I used bash.
At least that’s actually easy and quick to do and is the only way of doing it. Centering a div however has 81639393 ways and it seems the one that works is different every time
Bro its so easy bro, just use flexboxgridcolumns its been a standard since 2010 just flex it bro you haven’t learned to flex yet just check w3c schools and add a flex you can polyfill it but don’t use that hacked one use the good flexpolyfill then { content-align-middle-child-elements: center-middle-true-neutral } so easy with flex bro
I know you meant this sarcastically, but yes, flex is a good option for centering something. Either that or setting the left and right margins of the element to auto, which is generally even easier.
Basically, if you’re in a flex container use flex, if you’re in a grid use grid, and if neither of those apply set the left and right margins to auto.
I’m not sure there’s any version of it for grids, but IMO grids are inherently more intuitive, so it may not be needed. Flexbox is the one that is hard to learn.
Well, flexbox and grid have different purposes in my opinion/experience. Personally I use grid for “top level” layouts like the layout of the whole site, while I tend to prefer flexbox for layouts inside the grid. Of course that’s just a rule of thumb, there are absolutely cases where this isn’t the best option.
Sure. Here you go. The green container should cover all red boxes in both cases. I’ve been bashing my head against this issue for a while, but, as far as I understand, this is a bug that’s never going to be fixed. Which sucks, because I wanted to re-design some of the apps in the horizontal metro-style scrolling manner for the bottom screen on my zephyrus duo, but this effectively prevents me from doing so (Unless I use grids and set positions manually).
Chromium is a superior engine, yes. But Chrome itself, at least in my eyes, looks to be the least capable browser out of the bunch. I’d rather Vivaldi if I had to switch.
EDIT: Alright, this is a terrible case because the parent element has flex and therefore no inline-flex is necessary there, but I’d argue it’s the parent element being flex that is redundant, rather than child element being inline.
Inline means that your element should be treated like text. If your element is not text, then you shouldn’t use inline. In this screenshot the element is text, so it’s ok.
Exactly. For every level of abstraction, the abstractor is the high level and the abstractee is the lower level. Those aren’t real words perhaps, but you get what I’m saying. It’s all relative along the chain of abstraction.
Is it a chain though? I think it’s more of a branching network that (almost?) always is stopped at quantum physics and it’s theories or some form philosophy.
It’s not really abstraction though. It is more like syntactic sugar. In stead of 1000111011 you say ADD, but it is still the exact same thing. There is no functional, prgrammatical benefit of one over the other. It’s just that asm is readable by humans.
At least thats as far as I understand asm. I haven’t gone beyond NandToTetris
I would argue they don’t know what that means really. Assembly is pretty much a mapping of words to machine code. It’s just a way to make machine code easier to read. It doesn’t actually change how it works.
A compiler re-arranges and modifies things so what you write isn’t the same as the final program that is created. With assembly it is. It’s not really an abstraction, but a translation. It doesn’t move you further from the machine, it only makes it so you’re speaking the same language.
Writing good comments is an art form, and beginner programmers often struggle with it. They know comments mostly from their text books, where the comments explain what is happening to someone who doesn’t yet know programming, and nobody has told them yet that that is not at all a useful commenting style outside of education. So that’s how they use them. It usually ends up making the code harder to read, not easier.
Later on, programmers will need to learn a few rules about comments, like:
Assume that whoever reads your code knows the programming language, the platform and the problem domain at least in general terms. You are not writing a teaching aid, you are writing presumably useful software.
Don’t comment the obvious. (Aside from documentation comments for function/method/class signatures)
Don’t comment what a line is doing. Instead, write your code, especially names for variables, constants, classes, functions, methods and so on, so that they produce talking code that needs no comments. Reserve the “what” style comments for where that just isn’t possible.
Do comment the why. Tell the reader about your intentions and about big-picture issues. If an if-statement is hard to parse, write a corresponding if clause in plain English on top of it.
In some cases, comment the “why not”, to keep maintenance programmers from falling in the same trap you already found.
Comments should be part of code review, having at least two pairs of eyes on comments is crucial. Something that’s obvious to one person maybe isn’t so obvious to another. Writing good comments is as hard or harder than writing good code, so having it checked for mistakes and quality is a must
Comments aren’t the actual documentation and aren’t a reason not to write documentation to go along with your code. Often I see larger projects where each class and function is documented in comments, but the big picture and the how and why of the overall structure is completely missing. Remember that in the real world you often have a lot of folk that need to understand how the code works, who aren’t programmers themselves. They can’t read the code or don’t have access to the code. Writing documentation is still important.
Please for the love of god when you change code, check if the comments need to be updated as well. Not just around the immediate area, but also the entire file/class and related files. I’ve worked on large codebases before with a high wtf factor and having the code do something different to or even opposite the comments is a nightmare. I’d rather have no comments than wrong comments.
This is a notoriously bad book. If you read the part about comments (which I don’t know about, and am willing to accept is good) make sure to skip everything else because Robert Martin is a fraud.
I would argue that if an if statement is hard to parse, replace the entire condition with simpler to read (but way more specific) variables that you assign values (the original condition expression) in the line above. No need for comments in that case
In this day and age of source control I don’t think this is fully necessary. If you want to know the why, you can look into the commit history and see which ticket is connected to it. There you might even see the discussions around the ticket as well. But this requires good source control discipline.
Why not put the “why” in a comment and save people the job of dredging through old commits and tickets to figure out what the code is for? I’d thank someone for saving me the hassle.
Going back to the original ticket can offer far more info than what any “why” comment can give. You can see how old it is, if there are any connected tickets, who were involved with it, step by step instructions how to reproduce the bug, etc.
In any modern IDE “dredging through old commits” means clicking a single button to see who last changed the line. From there it often makes sense to go look at the PR to see a higher level of what was changed. You cannot include all of that context in a single comment.
Don’t comment what a line is doing. Instead, write your code, especially names for variables, constants, classes, functions, methods and so on, so that they produce talking code that needs no comments.
Over and over and over again in my experience this just doesn’t work. Readable code does not substitute for comments about what the code should be doing.
We currently have a student for training and had her learn Rust. After two weeks or so, she told me that she had a really hard time finding anything about Rust, and it became clear that she was really confused and thought Rust was some fringe technology that no one uses.
And yeah, no, search engines just got obliterated by LLM spam since the last time she had to learn a new technology. Seriously, I remember getting better results about Rust back in 2018, when it was really still relatively fringe…
But then you need to know enough about the topic already to know what is stable and what changes with newer versions.
Like, the “web dev boot camp” course I got from UDemy a few years ago as a guide for building a web dev high school course: I recently went back to to look something up, and the whole thing has been completely redone start to finish. Makes sense, considering that it’s updated to the newest versions of Bootstrap and other libraries (and who knows what else).
I know nothing about Rust, but I would assume there are at least some libraries that have major new versions in the last couple of years which might change best practices somehow? idk. But the harder part is not knowing what you don’t know.
One search that was memorable to me was looking for dimensional information on a T-slot. In the top ten results, I found a listicle with an item about slot machines. LLM spam and Google’s relentless bullshit have poisoned the internet.
I’ve been into computers for over 20 years and I couldn’t tell you what uses rust. I am aware of it, but I am completely unaware of how narrow or broadly it is used. I keep forgetting people aren’t talking about the game.
I mean, to name a few projects off the top of my head:
Firefox
Android is migrating some of their internals.
The Linux kernel, Google Chrome, Thunderbird are preparing to use Rust.
Many Python programs now have Rust in there, because of the PyCrypto library.
Fish shell is in the middle of a RiiR.
I don’t feel like there’s a ton of big, mature projects yet, because of how relatively young Rust still is, but performance-critical or embedded software will be strongly considering Rust in the future.
And like C, Rust can be used to create libraries which can be called from practically any other programming language. I expect that to give it significant growth in the future.
Frankly, I do most of my searching these days directly on std.rs and docs.rs . But yeah, those are usually better as a reference than for learning.
You can look through lib.rs and awesome-rust.com , if you’re searching for a specific library.
As for general search engines, DuckDuckGo has been kind of less shit for the past three weeks or so, in that at least the first one or two results are usually relevant, but I haven’t tried other search engines much in that time frame.
Another tip is to make use Clippy. Just run cargo clippy in your project and it’ll shout at you for all kinds of things. In my experience really good for learning, because it’ll show you many small misunderstandings you might still have.
There are two common types of laser printers. Those that have special paper that react to heat, such as receipt printers, would fit the description.
The other laser printers… Hm, I don’t think your description is accurate either. It’s more that the laser electrically charges ink particles so that they jump on to a separate roller that gets rolled on to the paper.
I am not aware of any receipt printers using lasers - thermal printers have an array of resistors that get hot when necessary. I know how a laser printer works and it is hard to explain in 12 or so words. Inkjets are way easier, you can just say “squirt squirt oops”. Anyway…
A photosensitive drum gets a negative electrostatic charge.
A laser shining through a rotating prism scans lines across the drum’s surface. This removes charge from parts of the drum that should not be covered in toner.
A high-voltage corona wire inside the toner reservoir charges an amount of toner positively.
The charged drum rotates past the corona wire, getting covered in toner where its negative charge remains.
Paper is pushed against the drum and the powdery toner is transferred to it.
The paper continues into a fuser, a little oven where a heating element briefly makes the toner so hot that it melts, its powder particles making a permanent bond among themselves and with the paper. (The heater is usually stationary and heats the paper from below. The fuser drum that pushes paper against the heater can get sticky and pick up some of the toner, making images repeat down the page. This is the most common failure mode that cannot be resolved through regular maintenance such as replacing the toner cartridge and printing cleaning pages. However, almost all laser printers have a cheap fuser module or its drum available so it is usually worth replacing.)
It’s an accurate description of laser printers. The “powder” in the description are small plastic flakes (toner), and the paper is baked so that powder melts into it.
Receipt printers have no additional consumables beyond the paper. The heat itself is all the paper needs.
the search in amazon is so bad that you sometimes need high to low: some searches get you so much cheap unrelated trash, you have to sort high to low, and page down so you find the actual cheapest match quicker.
Great, now consulting a search engine on questions about vim the text editor will yield equally awkward results as consulting a search engine on matters concerning latex the typesetting system.
While I understand the idea behind the naming scheme of matrix, it’s an awful name. The naming behind synapse/dendrite is better I believe. But I don’t have a better idea.
It was renamed, thats what pisses me off. The client was renamed from riot (much more unique in software context) to element. I assume riot was not investor friendly which is a lame ass reason too.
I once applied for a “database admin” job at one of the big credit card companies. The job description was basically “run all our Oracle databases” and the salary was in the mid 2 millions USD, but I assumed that figure was typo’ed or something ( an extra 0 maybe?)
In the interview I learned that there was no typo and it was to be one of the seven people on the planet that run the databases for this credit card processor. They said “if the database goes down then we are losing billions of dollars a minute”.
Anyways I didn’t get the job, but they’re not all underpaid.
It really wouldn’t be all that bad. If they’re dropping $2m/y on a database admin, then their BCDR plan must be rock solid with crazy fault tolerances. I’d imagine outages are extremely rare.
But, if they’re dropping that kind of money, you’d have to be an expert in the field. Or know someone.
If you labor there’s only two ways you get paid your full worth: you own the means of your production or your boss is a chump. However much the job pays, you are going to have a larger impact than your salary (hopefully).
Describing the what also helps when you dabble in a new technology or little-used technology. It helps to explain to yourself what you’re doing and it helps in onboarding. “Hey, newbie, there’s a function in XYZ module that’s extensively documented. Look there for guidance.”
Unless you’re working with people who are too smart, then sometimes the code only explains the how. Why did the log processor have thousands of lines about Hilbert Curves? I never could figure it out even after talking with the person that wrote it.
I don’t code, at best I script. I’m a sysadmin, not a dev, so I play around in PowerShell mostly.
I just started to naturally do all of this. Not because I was taught to, but because I’ve written too many scripts that I later looked at, and thought, WTF is going on here… Who tf wrote this? (Of course it was me)…
So instead of confusing my future self, I started putting in comments. One at the beginning to describe what the file name can’t, and inline comments to step me through what’s happening, and more importantly why I did what I did.
The sheer number of comments can sometimes double the number of lines in my script, but later when I’m staring into the abyss of what I wrote, I appreciate me.
It’s a picture of the people who submit zero value comment spelling fixes to the Linux kernel so they can claim “I’ve submitted X patches to the Linux kernel” for KPIs or resume building
“Hey Bob, you’ve worked on the Linux kernel before, can you handle this CPU scheduler problem we’re having? Shouldn’t take you too long. We need it done before lunch”
Hey man, I once had an engineering exec (who didn’t last very long) who decided engineers would be stack ranked by SLOC. You can imagine how easy that metric was to cheese, and you can also imagine exactly how that policy turned out.
Give an engineer a stupid metric to meet, and they’ll find a stupid way to meet it for you, if only out of malicious compliance.
I’d have a field day with that. Max line length 70 or 75, excessively verbose function and variable names, triple the normal amount of comments, extra whitespace wherever possible, tab width 8, etc. The possibilities are endless for that metric.
I’m truly torn with this. The first one seems sensible (action -> target) and easier to read and reason about (especially with long names), while the other one looks more organized, naturally sortable and works great with any autocompletion system.
programmer_humor
Top
This magazine is from a federated server and may be incomplete. Browse more on the original instance.