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 - "one-liner"
-
Waisting some times on codewars.com
~~~~
3 kyu challenge:
Given a string with mathematical operations like this: ‘3+5*7*(10-45)’, compute the result
~~~~~
*Does a quick and easy one liner in python using eval()*
*sees people actually writing some 100 lines parsing the string and calculating using priority of operation*
Poor them...
(Btw, passed to lvl 4 kyu thx to this)14 -
My (soon to become ex -) boss thinks "Every problem has an one-liner Javascript solution, that he doesn't have time to write."29
-
I am receiving this type of one liner mail more often from our clients.
"Application is not working properly."
Me:
Typed : explain properly idiot.
Deleted.
Typed Again: Sir, can you be more specific.
Sent.
Or
"Application is not running."
Me:
Typed : of course it can't run. Bloody hell.
Deleted.
Typed again: inconvenience caused deeply regretted. Our representative will contact you about this.
Sent.
Man i am tired.3 -
Had to do an assignment in Haskell and had some bugs all over the way. After some Wodka I did a one liner that worked but I never found out why. 10/10 would do again3
-
Yeah Apple, fuck up your SECOND Xcode release in a SINGLE WEEK and make me download ANOTHER 7 GIGABYTES (I've grown up with a 2.4 KBITS/S modem!) for what's probably a ONE-LINER FIX in your bloated SHIT!4
-
I'm writing my bachelor thesis in LaTeX. As people who use LaTeX might know, it generates shitloads of files while compiling (like 10 files per .tex file).
To unclutter my project folder, I wrote a simple one-liner bash script that deletes all files which are not .tex or .bib files (literature references) and of course it will not delete itself (although that one also took me longer to figure out why my script 'kept disappearing for no reason after I ran it' than I'd like to admit).
However, I forgot that images are also files which are stored in the project-folder.
And this is how I suddenly lost all of my images for no reason at all, resulting in my PDF not building anymore. Luckily we all commit and push all regularely, right...
Edit: I just figured out that I'm even stupider than originally thought... My .gitignore ans more importantly, the '.git' folder also neither end in .tex nor .bib. Guess I'll just go fuck myself.10 -
Yknow what the best part about Unix is? (Not Linux. Like old school Unix. AIX, HPUX, or in this specific case: Solaris)
It never needs to be updated. like ever. Even when new features are added 5 years ago to add features that GNU has had for literally decades. Updates are for the weak. Because why should I be able to type "netstat -natup" when instead you can enjoy several hours of developing the nightmare one-liner that is:
Pfiles /proc/* | awk '/^[0-9]/ {p=$0} /port/ {printf "%.4s %-30s %-8s %s\n", $1,$3,$5,p}' 2>/dev/null
Isn't that just so much more fun?!
Thanks guys. I'm going back to GNU now if you don't mind.6 -
A jr colleague came back from a react.js code camp.
Those hipsters turned the poor kid into a one liner terrorist and buzzword spammer.
It's time to play bad cop and start enforcing line length limit. -
Start-up I'm working for as a front-end dev is pretty nice. I have good hardware, free coffee and my coworkers are all decent people. My boss is chill, and I have flexible work hours.
There is this one policy for writing code, however. And I simply cannot understand it, nor can I ignore it because of code reviews: no comments in production code.
I mean, what? Why? Comments are nice, and they make life easier for the future maintainers. At least let me put a small two-liner explaining why I did stuff this or that way. But no, I only get to explain it verbally (once) to the person reviewing my PR. Why, man?9 -
writing a whole god damn function in one single line doesn't make it "one liner" and it DOESN'T make your code better and more readable!!!2
-
Hit an issue in a dependency of the node library I use, there's been many issue reports on it since october last year and multiple recently (12 days and 4 days ago) - the fix was a one-liner.
All you had to do was check for null in line 17, because in line 9 it gets defaulted to null, but then attempts to null.fetch() in line 21.
Fascinating.12 -
Not really a hack but still worth telling:
I was working in the QA team for a big project. I tried to do some automation when I realized some radio button behaved weird... out of curiosity I checked the source and saw that there was a hidden option for a unimplemented payment option.
I was like: Let’s see how the system behaves if I just submit that form with that hidden value...
Well I was very surprised when I received the email that my order has been processed successfully.
During the investigation we found out that this bug was in prod for over two years. And it requires a one liner executed in the browsers console to skip the payment.
It was kind of a big deal and although I was (and am) still a trainee (in apprenticeship) I got invited to meet up with the client and the bosses.
It was kind of a door opener! After that they trusted me more. I have more responsibility, more interesting tasks and more client contact ever since.
To make a long story short:
Validate everything on the server side ;-)1 -
Emoji support, default color support, double-buffering... my library is really coming along well!
Getting the default colors in Linux was a one-liner. But Windows.......
https://github.com/AlgoRythm-Dylan/...4 -
If you spend a lot of time looking with computers then PLEASE use a blue light filter to reduce strain in your eyes as well to help you sleep well.
My favorite program for this is "redshift" and can be set up with this one liner
apt-get install redshift && redshift -O 300015 -
Dockers JSON output is garbage.
First, you'll get no JSON per se.
You get a JSON string per image, Like this:
{...} LF
{...} LF
{...} LF
Then I tried to parse the labels.
It looked easy: <Key>=<Value> , delimited by comma.
Lil oneliner... Boom.
Turns out that Docker allows comma in the value line and doesn't escape it.
Great.
One liner turns into char by char parser to properly tokenize the Labels based on the last known delimiter.
I thought that this was a 5 min task.
Guess what, Docker sucks and this has turned into try and error...
For fucks sake, I hated Docker before, but this makes me more angry than anything else. Properly returning an parseable API isn't that hard :@3 -
When mysql_query gets called inside of a loop that is inside of a loop.. While the could've used a one liner mysql command...
Best of all they don't think that this doesn't effect performance...1 -
So I did an interview today and the problem was given a = 1 2 3 and b = 2 3 write code that finds the common elements.
I asked what the data structures are and they said it can be whatever so I said cool then we can use sets and do an interception to get unique elements.... this was in Python... but for the life of me I couldn't remember what the intercept notation was... and brought that up hoping they're give me a hint haha.
So I ended up writing a 8-9 line solution for what could've been a one liner fml: return a | b.
All because I didn't know the notation and still needed to give them something. Painful to write when I knew I was reinventing the wheel. Sign
I almost never use sets so this was heartbreaking hopefully I still get an offer!
How bad of a fail is this in y'all opinion?7 -
Programmer: "Places : instead of ;"
Javascript: "What the fuck did you just fucking post about me, you absolute beginner? I'll have you know I worked for ten of the biggest silicon-valley industry companies, and I've been involved in over two hundred top secret projects including NodeJS. I am trained in refactoring the most fucked up code, and I'm the top C++er in the entire fucking internet-connected universe. You are nothing to me, but just another IP. I will fucking revoke your commits from your gitlab account with absolute dedication using only one Rasperry Pi client. Mark my fucking words. You think you can get away with posting that shit on one of my numerous very personal blogs? Your devices are fucking bricked, kid. My attack software can be anywhere, anytime, and it is tasked to remove your entire git contributions from planet earth. Not only am I extensively trained in remote cross-firewall device-hacking, but I have access to over 100 of the United States CIA and NSA git repositories. If only you could have known what doom-bringing C-one-liner you have raised from my fucking hands, maybe you would have held your fingers. But you could not. You did not. And now you're paying the price, noob. I will hail havoc upon your puny online-presence and you will drown in your own badly designed software. You're fucking offline, kiddo."11 -
So I met this person via a social platform.
They were absolutely silly and weren't able to hold a conversation. So I, like a normal person, just stopped trying to keep things alive.
Over the years, I have realised and learnt that if a person is interested in being friends, they'd put in efforts and I alone will not have to drag things on my shoulder.
I started cutting out people right, left, and center who I felt were taking advantage of me or using me in some way or another.
I ended up saving a lot of time and energy. I no longer feel drained or anxious about something not working out. Not dragging saved me from draining.
Anyway, they reach out to me again after few weeks and I was like let's give it a try to establish a friendship, because befriending people is my weak point.
The cycle repeats. At first I thought it must be because of the asynchronous nature of the platform so I drop my Telegram Id in case they preferred an IM approach.
I swear in the name of sweet lord, the retard does the same behaviour. So, I stopped communication.
And one fine day, the person tells me that they lack social skills and want to learn how to make friends and stuff.
Very fair point. So, me being me, gave them a few tips and critically pointed out their behaviour on how they reply with a one liner after every 2 or 3 business days.
Absolutely no change in their behaviour. They kept texting me the same.
At this point, I was like why am I doing it? I could find better people easily. Because for me, communication is everything. I cannot function without a good communication between two living beings.
So, I asked them why are they even trying to learn social skills when they barely implement it and don't want to change to which they reply saying that so they can use it to befriend people and network to getter better job opportunities.
I fuck them off.
And fuck such people who have intentions, are not clear enough about it, and play people for their own selfish gains.
And this where another learning I got from @scout is have boundaries.
Why do all good people in my life leave? Damn it! I need those good people back and be friends with them and not retards who cannot even communicate beyond one liner.11 -
Pirate speak one-liner
text.replace(/[bcdfghjklmnpqrstvzx]/ig, letter => `${letter}o${letter.toLowerCase()}`)4 -
How it started:
Need to replace in a lot of SQL files certain stuff...
find . -type f -iname '*.sql' -exec sed -i 's|new|old|g' {} \;
12 hours later that find executed a shell script containing roughly 120 lines of text pipelining.
The jolly of inconsistent workflows.
Different SQL format stylings... Makes fun when single line string replace needs to be extended to multiline RegEx handling. Or matching SQL comment configuration..
Different line endings. MacOS, Windows, Unix, Bukkake.
Different charsets / collations. Anyone wants latin1_swedish_ci... utf8... utf16... :/
Realizing some people even left sensitive data inside the SQL files (e.g. API Tokens..... Yayyyyyyy).
...
Ugh. It's never a one liner. It's never easy. -.-
I hate cleaning up messy shit.3 -
Trying to make everything a one-liner. In the process overusing ternary operators, comma operators, short circuiting and/or operators.
Until someone else needs to review or understand what I created, and I'm forced to change... 😥1 -
debugging a performance issue. basically the original dev had no idea what a database was for. system was generating millions of buffered reads, and paging horribly.
to see if an id existed they had done the following:
fetch all 1 million rows into an array.
iterate the array looking for a match.
if found, set found=true
continue to iterate the rest of the array.
return found.
repeat at every login.
replaced with
return person.get(id)
set world record for most i/o avoided with one liner.1 -
Fucking love how one-liner packages are breaking basically the entire JS ecosystem every once in a while. Why the fuck do you add one-liner packages as dependencies in your code?9
-
So I was looking for a way to easily take android screenshots in a lossless image format, since my OEM only does jpeg.
Didn't want to install another adware and wound up with the adb shell screencap command since I need the pictures on my PC anyways.
But instead of a nice one-liner like
adb shell screencap -p > screenshot.png
I need 3 lines in a bash script.
Can we please just end the line ending wars?5 -
I got back from my holiday, back to work, and have spent 20 minutes of every hour at work waiting for my laptop to build while I navigate this “codebase” to put a teeny feature change in. A one liner.
Honestly everything about this makes me want to cry.1 -
I cant keep this inside anymore I have to rant!
I have a colleague that is an horrendous loose bug-cannon. Every peer-review is like a fight for the products life.
Now I understand - everyone makes bugs me included and it is a huge relief when someone finds them during peer-review. But these aren't the simple kind of bugs. The ones easily made when writing large pieces of code quickly. Typing = instead of == or a misshandling of a terminating character causing weird behaviour. These kinds of bugs rarely pass by a peer-review or are quickly found when a bug report is recieved from testers.
No the bugs my colleague makes are the bugs that completly destroy the logic flow of a whole module. The things that worst case cause crashes. Or are complete disasters trying to figure out what causes them if they are discovered first when the product reaches production!
Ironically he is amazing a peer reviewing other peoples code.
But do you know what the worst thing of all is! Most of the bugs he causes are because he has to "tidy up" and "refactor" every piece of code he touches. The actual bugfix might be a one liner but in the same commit he can still manage to conjure up 3 new bugs. He's like a bug wizard!
*frustrated Aruughhhh noises*9 -
One of the students I'm a TA for handed in a one-liner with the comment that his submission was the shortest.
The idiot forgot to add imports for the functions he used, so the code didn't even compile.
Safe to say he didn't get high marks for that. -
I've now spent 6 hours trying to find a way to do something similar, as you can do in Neo4j, where you find relations up to depth 5, in PostgreSQL.
The issue is, I have to tables. One with persons, another one with relations (incoming ID and outgoing ID) to have a many to many relationship.
I'm at the point where I just don't care getting it to work. In Neo4j it's a fucking one liner, so why the fuck am I getting assigned to do this in PostgreSQL?
To prove a point? Well fuck you, I'm done with this shit.3 -
Progress on my sudoku application goes well. Damn, what is javascript fantastic. While the code of the previous version that I posted here was alright I did decide that i want to split code and html elements after all. I have now a puzzle class doing all resolving / validating and when a field is selected or changed, it emits an event where the html elements are listening to. It also keeps all states. So, that's the model. puzzle.get(0,1).value = 4 triggers an update event. It also tracks selection of users because users selecting fields is part of the game. I can render full featured widgets with a one liner. Dark mode and light mode are supported and size is completely configurable by changing font-size and optional padding. So far, painless. BUT: i did encounter some stuff that works under a CSS class, but not if I do element.style.* =. Made me crazy because I didn't expect that.19
-
Come on guys, I want to gather deadly One-Liner for Linuxsystems. Maybe someone has some more creative ways than the standard ones below.
1. rm -rf / —no-preserves-root
2. echo . > /dev/sda
(3). :(){ :|: & };:
4. mv / /dev/null4 -
Colleague (Lead Engineer): Hey, check my code. I'm trying to group a list of Request objects by their id. Something is not working here
Me: * saw his code, had a lot of shitty loops, called all for a quick meet, changed his shitty mess to one liner
list.stream()
.collect(Collectors.groupingBy(Request::getId))
Walked out like a boss*
😎 -
Yesterday I spent almost 3 hours trying to sort an array of objects in java. I'm a person who has written a lot of python and dart code and java is just so daunting. Every simple thing is so complicated.
You can sort a list of objects wrt any parameter using a one liner in python.
Finally after copy pasting a lot of code from stack overflow the thing got sorted. And the worst part I don't even know how the thing works.4 -
If a bug is logged don't mark it as resolved unless you commit that resolution.
Also don't mark it resolved without at least a one-liner of the fix/expected behavior.1 -
I waa pretty sure fortune cookies were getting weirder... but seriously, it's gotten THIS bad? Not a fortune, nor a proverb, just a one-liner on political finance?
Just seems extra messed up that you can now be prompted to discuss national debt via fortune cookie from chinese take-out. We do owe the most to china afterall. Yet fortune cookies are invented by us(and typically one of the few things produced stateside). Just seems extra off...6 -
Just found this javascript one-liner gem:
array.sort((a, b) => ([...new Set([...this.strip(a.name), ...a.tags])].filter(x => inKeywords.includes(x))).length == ([...new Set([...this.strip(b.name), ...b.tags])].filter(x => inKeywords.includes(x))).length ? 0 : (([...new Set([...this.strip(a.name), ...a.tags])].filter(x => inKeywords.includes(x))).length < ([...new Set([...this.strip(b.name), ...b.tags])].filter(x => inKeywords.includes(x))).length ? 1 : -1))
If that doesn't make you angry you might be in a coma11 -
Test A succeeds when run solo. Test A fails when run in conjunction with Test B. Obviously, some kind of messy state that isn't isolated per test.
I realize what it is, so I add a new feature to address it.
Test still fails, it had nothing to do with that.
I finally realize what it was. One liner fix.
Yay for a new (useless?) feature that isn't getting backed out. -
Jenkins' triggerManualBuild randomly but if so then consistently produces 500 errors for certain newly created jobs. I haven't really found a pattern, yet I was bit by it in the past already. I used to "solve" it by deleting the offending job and re-creating it.
Now, I have this annoying issue again, and no matter how often I re-create that shitty one-liner job in the pipeline, it won't trigger. (The job itself is fine. It's the actual trigger that is broken.)
It's not like it's important or anything, as this is basically only the "push to production" step.
FML. And fuck me for stating: "Creating a delivery pipeline should be straightforward. I therefore consider 1 storypoint enough."4 -
Made this one-liner today:
hostname $(curl nsanamegenerator.com | grep body | sed -e 's/<.*;//g' | sed -e 's/<.*>//g')
and added it to my laptop's crontab...4 -
After the fun I had with the XEN Orchestrator UI ( https://devrant.com/rants/2554182/ ) I build an exporter that normalizes XEN / Proxmox API output and writes it into a nice spreadsheet.
Took PHP 7.4 for a spin. Sweet jesus, lot of nice stuff.
Been nearly a year since I did something larger than small scripts in PHP, but felt really at home again.
The type hinting and arrow functions made writing the exporter a breeze.
DTOs with typed properties spared me quite a bit of headache when normalizing the different APIs...
Utilizing *sort with fn arrow function is a pretty nice and concise one liner with the spaceship operator.
And I have now a nice spreadsheet...
Thanks at the PHP folks.1 -
in this takehome challenge: let's see how much we can over-fucking-complicate every single thing. You want one selectors (that could just be one-liners) stacked on top of MORE one liner selectors? you got it!
you want sagas with fucking wierd ass syntax that can be replaced with i don't know, BUILT IN JAVASCRIPT??!!? you got it!
oh yeah, and with all this complexity, not a single line is written with TypeScript...
...i can't remember the last time i fucking had to write the characters 'propTypes' on a react project
what the hell is this, 2015?
it's absolutely mind exploding mind boggling how these orgs operate
double the work, double the time, double the cost
but what do i know? i'm just a 🤡 -
guard let param = param, otherParam == .someValidValue else { return }
Beautiful one-liner that validates your function's parameters without having to incur in another indentation level. -
It's funny that I already do the <@user> when mentioning someone automatically.
If some still don't understand why tf I do that:
If find the typical one liner mentions too ugly. I just thought I'd be more nerdy and do the HTML <> thingys.
- Example -
Normal:
```
@user yes!
```
Mine:
```
<@user>
Yes!
```
Much more beautiful!!! :)
(Just as myself)3 -
package bar;
public class Foo {
public static void main(){
System.out.println("Hello, World!");
}
}
I still wonder why I didn't start with Python, print('Hello, World') is a god damn one-liner7 -
Functional programming in a one liner:
const value = (define_value, start) => value(define_value(start))1 -
Fuck you Linux! I thought user password validation would be a piece of cake, like bash one liner. How wrong could I be!
Yeah, it's already ugly to grep hash and salt from /etc/shadow, but I could accept that. But then give me a friggin' tool to generate the hash. And of course the distro I chose has the wrong makepswd, OpenSSL is too old to have the new SHA-512 built in, as it should be a minimal installation I don't want to use perl or python...
And the stupid crypto function that would do me the job is even included in glibc. So it's only one line of C-code to give me all I want, but there is no package that would provide me this dull binary? Instead I will have to compile it myself and then again remove the compiler to keep image small?5 -
Built the most generic file importer.
So a customer had his SAP system giving us some 5 million barcodes in a csv which we needed to parse. But as there could be different file types and I thought the handling would always include the same steps I made them configurable through function pointers. - Did not want to make it as spooky as the rest of the code base where the function pointers were buried deep in some shared memory configs, which might even change at run time, but rather I statically used the member functions of my class. Just to poke fun on the ugly C++ syntax of member function pointers. I still shudder at the thought some poor soul now has to maintain that code.
(For the actual parsing I actually used a one liner in awk which was churning through the records in one minute which was faster than the SAP guys seemed to be accustomed to.) -
Dad: Son, please put a liner in the trash.
Son: Argh, okay... <grumbles and starts>
Dad: Its just a one liner. It doesn't even have to be funny.
Son: <GROAN!> ... I hate you ...1 -
So I’m tryina put together a resume and I see a lot of dev résumé talking about increased revenue from x to y or user base from z to w.
What I don’t understand is while yes the user base did increase from z to w it wasn’t just you that caused it. The entire company was working hard at it to get there so why are u claiming that it was you. And apparently recruiters love these kpis that u make out of your ass.
Should I give in and just put them in there anyway?
I worked in a startup so my job didn’t really have a definition of what to be told to do and do I had to deal with building front end with vue to figuring out how to automate our deployment flow and it’s really hard to quantify my performance like sure 3000 tickets solved but u don’t know what portion of them were full blown features what portion was just a one liner.2 -
A beautiful but fundamentally flawed Rust one-liner I found in my own code during refactoring today:
iter.size_hint().1.map_or_else(Vec::new, Vec::with_capacity)random size_hint.1 gets _really big_ sometimes rust allocate maximum possible memory needed one-liners14 -
During these interesting times it has certainly been a productive one for me. But after this fuckup i need to take a break. Also came to the reallisation i rely too much on Ctrl-r in terminal. I just needed to find that one long weird rsync thingy that i use once a quarter year...
:~$ history -c | grep rsync | grep...
I need a break. I royally fucked up now and i cannot be bothered right now to type that 25 lines of escaped backslashed one-liner rsync thing...3 -
I got relegated to updating an old project. It takes just 35 lines to do what we can write as a single liner in the new one.2
-
Hi dev!, how do you deal with the dilemma of choosing between using a library (gem, package, plugins...) to implement a solution or building from scratch...
Use case: you are working on project x, you need to implement a feature, but stuck between importing a library ( however you will need to customize the library to fit in requirement) and building feature from scratch ( this may take you more time but you have more control).
I have been in both scenarios, whereby I use a library but spent 2 days on customizing, only for me to discard it and implement feature within 2 hours.
I had been in a situation where I build the feature from scratch, only to discover, a one-liner from a library could have saved me hours and whole stress.
I NEED YOUR EXPERIENCE.
THANKS IN ADVANCE4 -
How the fuck is this even possible Microsoft, apparently one line of code breaks web browser sandboxing on all chromium based browsers.
https://slashgear.com/windows-10-19...3 -
#Suphle Rant 8: Strange star discovered
I was searching for a project I'd starred earlier, on my github feed, when I realised a user had starred suphle at some point but for some reason, it wasn't reflecting on the stargazers. I was half overjoyed and half confused. Overjoyed over unlocking the milestone.
User seemed legit –an Italian with projects in C that were not forked. Followers and commit graph are organic. Did he star in error, feel the project is a stinker, or encounter installation challenges? Luckily, I found his email address but all his repositories are in Italian so I wasn't too sure he'd understand English, or if the mail was being attended to. Yet, I took my chances
He surprisingly got back to me, affirming that the star-unstar was actually deliberate. He withdrew the star cuz project's documentation is not hosted online and still requires npm start.
I try to persuade him by reminding him it's just a one liner but that markdown files are equally rendered directly on github. Never heard from him again, sadly
I'm kind of bothered cos I find it funny I thought suphle's APIs are all cast in stone, but the more I work on the docs, the closer I am to spotting something that doesn't sit right with me, and diving in to modify it. This not only prolongs ETA, there's the risk of someone who may have stumbled upon it and is studying it, having the rug pulled from under their feet. Things like validator rules and route-collection service-coordinators have been converted from methods and classes to native decorators. I guess I'm safe since nobody has indicated any signal to the contrary. It'll be pedantic to start tagging versions for each change.
Another consideration is that these breaking changes would go to the first segment of the semver scheme, which is hilarious because the rate at which I push such changes is so alarming, we'd probably progress through 15 versions under a year12