There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

programmer_humor

This magazine is from a federated server and may be incomplete. Browse more on the original instance.

nyan , in Recursion

Half-pull the lever so that the points get stuck midway between the two tracks. That should derail the trolley. Someone could conceivably still get hurt, but it improves everyone’s chances.

(What? You mean it isn’t a literal trolley that has to obey the laws of physics? Damn.)

cicadagen ,

News next day, 10 dead in derailment.

EmoDuck ,

Ten baby puppies to be exact

explodicle ,

Philosophy problems vs all real world problems

nothacking , in Bleeding edge tech

Is this part of a Hi-Lo implementation for blackjack? (Also, ewww mixed types)

obosob ,
@obosob@feddit.uk avatar

Yeah, just use a char for card and test


<span style="color:#323232;">if(card &lt; '7') count++;
</span><span style="color:#323232;">else count--;
</span>

Or something, don’t mix types.

Hexarei ,
@Hexarei@programming.dev avatar

The cards should just be numbers, and an enum should be used for display names

obosob ,
@obosob@feddit.uk avatar

Chars are just numbers, but yeah, an enum would work fine too, sure. The only advantage with using a char for it is that there’s no conversion needed for outputting them into strings so it’s a little easier. Less code, very readable, etc. Though yeah, thinking about it JQKA wouldn’t be numerically in the right order which could cause issues if the program did more than just implement HiLo

nothacking ,

Well that won’t work for 7, 8 or 9.

obosob ,
@obosob@feddit.uk avatar

I didn’t notice that 7,8,9 had no effect on the count. My bad.

MonkderZweite , in Golang be like

Comment the unused variable out and no security hole gets accidentally shipped.

Crashumbc , in Golang be like

The best part of these threads is no matter what someone comments, at least 2 people will reply either correcting or “clarifying” the original commenter.

Lol

s12 , in Scammers vs Impossible Password Game

The scammers let Paul be slain.

IntentionallyAnon ,

Avenge Paul!

EsteemedRectangle , in Ouch

This clean code stuff is being taken too literally

sv1sjp , in Why are you doing me like that, LinkedIn?
@sv1sjp@lemmy.world avatar

I thought all companies are dying to find a CS boi, how they can even think to reject us?

newIdentity ,

They’re searching for good CS bois :(

Bipta ,

oh fuck

LemmyNameMyself , in Linux Best Practices
@LemmyNameMyself@lemmy.world avatar

fr, fr, no preserve root

danwardvs ,

ong ong no cap

philluminati , in Supermarket AI meal planner app suggests recipe that would create chlorine gas

…but does it taste good?

kryllic ,
@kryllic@programming.dev avatar

Not bad, mustard is a bit strong tho

Feyter , in Sometimes there is a better choice than Javascript

I thought that’s what GIF was created for… Even if the original introduction of it is saying something completely different.

kogasa , in python &lt; shell (for scripts)
@kogasa@programming.dev avatar

I can’t think of a single reason to use bash over Python. Anything you can do in bash can be done in pure Python. Unless you’re working in some embedded environment it’s a non-issue to install a Python interpreter (you certainly already have one). I would only use sh/bash for packages I’m distributing to avoid the external dependency, and then only if it’s a relatively simple script.

Reborn2966 ,

i would not run a python script with root.

ultimitchow ,

i run my daily NAS backup python script with root.

AProfessional ,

It is fine, just should be more careful with modules used.

kogasa ,
@kogasa@programming.dev avatar

That’s fair.

alexcoder04 OP ,
@alexcoder04@programming.dev avatar

Bash is much better for doing file operations and piping the output across multiple commands

corm ,

Better than subprocess.getoutput?

MonkderZweite ,

Why is always about bash? POSIX shell scripts run everywhere.

AProfessional ,

BASH has some useful features and I’ve literally never had an environment with bash unavailable (even if a package is needed, so what).

MonkderZweite ,

MacOS ships only 3.something version, which has some compatibility issues with Bash 4+.

AProfessional ,

brew install bash

IRQBreaker ,

Granted, it’s a kind of niche use case but in the embedded world there’s usually size constraints which prevents a full blown bash installation.

However, things are better now than 20 years ago. Flash is cheap.

bort ,

I know whatever environment I run my shell script in has sh, I can’t rely on (the right version of) python being there.

kogasa ,
@kogasa@programming.dev avatar

Why not?

Chunk ,

Because you could be on another machine that doesn’t have Python 3.X it only has 3.X-1. or you could write code for Python 3.12 and then four years later no one has 3.12 anymore.

Sometimes you need to download packages from pip but pip might not be available or you may be hitting your company’s internal pip mirror.

kogasa ,
@kogasa@programming.dev avatar

How often are you writing scripts that accidentally require a specific minor version of Python 3 to run? If you have dependencies, 1) you’re no longer scripting, and 2) you need to manage your runtime environment anyway.

RubberDucky ,

Runtime environments can change often, if you need to install your application on a ton of PC’s you don’t want to install python version 3.X on all of those instead you could just compile it into a native binary, pip is the most unsafe hell

kogasa ,
@kogasa@programming.dev avatar

If you’re compiling a native binary you DEFINITELY aren’t in scripting territory anymore.

CoderKat ,

Python is superior for string anything (parsing, searching, manipulating). But Bash is much simpler for running existing CLI tools. Plus you should already be using Bash as a simple terminal language already, so wrapping what you’re used to into a simple script flows naturally.

Eg, if I have some admin tool for updating a user thingamajig, a common scripting need is just running that tool for every user in a file (or the output of another command). The string manipulation that often requires is annoying in bash, but running the commands is easier than Python.

kogasa ,
@kogasa@programming.dev avatar

If what you’re doing is essentially a few shell commands, then you may as well put it into a script. If you’re talking about how “elegant” your shell scripts are and comparing them to Python, you’re probably wrong and should be using Python.

Potatos_are_not_friends , in Shit Happens

Frontend developer: Listen I make pretty websites. This is a backend problem

whereisk ,

Backend developer: the buttons disappear only on smaller screens - looks like a frontend problem.

hperrin , in rm -rf /

What? Why would you need to do this? Is someone fucking with the .git directory?

Ephera ,

It does sometimes happen that something in there just breaks and isn’t easy to recover. But it can also be a matter of (inexperienced) devs just deciding, fuck it, I won’t try to merge it, I’ll just copy my changes elsewhere and throw away the repo.

nous ,

I have never had git get into a state I cannot get out of. Even if that is a reset, checkout or clean. And those are very rare. How are people breaking things so often.

Learn the tools you use daily, it saves you a lot of headache in thelong term.

Ephera ,

Oh yeah, but I’m talking about the internal Git state just genuinely being broken, for example: stackoverflow.com/…/git-commit-stopped-working-er…
Ultimately, if you spend half an hour debugging that, it just starts being a waste of time compared to cloning anew.

As for how to merge, yes, one should learn that. The problem is that the complexity of the code changes adds on top of whatever insecurities you might still have with Git.
I did put “inexperienced” in braces there, because even as an experienced dev, merges are sometimes just not worth doing. In that case, you could just checkout the branch a second time, but well, still not that different.

RecluseRamble ,

But it can also be a matter of (inexperienced) devs just deciding, fuck it, I won’t try to merge it, I’ll just copy my changes elsewhere and throw away the repo.

Pretty sure that’s actually it. Git has a learning curve and, for example, some naive rebase not working out as intended can be scary if you don’t know what you’re doing.

SirQuackTheDuck ,

I’ve been doing this yesterday. Not because Git broke, but since Intellij kept pulling invalid configs from the cache, and that was based on some kind of path identifier it seemed.

Johanno ,

Gradle!

Fucking gradle. I do config stuff, rerun gradle error here, I fix the error rerun gradle: sth. Violation error.

Ok intellij invalidate chaches and restart… Still same error.

Fine I’ll do it again


<span style="color:#323232;">git add. 
</span><span style="color:#323232;">git commit -m "stuff"
</span><span style="color:#323232;">git push
</span><span style="color:#323232;">
</span><span style="color:#323232;">rm -rf repo
</span><span style="color:#323232;">git clone repo
</span>
iammike ,

You can probably use something like


<span style="color:#323232;">git clean -xdf
</span>

To get rid of all the artifacts not tracked by git, in this case it’s virtually the same as deleting the repo and re-cloning it.

NOTE: Make sure everyhing is staged, otherwise that data is gone

PotatoesFall ,

People inexperienced with git can get stuck after doing some funky checkout / rebase stuff. If you don’t know your way around git so well, I guess this is the obvious solution.

Prunebutt , in rm -rf /

I feel dumb: Why git rm -rf and not rm -rf? O.o

JPDev OP , (edited )

git rm -rf is only usable within the scope of the git repository and removes files in the staging area and working directory but doesnt affect untracked files or .git. rm -rf affects everything. For this case rm -rf probably would be the better option

edit: did a quick edit on the meme to change it to rm -rf since it makes more sense

leisesprecher ,

Never heard of it, makes total sense, but I’d guess 95% of developers just nuke the directory raw.

Prunebutt ,

That’s the joke, yes.

Prunebutt ,

Thanks

BatmanAoD ,

rm - rf is the only version that makes sense, since the only reason to delete and re-clone is to recover from an unexpected .git/ state, and git rm won’t remove that.

glizzyguzzler , in OneDrive deleted my files!
@glizzyguzzler@lemmy.blahaj.zone avatar

One drive does suck nards, but for your double clicking; logitech has been using shitass switches to detect clicks for a while now. They sooner rather than later fail to click once. Only solution I’ve found is to replace the switches (hard mode), or keep using the logitech mouse I have from 2009.

It’s sucks, but you just gotta go for another brand. Even razer doesn’t have such a rampant double click problem.

Logitech enshitified their dominant market position by cheaping on switches - works for them, they sell more mice (if you don’t put together they’re the source of the problem and it’s not a one-off issue).

IMongoose ,

MX518 gang

glizzyguzzler ,
@glizzyguzzler@lemmy.blahaj.zone avatar

Mine is a G5, which looks like it lost the MX518’s sick ass faux metal and instead gets what I can best call “cracked lightning?”. I was too young to figure out mouse buying so the fam’s resident nerd chose that for me - I thank her to this day

Passerby6497 ,

I had a G5 for close to a decade and I miss that heavy little bugger. I’ve got a G502 right now and its rather good, but the max weight isn’t as heavy as my old one.

glizzyguzzler ,
@glizzyguzzler@lemmy.blahaj.zone avatar

I had to replace the cable on my G5 after it frayed after about a decade, but after that it was back to it. Sorry you lost yours, and I hope you never double click on the G502!

(All the weights gang, build that wrist strength)

Passerby6497 ,

Yep, that’s what happened to mine. The jacket frayed until the wire got out and strangled itself. My 502 is still rocking strong after 5+ years, but here’s hoping your g5 sticks around for a while, that was a great mouse.

trollblox_ ,

every razr product I’ve owned has been e-waste quality. never buying from them again

glizzyguzzler ,
@glizzyguzzler@lemmy.blahaj.zone avatar

That’s what I mean, even e-waste quality razer isn’t double clicking!!

trollblox_ ,

I’ve never had a problem with my g502 hero, and it’s about 4 years old

glizzyguzzler ,
@glizzyguzzler@lemmy.blahaj.zone avatar

Mine clicked just after a year :( so it’s waiting to get switches soldered cause I ain’t buying a new one but don’t have the will to do it yet cause I got my ancient G5 still. (I live in America, so doing warranty shit is a hassle, and I surmised it would fail again so I should just fix it now)

abcd ,

That’s the reason why I switched to a steelseries mouse with optical switches. The mechanics look like they should last forever.

Morphit ,
@Morphit@feddit.uk avatar

The switches do suck but they can usually be revived with contact cleaner. If you open the mouse you can spray around the switch plunger or better yet, pop off the top half of the switch case and spray the contact directly. That completely cleared up the double click on my G402 and even revived an old MX510 that was missing clicks.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines