Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Search - "util"
-
INTRODUCING:
---
SYNTAX HIGHLIGHT BOT
---
I have lots of ideas.
This was one of them.
Last week I was playing around with https://carbon.now.sh and found it quite cool!
Then I thought: https://carbon.now.sh supports Twitter. Cool. But what about devRant?
So yeah, then I got the idea: A devRant Bot that generates https://carbon.now.sh images!
Now, 4 days and 800 lines of code later, the bot is ready!
I even had to rewrite the notification checking code 4 times, because none of them worked perfectly...
But on the other hand, the final solution is so good that I want to keep it a secret for now ;D
---
HOW TO USE:
All you need to do is to mention the bot!
Example:
<rant>
@highlight
console.log('Hello World!');
</rant>
The bot then generates your syntax highlighted code (as an image) and posts it as comment a few seconds later.
Everything before the "@highlight" will be ignored!
Example:
<rant>
Look at this code:
@highlight
function add(a) {
return a + 1;
}
</rant>
Here, "Look at this code:" will not be included in the syntax highlighted code.
If the comment text ends right after the "@highlight", the bot wont reply, btw.
---
THEME SELECTION:
That's not all!
You can even select the theme for your syntax highlighted code!
Just go to my other rant and read the instructions!
The theme will be used for every image the bot generates for you!
Link:
https://devrant.com/rants/2178551
---
Feel free to ask any questions in the comments!
My creator (and father thanks to @rutee07), @Skayo, will try to answer all of them!
P.S.: Speaking of @rutee07: I'm a girl. (Also thanks to him)167 -
I have never doubted my abilities more, before this happened:
I got a Linux VM on Azure, downloaded apache httpd source which I proceeded to configure, make and install.
As expected, install failed with something related to apr and apr-util.
Searched several mailing lists, tried out several configure options, nothing worked..
After almost an hour, it stuck to me, all I had to do was "sudo yum install httpd" !!!
Disappointed that I missed something so simple, but when I did that, it came back with 'Nothing to do'...
Realized, httpd was pre-installed in that VM.. I just had to start the service !!!
:facepalm1 -
"I'm almost done, I'll just need to add tests!"
Booom! You did it, that was a nuke going off in my head.
No, you shouldn't just need to add tests. The tests should have been written from the get go! You most likely won't cover all the cases. You won't know if adding the tests will break your feature, as you had none, as you refactor your untested mess in order to make your code testable.
When reading your mess of a test case and the painful mocking process you went through, I silently cry out into the void: "Why oh why!? All of this suffering could have been avoided!"
Since most of the time, your mocking pain boils down to not understanding what your "unit" in your "unit test" should be.
So let it be said:
- If you want to build a parser for an XML file, then just write a function / class whose *only* purpose is: parse the XML file, return a value object. That's it. Nothing more, nothing less.
- If you want to build a parser for an XML file, it MUST NOT: download a zip, extract that zip, merge all those files to one big file, parse that big file, talk to some other random APIs as a side-effect, and then return a value object.
Because then you suddenly have to mock away a http service and deal with zip files in your test cases.
The http util of your programming language will most likely work. Your unzip library will most likely work. So just assume it working. There are valid use cases where you want to make sure you acutally send a request and get a response, yet I am talking unit test here only.
In the scope of a class, keep the public methods to a reasonable minimum. As for each public method you shall at least create one test case. If you ever have the feeling "I want to test that private method" replace that statement in your head with: "I should extract that functionality to a new class where that method public. I then can create a unit test case a for that." That new service then becomes a dependency in your current service. Problem solved.
Also, mocking away dependencies should a simple process. If your mocking process fills half the screen, your test setup is overly complicated and your class is doing too much.
That's why I currently dig functional programming so much. When you build pure functions without side effects, unit tests are easy to write. Yet you can apply pure functions to OOP as well (to a degree). Embrace immutability.
Sidenote:
It's really not helpful that a lot of developers don't understand the difference between unit, functional acceptance, integration testing. Then they wonder why they can't test something easily, write overly complex test cases, until someone points out to them: No, in the scope of unit tests, we don't need to test our persistance layer. We just assume that it works. We should only test our businsess logic. You know: "Assuming that I get that response from the database, I expect that to happen." You don't need a test db, make a real query against that, in order to test that. (That still is a valid thing to do. Yet not in the scope of unit tests.)rant developer unit test test testing fp oop writing tests get your shit together unit testing unit tests8 -
These postings on angel.co
I swear to God it's like I've uncovered a conspiracy theory.
I had been searching for a side project now that holidays are coming and I really don't wanna get bored.
Applied to a few companies. About 5 of them "responded" with an acceptance. I write them my interview timings and all that's required.
Nothing. Nothing for like a solid week and a half.
Meanwhile I applied to more companies and still the same thing.
I decided to manually mail their companies regarding the process, so that I can, preferably, move on to other ones if they have rejected the application (which they obviously hadn't)
I get mails from almost all the companies with some or the other variant of "We were waiting for your reply to proceed"
I tell them I had replied over the conversations and they said they never got a message.
Now feeling that this might be angel.co at fault. I wrote a request to look into the issue. Meanwhile I tested the system using a friend's account as a recruiter and testing myself.
Unsurprisingly it was working flawlessly.
Narrowing it down to the companies then.
I sent a document with my findings to each of the companies and pretty much 50% of them stopped with replying.
The rest confirmed that they hadn't received any mails regarding the same and they saw no mail resembling the one I tested with my friend.
Kinda confusing but I asked them to look into it.
Meanwhile mail from Angel returns saying that their system is working perfectly fine even around my region. So idk what was the problem
I got a mail 3 weeks after the first mail to the company. They had been using a utility to auto-accept/reject profile applications. This util sent a lot of mails, even for rejections, to their mailboxes, filling them.
So they decided to remove these emails automatically by marking them spam. Apparently, the interview confirmation messages also count as these emails and were automatically archived. Thus removing my responses to those companies.
Idk if this is widespread issue because only one company has responded to me yet.
I'm still livid with this shit.5 -
I was excited to get back to work on a major project today. I was thinking in the shower, on my bike, on the train, on the walk from the train to my office, on the elevator, about how I would approach it and came up with a good plan. Again, I was excited.
Then, on our standup call, a dude says he needs access to the util server I manage, and just happens to not know shit about Linux. So I spend the next hour and a half walking him through simple SSH commands, and completely lose my train of thought for the project I was planning to tackle.
Now, I'm seething on the toilet, hoping to reset.4 -
Oh I have quite a few.
#1 a BASH script automating ~70% of all our team's work back in my sysadmin days. It was like a Swiss army knife. You could even do `ScriptName INC_number fix` to fix a handful of types of issues automagically! Or `ScriptName server_name healthcheck` to run HW and SW healthchecks. Or things like `ScriptName server_name hw fix` to run HW diags, discover faulty parts, schedule a maintenance timeframe, raise a change request to the appropriate DC and inform service owners by automatically chasing them for CHNG approvals. Not to mention you could `ScriptName -l "serv1 serv2 serv3 ..." doSomething` and similar shit. I am VERY proud of this util. Employee liked it as well and got me awarded. Bought a nice set of Swarowski earrings for my wife with that award :)
#2 a JAVA sort-of-lib - a ModelMapper - able to map two data structures with a single util method call. Defining datamodels like https://github.com/netikras/... (note the @ModelTransform anno) and mapping them to my DTOs like https://github.com/netikras/... .
#3 a @RestTemplate annptation processor / code generator. Basically this dummy class https://github.com/netikras/... will be a template for a REST endpoint. My anno processor will read that class at compile-time and build: a producer (a Controller with all the mappings, correct data types, etc.) and a consumer (a class with the same methods as the template, except when called these methods will actually make the required data transformations and make a REST call to the producer and return the API response object to the caller) as a .jar library. Sort of a custom swagger, just a lil different :)
I had #2 and #3 opensourced but accidentally pushed my nexus password to gitlab. Ever since my utils are a private repo :/3 -
http requests
literally the bread and butter of any software engineer building applications, you would ASSUME they know what they are doing...
and you're gonna write a seperate http get and post function for every type you have?
apparently stuff like this that is written by "senior" developers? you don't even have a basic understanding of software...
i'm won't do it that way, becuase i'm an adult, not a child
what i'm going to do is write a HTTP request util function that can be used for any type and HTTP verb. DRY, single responsibility, etc.
imagine making the http request itself a responsibility coupled to the type 😂😂😂😂
get a clue and come back later
i can't tell anymore if my thoughts are so outlandish compared to everyone else that no one understands them, or if i've been doing this so long that i just immediately understand what needs to be done and don't know how to explain it to anyone else anymore (or take the mental effort to)
peace out
oh P.S.: imagine thinking the SOLID principles are only applicable to OOP
stay safe out there folks, its getting more painful every day8 -
Every fucking time I install a new npm package
npm WARN deprecated core-js@2.5.7: core-js@<3.0 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated fsevents@1.2.9: One of your dependencies needs to upgrade to fsevents v2: 1) Proper nodejs v10+ support 2) No more fetching binaries from AWS, smaller package size
npm WARN deprecated gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/...
npm WARN deprecated browserslist@2.11.3: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated domelementtype@1.3.0: update to domelementtype@1.3.1
npm WARN deprecated circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
npm WARN deprecated flatten@1.0.2: I wrote this module a very long time ago; you should use something else.21 -
Currently working on thesis:
Me:(Using iText to convert PDF Files to String)
Groupmate: I think the conversion makes our program slower.
M: Fine, I'll search for other libraries
M:(Finds Apache PDF Box and another open source PDF Util)
M:(Tests using nanotime then converted to seconds)
PDFBox: 24.3464 seconds
PDFUtil : 20.8365 seconds
iText : 7.937 seconds
://///// -
I just found an old util class of mine for messing with some data before sending it to the api.
The methods are called:
burnId
mutilateDate
cleanseDates
cleanseData
unfuckLocalDateString
fuckDate
I love it. -
My last post was a year ago. What brought me back here is the ability of AI to agree and apologize to anything and everything, while producing the worst hopeful code.
4 days I wasted, trying to make an android audio visualizer, but AI... sigh.
It gave me the wrong structure of FFT bytes emitted. I corrected it
It gave me the wrong logarithm calc, I corrected it
It gave me the wrong sampling rate, I corrected it.
It gave me the wrong texture order, I corrected it.
It gave me the wrong glsl sample2d, I corrected it.
It gave me the wrong textureID generation, I corrected it.
It gave me a render which was about 10 fps, I found out that instead of using native onDraw, I had a fcking delta time in my shader. I almost corrected it, I gave up
Lets go to code generators with Annotations.
Like always, starts very positive, until I start to correct it.
It gave me the wrong file locations, I corrected it.
It gave me the wrong order of find copy modify and write to .build, I didnt correct it.
It gave me regexes to find annotations. Im like So whats the use of an "ANNOTATION PROCESSOR"
It apologizes and used a fucking regex in the processor,..... I didnt correct it, in the end, I was left with a separate module, targetting iOS Android and JVM, with an annotation processor implemented in jvmMain, which tries to modify commonMain src by finding annotations with regexes, which wont run on app build or app sync project, but only on java -jre command pointing to that fucking .java class in that module, which takes at least 2 mins to run, and Finally generate 0 files.
I needed to rant, I understand LLMs are just models of words built and stolen from the most intelligent and dumbest people out there. But Im an idiot for getting my hopes high. I cant build anything new and unheard of. I used to do that. I once made a textView + image print util for a bluetooth printer just to say FU to libraries and heavy sdks. like literally rasterizing shit to bluetooth packets. I needed to let off some steam. I havent been here in a year so I dont know what reactions I can get from this rant. I bet someone will just say yeah we tired of 'Fuck AI' rants. but shit, it hurts. When I gave up on that visualizer, I downloaded an app, I think its called project M, like in reference to MilkDrop.. like the Winamp Milkdrop. I opened it, played something on spotify, and let my eyes go blind9 -
Wrote a util program/script last week only to realize today that I already had one which actually did better....
Just couldn't remember it last week. -
Had a production issue last night where db hung so today whole team was investigating.
I checked the graphs and noticed a huge spike in inserts during a few hours. Normally it's distributed evenly through the day.
Emailed team with screenshots and also mentioned it to someone but then forgot to follow up... I assumed they were looking into it (I don't work in the same office as them).
Someone just logged in and notice the same thing happening right now... which made me remember.
So I asked him, did you see my email?
Silence....
Also got another guy doing a sort of code review on a util app I wrote that deletes certain records from our db and why I'm not just using SQL. I tools him the most obvious way doesn't work I tried but he won't believe me so let him do try it himself.
Anyway, these few days just feels like "why doesn't anyone listen to me?" ... and just feeling overqualified and sort of not part of the team again....3 -
I fucking hate the way we have test in our company. They're worse than useless. They test internals but don't test the actual fucking behavior. I just broke the dev branch with a stupid mistake - because of course one of the core behaviors of our app is not tested. But I had to fix tests in three places just because I removed a useless util in favor of using a built-in JS feature.2
-
This is Node.js FYI
Exporting a single class from a file called util.js. This class only has static methods. Each method is a util function. No fucking way of importing a single method. Class abuse?6 -
Working with new guy who is "senior" is such a pain. We had a factory file that is used to populate tables in endpoint tests. The new guy decided to add a static util method called createTestRecord() to a query builder model. Fucking query builder calls in a static method in a query builder class. I send him messages expressing concerns regarding his approach but never got anything back. The guy just ignored me and asked me to review his pr.
I am leaving in 4 months. Release me from my misery. Fuck my life5 -
Here's a story about why putting util functionality in a generic parent class is baaaad. So we run into a bug where an online shop module we develop causes a third party module to break the entire site until the session expires.
We track the bug down to the fact that the third party module has added some functionality to the part of the shop that deals with the cart and that functionality expects that one of the module's libraries is initialized. But as it turns out another of that module's libraries that is loaded earlier is fetching the cart and thus triggers our module which adds gifts to it.
Now, since we need a deeper integration with the cart to make gifts depend on the cart contents we call the part of it that now depends on the third party module's unloaded library.. So we think changing the order the third party libraries are loaded will fix the issue, only to discover the unloaded one is a child class of the first and the cart is fetched in the parent constructor. The parent of course then turns out to be a generic util class, inherited by all the module's libraries, so whatever order we load them in, the constructor is always called, so we had no other choice but to dynamically disable our module during the initialization of those libraries and then patch the updated cart contents into them after they've all been initialized.
At this point we get curious what that module's doing with the cart contents only to discover.. nothing. It's just that the parent class is full of utils and data fetching that the vendor reuses in all their modules.. -
Am I the only one that in order to keep C code clean has a horrible file with macros and util functions?4
-
I have a great chemistry with this coworker.
He lacks some depth of android knowledge but is always very interested in adding new google libs to the project, so we often discuss and come up with the safest, scalable solutions.
He is SE2 and I am SE1.
But one thing that is interesting about him is the way he gives estimations for the tasks. He takes usually that much amount of time that i would take, for a task, but he would quote half the time estimates.
the bosses usually come on the last days to check the feature demo, but QAs gets the first build when a task is completed. I have seen his first builds that goes to QA and most of the time, boy it has some amazingly stupid bugs.
dude would just put a util function, then run the build, if everything compiled, he would just give the build to QA directly. he wouldn't even check that the util function gave an expected output or not.
He is simply wasting QA time n efforts, and risking product quality by not testing enough, but he almost always gets a clean chit for this behavior just because he did the work super fast.
Dude is super cool and i don't envy him for his good luck, but rather think of him as an inferior dev. However bosses think of him as a better dev and my TL even once told me to "be like him"
So i guess this is how corporate works. I will try to apply this in my next role in current/next organisation.3 -
So I went to a service center to repair my cracked mobile screen. I thought that the process would be completed in a few hours so I didn't took any backup.
Guy: You need to hand over your device for 2 days.
Me: Okay, no problem just fix it. (At this point i was desperate because a bunch of shops already told me that the complete model needs to be replaced)
Guy: You also need to remove any screen lock from it.
Me: But why?
Guy: We need to test once we fix the display. The repair util can be accessed by an inbuilt app.
Me: *Internally screams, my pr0n collection, my browsing history...*
Me: Just give me a minute. *Uninstalls a bunch of apps*.
Me: Handing the device to him. *crying internally and thinking if anything was left*.
Me: While returning, Fucking fuck now how am i gonna suppose to book myself a cab.. *facepalm myself with a fist*1 -
OOP is all about code reusability until you really want exactly the code Foo with non-pure functions in all your classes. You end up almost rewriting all subclasses' properties into the superclass to silence typecheckers. Is there no "I know what i'm doing, please just transpile/compile this piece of logic into these 20 places I need?" You end up doing it the functional way, dumping refs and params into some shared util function and have it do the job. I know, might as well have that one inherited also, but what's the point of adding more mess just for that ?2
-
How should you override Equals in Java?
We have model classes with lots of fields and the we override the details equals to compare all the fields. I guess like doing a deep comparison.
And in all these classes SONAR is complaining about lots of ifs, complexity, etc.
And it's killing the analysis time... Old issue never fixed because whoever setup sonar was too incompetent to bother asking, researching, or fixing...
Is there a better way to override the equals to get the same result but without triggering SONAR issues?
Pretty sure this is a solved problem. And well if the top of my head, is just create a Util method that uses reflection like
Boolean equals( Object a, b, Class class)
foreach (String f: class, getFields()) {if !compare(class.getField(f,a),class.getField(f,b)) return false; }
return true5 -
Well fucking shit, I built util-linux from source and restarted my Debian installation without knowing that mount needed new libraries, so I can't fix it from the install itself because mount no longer works properly and and the root partition mounts as read only. My only hope is to take the SSD out and put it in my laptop (The BIOS on this machine doesn't like booting from external drives for some reason...), boot from a recovery disk, chroot, and re-install util-linux that way.2
-
When you code during an interview using a coding platform like HackerRank out even on a whiteboard, do you spend time memorizing the actual the import statements?
When I usually code, and I need to use like a Queue, when the IDE asks which to import, all I do is look for java.* rather than an external lib. Or for Date, util.* Not sql.*
After you expected to know the full paths?1 -
Spend a day migrating from
org.vividsolutions.jts.geom to org.geolatte.geom
should be drop in replacement, except geolatte just redesigned there API..
So i created a util class to provide me with functionality i was missing..
today i realize it doesn't work with jsp..
(who the hell uses jsp in 2016 but us.. *cry')1 -
Was chilling with my team and remembering some very funny code issues (wasn't at the time) we inherited in a product... when we took control of the servers they were dead...
Code somewhat abbreviated... see why a few 100 of these could do that :)
public class Util
{
... lots of nonsense here...
public static DbConnection GetConnection()
{
conn = factory.CreateConnection();
conn.ConnectionString = this.connectionString;
conn.Open();
return conn;
}
}
try {
Util.GetConnection().DoThingsAndStuff();
}
finally {
Util.GetConnection().Close();
} -
I try to delete a partition from my sundisk Pendrive using GParted but when I do this I got the error that is shown in the image.
And If I try to use "fdisk" which run `sudo fdisk /dev/sda` following command it gives me ```welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
fdisk: cannot open /dev/sda: Read-only file system```
following error does that mean my pendrive permanently broke can anybody help me!9