programmer_humor

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

angelsomething, in Works on my machine

Literally why docker was invented

SpeakinTelnet,
@SpeakinTelnet@sh.itjust.works avatar

I have a love/hate relationship with docker. On one side it’s convenient to have a single line start for your services. On the other side as a self-hoster it made some developers rely only on docker meaning that deploying the stack from source is just an undocumented mess.

Also following the log4j vulnerability I tend to prioritize building from source as some docker package were updated far later than the source code was.

kratoz29,
@kratoz29@lemm.ee avatar

I love Docker because it is the only sane method to selfhost shit with my Synology NAS, and I love my Synology NAS because it is the only Linux interaction that I have (from my old MacBook Pro).

Zikeji,

The Dockerfile is essentially the instructions for deploying from scratch. Sure, they most likely only exist for one distro but adapting isn’t a huge chore.

You can also clone the repo and build the container yourself. If you want to update say, log4j, and then attempt to build it, that’s still entirely possible and easier than from scratch considering the build environment is consistent.

SpeakinTelnet,
@SpeakinTelnet@sh.itjust.works avatar

If I’m updating the source code already I might as well build my service from it, I really don’t see how building a docker container afterward makes it easier considering the update can also break compatibility with the docker environment.

Also adapting can be a pita when the package is built around a really specific environment. Like if I see that the dockerfile installs a MySQL database can I instead connect it to my PostgreSQL database or is it completely not compatible? That’s not really something the dockerfile would tell me.

evranch,

I really don’t see how building a docker container afterward makes it easier

What it’s supposed to make easier is both sandboxing and reuse / deployment. For example, Docker + Traefik makes some tasks so incredibly easy and secure compared to running them on bare metal. Or if you need to spin up multiple instances, they can be created and destroyed in seconds. Without the container, this just isn’t feasible.

The dockerfile uses MySQL because it works. If you want to know if the core service works with PostgreSQL, that’s not really on the guy who wrote the dockerfile, that’s on the application maintainer. Read the docs, do some testing, create your own container using its own PostgreSQL or connecting to an external database if that suits your needs better.

Once again the flexibility of bind mounts means you could often drop that external database right on top of the one in the container. That’s the real beauty of Docker IMO, being able to slot the containers into your system seamlessly due to the mount system.

adapting can be a pita when the package is built around a really specific environment

That’s the great thing about Docker, it lets you bring that really specific environment anywhere and in an incredibly lightweight manner compared to the old days of heavyweight VMs. I’ve even got Docker containers running on a Raspberry Pi B+ that otherwise is so old that it would be nearly impossible to install the libraries required to run modern software.

kurwa,

Now we just need to run docker inside the browser

eatyourglory,

Ah-ah! Now that’s progress!

ohlaph,

Docker has been a savior.

takeda, (edited )

Yeah, it “solved” the “it works on my machine” by bundling the machine with the code.

youtu.be/0uixRE8xlbY

Opafi,

Man, I really was interested in that topic, but that guy really can’t do talks.

takeda, (edited )

What about this? youtu.be/5XY3K8DH55M

Also I created this repo to create a reproducible sec environment for myself. I added other languages, but personally work mostly with python. It is basically resonating for handling all the boiler plate:

github.com/takeda/nix-cde

For packaging in docker I started to use nix2container project as it gives me a greater control over layers. So for example when I package my phyton app I typically use 3 layers:

  • python and it’s dependencies
  • my application dependencies
  • my application, which is very tiny compared to other two, so there is great reuse of the layers

The algorithm mentioned in the video also helps a lot with reuse, but the above is more optimized by frequency of how things typically change.

BTW: today I discovered this github.com/astro/microvm.nix I haven’t play with it yet, but in theory it would let me generate a microvm image (in similar fashion to generate a docker container) which would let me to run my app natively as a tiny VM on EC2 for example, and use only minimum necessary of a typical OS to run it.

GBU_28, in It's that time of the year again!

No closing semicolon, anyone got any extras to throw on this thing?

Moops, (edited )

At the very least I’d try to clean up that fuzzy condition on behavior to anticipate any bad or inconsistent data entry.

WHERE UPPER(TRIM(behavior)) = ‘NICE’

Depending on the possible values in behavior, adding a wildcard or two might be useful but would need to know more about that field to be certain. Personally I’d rather see if there was a methodology using code values or existing indicators instead of a string, but that’s often just wishful thinking.

Edit: Also, why dafuq we doing a select all? What is this, intro to compsci? List out the values you need, ya heathen ;)

(This is my favorite Xmas meme lol)

mp04610,

behavior is an ENUM.

moroni,
@moroni@lemmy.ca avatar

That’s a table scan, right there. Naughty.

epyon22,

; found this in the back for you should still work though

db2,

Can confirm.

krotti,

Honest question, which ones wouldn’t it work with? Most add a semicolon to the end automatically or have libraries and interfaces saved me a million times?

jaybone,

Usually with libraries like jdbc or whatever and prepared statements you don’t need the semicolon.

GBU_28,

Other reply s accurate but it’s always a good practice to include the semicolon else you can get

“Bobby tables’ed” look that xkcd comic up

docAvid,

I’m not sure how including a final semicolon can protect against an injection attack. In fact, the “Bobby Tables” attack specifically adds in a semicolon, to be able to start a new command. If inputs are sanitized, or much better, passed as parameters rather than string concatenated, you should be fine - nothing can be injected, regardless of the semicolon. If you concatenate untrusted strings straight into your query, an injection can be crafted to take advantage, with or without a semicolon.

GBU_28, (edited )

Yep it would only work if you didn’t sanitize a user input string in this case ‘nice’

They could write ‘’; drop table blah;

krotti,

Wouldn’t that still apply, if you can inject straight SQL, such as “query’ OR 1=1?”

pruwybn, (edited )
@pruwybn@discuss.tchncs.de avatar

Need to normalize the database. I would add a join to a BehaviorTypes table.

Edit: or, if the only options are naughty or nice, make it a boolean.

takeda,

You need semicolons if it is a script with multiple commands to separate them. It is not needed for a single statement, like you would use in most language libraries.

mellejwz,

If you don’t use a semicolon directly in MySQL it won’t do anything until you add it.

takeda,

In the MySQL client console where you can run multiple commands.

If you add semicolon in language library commands such as fetch() you will get an error.

fmstrat,

Can we get a SIMILARITY?

4am, in isEven API

Incoming trademark lawsuit from iSeven, the API that tells you if a number is seven or not

Toes, in Client did not pay?

That’s a bit more civil than redirecting the domain name to 2girls1cup

hakunawazo,

Or to Rick Astley for a more SFW version.

cybersandwich, in Not mocking cobol devs but yall are severely underpaid for keeping fintech alive

Cobol devs that we had (while we spent insane money to retire their systems) we’re getting 300-500k/year.

I’m sure companies are trying to rip off any young new entrants but 90k seems super low.

frezik,

Right, you can make that kind of money when you have 40 years of Cobol behind you. But even for new entrants, $90k seems low. There had better be a premium for dealing with old bullshit, especially when you’re probably damaging your resume in the long run.

Nollij,

90k sounds pretty standard for inexperienced (although maybe not first job) devs in general for most markets. Throw in factors like experience or skills in low supply and that changes pretty fast.

I know that COBOL isn’t going away anytime soon, but most companies have seen the writing on the wall for a long time. Anywhere that COBOL can be replaced with something more modern, it’s already underway. Some places even have a surplus of COBOL devs because of it. But there are countless places where it can’t be replaced, at least not reasonably.

The only way a COBOL dev is making $90k after 5 years is if there are very specific fringe benefits that make them not want to move along, or they are extremely naive about the market.

dan,
@dan@upvote.au avatar

Anywhere that COBOL can be replaced with something more modern, it’s already underw

Rewrites are extremely risky though, and some companies don’t want to risk it. That COBOL code probably has 40 years worth of bug fixes and patches for every possible edge/corner case. A rewrite essentially restarts everything from scratch.

Do you know of a decent sized company that successfully migrated away from COBOL? I’d be interested in reading a whitepaper about how they did it, if such a thing exists.

RaoulDook,

Yep I know a COBOL programmer and she drives a nice-ass Mercedes SUV and owns 2 houses. Making way more than I do.

h_a_r_u_k_i,
@h_a_r_u_k_i@programming.dev avatar

Better learn COBOL now.

makuus, in Fitbit Clock Face

That’s something I think I’d like to use, but I don’t know if could get over the fact that neither the date nor the time are in ISO 8601 format.

dep,
@dep@lemmy.world avatar

Lol I came here to say this

spader312,

The date format isn’t even human readable (at least in American). It should be Sun, Jan 14th

TheGrandNagus, (edited )

Considering it uses day then month, 24hr clock, and distance in km, I’m guessing the reason why it’s not “human readable in American” is because it’s intended to be “human readable for pretty much everybody else”

The date format isn’t incorrect at all

neutron,

I still think YYYY-MM-DD should be more apt for an international release.

MystikIncarnate,

IMO, that format is best for all releases.

You want to talk about sorting releases, ISO 8601 works with sorting and it’s still human readable.

My homies all start their date time stamped files with ISO 8601.

spader312,

I always start my files with iso8601, except on s3 it doesn’t like the colon. Gotta replace the colons lol

tgxn,
@tgxn@lemmy.tgxn.net avatar

They should put it as Unix epoch instead!

dejected_warp_core,

I once worked in a software shop where all release packages had the Unix epoch timestamp in the filename. Yes, these sorted brilliantly making it trivial to find the last one. But good luck finding a build from a specific date/time.

datelmd5sum,

just wildcard for n digits

Alivrah, in “It’s not that hard”
killeronthecorner, in Need a rust version too.
@killeronthecorner@lemmy.world avatar

Swift: Apple releases a new version of the castle and deprecates the princess before you finish your implementation

turing_spider574,

the author did another comic with swift and it’s pretty much what you said lol

toggl.com/blog/kill-dragon-comic

moomoomoo309,
@moomoomoo309@programming.dev avatar

I love the Lua one because it’s so true, LuaJIT is magic and Mike Pall is the only one who understands it as its creator.

fossilesque,
@fossilesque@mander.xyz avatar

The Python one should have been an environment joke.

Localhorst86, in Programmer tries to explain binary search to the police

“Exactly my point. We will not be investing an hour looking at the footage to pinpoint the time of theft, now get out!”

Rolando,

Show up with a box of donuts.

“Hey, look what I got for us to eat while looking at that tape!”

“Oh, I don’t think those donuts will last more than ten minutes here!”

“No problem, I know a way that won’t take that long…”

agissilver, in Why pay for an OpenAI subscription?

Yellow background + white text = why?!

PanArab,

Branding

merc, in 4 billion if statements

I like this bit at the end:

As a side note, the program is amazingly performant. For small numbers the results are instantaneous and for the large number close to the 2^32 limit the result is still returned in around 10 seconds.

caellian,

Really makes you question your sanity when optimizing jumps in code without benchmarks.

merc,

For a long time I’ve been of the opinion that you should only ever optimize for the next sucker colleague who might need to read and edit your code. If you ever optimize for speed, it needs to be done with massive benchmarking / profiling support to ensure that the changes you make are worth it. This is especially true with modern compilers / interpreters that try to use clever techniques to optimize your code either on the fly, or before making the executable.

Klear, (edited )

The first rule of optimization: Don’t do it
The second rule of optimization: Don’t do it yet (experts only)

Ephera,

I’m absolutely on-board …in application code.

I do feel like it’s good, though, when libraries optimize. Ideally, they don’t have much else to do than one thing really well anyways.

And with how many libraries modern applications pull in, you do eventually notice whether you’re in the Python ecosystem, where most libraries don’t care, or in the Rust ecosystem, where many libraries definitely overdo it. Because well, they also kind of don’t overdo it, since as a user of the library, you don’t see any of it, except the culmulative performance benefits.

merc,

Libraries are also written and maintained by humans.

It’s fine to optimize if you can truly justify it, but that’s going to be even harder in libraries that are going to be used on multiple different architectures, etc.

blusterydayve26, (edited )

I’m still mad he didn’t use the size of the number to tell the system which block to read first. I feel like that would be a great use of division or maybe modulus?

merc,

I just like how he used “% 2” in the Python code he used to generate the C++ code.

magic_lobster_party, in Bill is a pro grammer

x += 1; // Increases x by one

towerful, (edited )

// increase the dynamically allocated memory space of a word sized integer stored at the memory address represented by the symbol “x” by the integer 1 and terminate the instruction

Anders429,

Why the heck does it need to be dynamically allocated? Just put that puppy on the stack.

towerful,

That’s what it used to do.
But it was a bug, and the code has been fixed.

morrowind,
@morrowind@lemmy.ml avatar

Wait why is it dynamically allocated and why are you increasing the memory. Something is very wrong here

floofloof,

Found the bug. Thank goodness for comments.

Anders429,

Oh, is this what they meant by “commenting your code”?

ZILtoid1991,
@ZILtoid1991@kbin.social avatar

x++; // Move X position forward by one

There, I made that kind of comment more useful!

LostXOR,

x++; // Set x to the incrementation of the value of x
Much better.

Jakylla,
@Jakylla@sh.itjust.works avatar

// Move to the right

autokludge, (edited )
@autokludge@programming.dev avatar

…Years later
x += config.increment; // Increases x by one


<span style="color:#323232;">"""
</span><span style="color:#323232;">config.yaml
</span><span style="color:#323232;">increment: -2
</span><span style="color:#323232;">"""
</span>
redcalcium, in Good luck web devs

Not on wayland, right? Time to pester wayland devs to add this important missing features!

nickwitha_k,

Probably would fall into scope of a compositer in Wayland, rather than the protocol. I suspect it originated with old CRT displays. Sometimes they can appear scan diagonally.

Even without that usecase, I think it’s great to have around in order to support novel displays and display-like devices.

fibojoly, in Not mocking cobol devs but yall are severely underpaid for keeping fintech alive

That’s because the COBOL OGs are retired/ing and the industry has been training young people telling them “yeah, sorry, this is all we can pay you”. Here in Europe, they’ll take unemployed people from a different industry, put them on a training course, and bang! you’ve got a grateful new dev who doesn’t know how much they are worth.
You just gotta keep spreading the message. I keep happily sharing my salary, especially with younger, less experienced devs, so we can all win better.

Swedneck,
@Swedneck@discuss.tchncs.de avatar

programmers desperately need to unionize

fibojoly,

For real. Even just talking to your fellow coding monkeys helps. It’s ironic that for example here in France, despite all our workers rights and revolutionary tradition, speaking about your salary is still a social faux-pas. And who benefits? Certainly not us.

andioop,

I’d understanding actively pressuring someone to share their salary being a faux-pas. Admittedly, just sharing your own may make some people feel pressured to share theirs out of reciprocity, but just sharing your own salary generates nowhere near the same amount of pressure as outright telling someone “share your salary or you’re a bad person on the side of The Man!”

I hope the amount of people sharing their salary increases and talking about it becomes normalized.

Asafum,

Man I’d swim to Europe if some company wants to swoop me up and train me for something that valuable lol here in the States I have to not only pay for the training out the nose, but also find the time to do that while still working my regular job lol

fibojoly,

Well, you could do like many US people and visit Ireland, I suppose :)

nullPointer, in Programmer tries to explain binary search to the police

just tell them there is a black man at the moment of theft, they will get on it lickety split!

Cannacheques,

Sad meme very relevant

Grimble,
  • Binary search: O(log(n))
  • Sequential search: O(n)
  • Linear search: O(n)
  • Police ethnicity database search: O(0)
ScrewdriverFactoryFactoryProvider,
@ScrewdriverFactoryFactoryProvider@hexbear.net avatar

No need to search when you already have someone you wanna pin it on.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • programmer_humor@programming.dev
  • localhost
  • All magazines
  • Loading…
    Loading the web debug toolbar…
    Attempt #

    Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20975616 bytes) in /var/www/kbin/kbin/vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php on line 171

    Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4210688 bytes) in /var/www/kbin/kbin/vendor/symfony/error-handler/Resources/views/logs.html.php on line 36