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 - "integer"
-
TLDR : I left a company which doesn't understand the concept of email id and passwords.
Me (trying to login to the alumni website) *no register user option*
Customer support - you've to click on forgot password to create an account.
Me - Wonderful
*clicks on reset password*
*enters employee id, name, email, father's name, DOB, date of joining , date of leaving, current city because apparently if I just enter my employee id it is as if they never knew me. Sigh*
*your password will be sent to your email id*
Me - okay. *waits for two weeks because I assumed someone will manually go and create my account and email me, considering the state of system. *
After two weeks,
Me - I still haven't received my password on email after I created my account. Can you please check?
After one week,
Customer support - you need to click on forget password if you forgot your password.
Me - *inventing new curse words* I have not forgot my password, I never received it in the first place!
After one week,
Customer support - yes you'll receive your password on your email id.
Me - *runs out of curse words* seriously dude?
* proceeds to reset password*
System - your password has been reset. Your new password will be sent to your email id. *apparently anyone can reset passwords if you have the employee id, which is an integer*
After a week
Me - Am I going to ever receive the password? I've tried generating passwords, resetting my password. I never get my passwords. What should I do!!
Customer support - yes you need to click on Forgot password.
Me - are you fucking kidding me!!!
You fuckers need to be fired and replaced by a FAQ page which has no question and just a single answer, because a peanut has higher IQ than you. For any questions you may have, just reset password. Goddammit idiots!
Also, which email id are you sending my passwords to?
Customer support - myname@oldcompany.com
Me - you do realize that this is the alumni website for the company. Alumni means ex members.
Being ex members, you can assume we don't have access to our company email ids obviously?
Customer support - yes.
Me - how am I supposed to get the password using my old email id then?
Customer support - you need to click on forgot password option.
I think I should probably move to the Himalayas for my anger management issues. Plus it'll be probably easier to throw idiots off a mountain.31 -
Fun fact:
In the game Civilization, Gandhi had a aggression rating of 1 which means he didn't declare war on anyone. Now whenever someone Researched Democracy their aggression rating dropped by 2. Now instead of it dropping to - 1, it caused an integer underflow and the aggression rating became the highest possible value, making Gandhi into a nuclear warlord. He nuked everyone!20 -
So a few days ago I felt pretty h*ckin professional.
I'm an intern and my job was to get the last 2003 server off the racks (It's a government job, so it's a wonder we only have one 2003 server left). The problem being that the service running on that server cannot just be placed on a new OS. It's some custom engineering document server that was built in 2003 on a 1995 tech stack and it had been abandoned for so long that it was apparently lost to time with no hope of recovery.
"Please redesign the system. Use a modern tech stack. Have at it, she's your project, do as you wish."
Music to my ears.
First challenge is getting the data off the old server. It's a 1995 .mdb file, so the most recent version of Access that would be able to open it is 2010.
Option two: There's an "export" button that literally just vomits all 16,644 records into a tab-delimited text file. Since this option didn't require scavenging up an old version of Access, I wrote a Python script to just read the export file.
And something like 30% of the records were invalid. Why? Well, one of the fields allowed for newline characters. This was an issue because records were separated by newline. So any record with a field containing newline became invalid.
Although, this did not stop me. Not even close. I figured it out and fixed it in about 10 minutes. All records read into the program without issue.
Next for designing the database. My stack is MySQL and NodeJS, which my supervisors approved of. There was a lot of data that looked like it would fit into an integer, but one or two odd records would have something like "1050b" which mean that just a few items prevented me from having as slick of a database design as I wanted. I designed the tables, about 18 columns per record, mostly varchar(64).
Next challenge was putting the exported data into the database. At first I thought of doing it record by record from my python script. Connect to the MySQL server and just iterate over all the data I had. But what I ended up actually doing was generating a .sql file and running that on the server. This took a few tries thanks to a lot of inconsistencies in the data, but eventually, I got all 16k records in the new database and I had never been so happy.
The next two hours were very productive, designing a front end which was very clean. I had just enough time to design a rough prototype that works totally off ajax requests. I want to keep it that way so that other services can contact this data, as it may be useful to have an engineering data API.
Anyways, that was my win story of the week. I was handed a challenge; an old, decaying server full of important data, and despite the hitches one might expect from archaic data, I was able to rescue every byte. I will probably be presenting my prototype to the higher ups in Engineering sometime this week.
Happy Algo!8 -
The story of the $500,000,000 error.
In 1996, an unmanned Ariane 5 model rocket was launched by the European Space Agency.
Onboard was software written to analyze the horizontal velocity of the spacecraft. A conversion between a 64-bit floating point value and a 16-bit signed integer within this software ultimately caused an overflow error just forty seconds after launch, leading to a catastrophic failure of the spacecraft.
That day, $7 billion of development met it's match: a data type conversion.12 -
Swift, oh my god, why do you have to be like this?
I'm looking to write a simple for loop like this one in java
for(int i = 5; i > 0; i--) {
// do shit
}
Thats it, simple, go from 5 to 1 (inclusive), I saw that to iterate over a range in a for loop (increasing ordeR) I can do this
for i in 0...5 {
// do shit.
}
So I thought maybe I could do this to go in reverse (which seems logical when you think about it doesn't it?)
for i in 5..<0 {
// do shit
}
But no, this compiles FINE (THIS IS THE FUCKING KICKER IT COMPILES), alright, when you the code runs you get a fucking exception that crashes the mother fucking application, and you know what the problem is?? This dogshit, shitStain of a language doesn't like it when integer that the for loop starts with is larger than the integer that the for loop ends with MOTHERFUCKER ATLEAST TELL ME THAT AT COMPILE TIME AS A MOTHERFUCKING WARNING YOU PIECE OF SHIT!!
Alright *deep breathing*, now we can't just be stuck on this raging, we're developers need to move forward, so I google this, "Swift for loop in reverse" fair enough I get a straight forward answer that tells me to use the `stride` functionality. The relevant code for it
for i in stride(from:5 to:1 by:-1) {
// do shit
}
Wow looks fine and simple right?? (looks like god damn any other language if you ask me, no innovations here piece of shit apple!) WRONG BITCHES !!! In the latest version of Swift THE FUCKING DEVELOPERS DECIDED TO REMOVE STRIDE ALTOGETHER, WITHOUT ADDING IN A GOOD REPLACEMENT FOR THAT SHIT!
Alright NOW IM FUCKING MAD, I got rage on stackoverflow chat, a guy who's been working on ios for quite a while comes up n says and I quote
"I can sort of figure it out, but besides that, iterating in reverse is uncommon enough that it probably hasn't crossed anyone's mind."
Now hope you guys understand my frustration, and send me cookies to calm me down.
Thank you for listening to me !27 -
* On a field trip *
🎵 99 BOTTLES OF BEER ON THE WALL, 99 BOTTLES OF BEER. TAKE ONE DOWN, PASS IT AROUND, 98 BOTTLES OF BEER ON THE WALL 🎵
Oh please don't.
...
🎵 1 BOTTLE OF BEER ON THE WALL, 1 BOTTLE OF BEER. TAKE ONE DOWN, PASS IT AROUND, 0 BOTTLES OF BEER ON THE WALL 🎵
Finally, they've been singing for like an hour. Good thing it's ove--
🎵 0 BOTTLES OF BEER ON THE WALL, 0 BOTTLES OF BEER. TAKE ONE DOWN, PASS IT AROUND, 4294967295 BOTTLES OF BEER ON THE WALL 🎵
>_>5 -
I had to open the desktop app to write this because I could never write a rant this long on the app.
This will be a well-informed rebuttal to the "arrays start at 1 in Lua" complaint. If you have ever said or thought that, I guarantee you will learn a lot from this rant and probably enjoy it quite a bit as well.
Just a tiny bit of background information on me: I have a very intimate understanding of Lua and its c API. I have used this language for years and love it dearly.
[START RANT]
"arrays start at 1 in Lua" is factually incorrect because Lua does not have arrays. From their documentation, section 11.1 ("Arrays"), "We implement arrays in Lua simply by indexing tables with integers."
From chapter 2 of the Lua docs, we know there are only 8 types of data in Lua: nil, boolean, number, string, userdata, function, thread, and table
The only unfamiliar thing here might be userdata. "A userdatum offers a raw memory area with no predefined operations in Lua" (section 26.1). Essentially, it's for the API to interact with Lua scripts. The point is, this isn't a fancy term for array.
The misinformation comes from the table type. Let's first explore, at a low level, what an array is. An array, in programming, is a collection of data items all in a line in memory (The OS may not actually put them in a line, but they act as if they are). In most syntaxes, you access an array element similar to:
array[index]
Let's look at c, so we have some solid reference. "array" would be the name of the array, but what it really does is keep track of the starting location in memory of the array. Memory in computers acts like a number. In a very basic sense, the first sector of your RAM is memory location (referred to as an address) 0. "array" would be, for example, address 543745. This is where your data starts. Arrays can only be made up of one type, this is so that each element in that array is EXACTLY the same size. So, this is how indexing an array works. If you know where your array starts, and you know how large each element is, you can find the 6th element by starting at the start of they array and adding 6 times the size of the data in that array.
Tables are incredibly different. The elements of a table are NOT in a line in memory; they're all over the place depending on when you created them (and a lot of other things). Therefore, an array-style index is useless, because you cannot apply the above formula. In the case of a table, you need to perform a lookup: search through all of the elements in the table to find the right one. In Lua, you can do:
a = {1, 5, 9};
a["hello_world"] = "whatever";
a is a table with the length of 4 (the 4th element is "hello_world" with value "whatever"), but a[4] is nil because even though there are 4 items in the table, it looks for something "named" 4, not the 4th element of the table.
This is the difference between indexing and lookups. But you may say,
"Algo! If I do this:
a = {"first", "second", "third"};
print(a[1]);
...then "first" appears in my console!"
Yes, that's correct, in terms of computer science. Lua, because it is a nice language, makes keys in tables optional by automatically giving them an integer value key. This starts at 1. Why? Lets look at that formula for arrays again:
Given array "arr", size of data type "sz", and index "i", find the desired element ("el"):
el = arr + (sz * i)
This NEEDS to start at 0 and not 1 because otherwise, "sz" would always be added to the start address of the array and the first element would ALWAYS be skipped. But in tables, this is not the case, because tables do not have a defined data type size, and this formula is never used. This is why actual arrays are incredibly performant no matter the size, and the larger a table gets, the slower it is.
That felt good to get off my chest. Yes, Lua could start the auto-key at 0, but that might confuse people into thinking tables are arrays... well, I guess there's no avoiding that either way.13 -
If you divide an integer with two over and over again, you will get closer and closer to 0, but you will never reach it.
Kind of the same feeling as watching your rant gain more and more ++'s, but never hitting that magical 300.11 -
In a programming contest, I forgot how to round numbers in Java, an I needed a 3 number rounding, so I multiplied the number by 1000, then sum 0.5 and convert it to integer so the decimal part would be gone, finally, just print the number except the 3 last digits as a string, put a period and print the other 3 digits.
I must say I'm not proud of that.5 -
- How can we make sure the age input is an integer?
- Let's add some incremental buttons for edit it.
- Nice, sounds pretty safe and convenient6 -
True fact!
Had my practical exam yesterday on Data Structures using C.
Had included this in my code
if(!count)
break;
Examiner: What type is count?
Me: Sir, it's an integer.
Then he asked me what was not expected.
Examiner: What does this exclamatory mark do?
In my mind: Now's the right time for the world to end. 😛9 -
When you hate someone so bad that it actually turns into love...natures emotional integer overflow...3
-
Where I work, in our database, we use 3 to indicate true and 7 to indicate false and 0 is true but null is false
In another table, we use 'P' to indicate true and 'I' to indicate false and 'Y' is also false and null is false
And the most used table, we also use 'Y' to indicate yes and 'N' to indicate no, but null is also Yes.
We also store integers as varchar in a live table, but stays an integer in all the other tables. I hope I'm not there when the number of digits exceeds the varchar limit.
These are all live and used in production all created by my boss, the head of IT.8 -
I'm currently rewriting perfectly clean and functioning Scala code in Java (because "Enterprise", yay). The amount of unnecessary boilerplate I have to add is insane. I'm not even talking big complicated code but two liners or the lack of simple things like a range from 5 to 10.
Why do I have to write
List<Position> occupiedPositions = placedEntities.stream()
.flatMap((pe) -> pe.occupiedPositions().stream())
.collect(Collectors.toList());
instead of simply
val occupiedPositions = placedEntities.flatMap(_.occupiedPositions)
Why on earth does `occupiedPositions.distinct` suddenly become a monstrosity like `occupiedPositions.stream().distinct().collect(Collectors.toList())` where the majority of code is pure boilerplate? And this is supposed to be the new and better Java8 api which people use as evidence that Java is now suddenly "functional" (yeah no, just no).
Why do APIs that annotate parameters with @Nullable throw NullPointerExceptions when I pass a null? Why does the compiler not help prevent such stupidity? Why do we use static typing PLUS those annotations and it still crashes at runtime like every damn dynamic, interpreted language out there? That's not unfortunate, it's a complete waste of time.
Why is a simple idea like a range from x to 10 (in scala literally `x to 10`) not by default included in Java? There's Guava's version of Range which does not have a helper for integer ranges (even though they are the most used ones). Then there's apache.commons version which _has_ a helper for integers, but is strangely not iterable (wtf I don't even...).
Speaking of Iterable: How difficult could it be to convert an abstract Iterable<T> into a concrete List<T>? In scala it's surprisingly `someIterable.toList`. I found nothing like that so I took to stackoverflow where I found a thread in which people suggested everything from writing your own ListUtils helper class, using Guava (which is a huge dependency!) to using the new Java8 features inline (which is still about three lines long). I didn't know this was such a hard problem in computer science, TIL.
How anyone can be productive in this abomination of a language is beyond me now, even though I've used it for many years while learning to code (back then I didn't know there were much better ways to do things). The only good part is that I have to endure this nonsense for only about 3 days longer then I'm free again!12 -
I'm planning on making a band called Bar Fighters and will play songs like Integer Or Long, The Renderer, Test of U nit, Learn to Try ( catch )5
-
u/bob
"hey can someone help me assign 10 to a variable in rust"
u/1337rustpro
"Well first of all little shithead that is not rust-like we dont do that in rust here is how godfather mozilla intended it first you create a register in your ram then you download these 9 packages that are not in std for some reason then you box your integer 78 times then you sacrifice a goat that the rust compiler doesnt give you random advice that doesnt work then you pee on your motherboard and commit 53 times to open source repos on github bitbucket and svn then you will maybe probably have 7 assigned to your variable"
u/bob
"Oh wow rust sure is overly complicated"
u/bob
<User banned>4 -
You know the code is in bad shape when you see variables starting with "get":
Integer getDataBlockSize;4 -
I've always found those "age++" rants to be annoying.
are you people storing age as an integer rather than as an epoch timestamp?! seems rather tedious to upkeep.
either way. another year down! (that's 31,536,000 seconds for those of you counting correctly.)6 -
Inner Me: Where the fuck is this bug coming from
> Set a breakpoint in every single place where the method I'm using is being called.
> Try calling the method before every function call
Inner Me: FUCKING DAMNIT! It's been hours now
Inner Me: No way it's the library I'm using.
Inner Me: That couldn't possibly be the problem
> Try running it again and delete some more shit
Inner Me: FUCK MEEEEEEEE
> Getting delirious
> Begin to look at some stupid memes.
> Come back to it.
> Have an Ah-ha moment
> Try running it again but rearrange the order of the method calls
> Still no luck
> try git stashing a bunch of my changes
> git stash apply them back
> erase the method call entirely
Inner Me: well that sort of worked, but now all my numbers are incomplete
Inner Me: FUCKING FINE!!! I'LL LOOK IN THE GODDAMN LIBRARY
Inner Me: FUUUUUUUUUUUUUCCCCCCCCKKKKK a stupid integer casting was occuring to my floats!!!
Now Talking to my girlfriend.
Me: The problem was in the library I was using
Girlfriend: How are you going to fix it if it's in the library?
Me: ... I can, because I wrote the library...
Me: FUCK ME RIGHT?
Me: I guess moral of the story; sometimes the problems starts with ourselves
GF: Hahaha. Thats Deeep2 -
So customers can place orders at our website, but some of the products are actually handled by a third party. We use a web service to communicate about these orders. Obviously, we need a way to uniquely identify each order, and decided with this other company that we would use a simple incrementing integer.
Last week, something strange happened: we could no longer cancel orders by their ID, because according to the web service, the orders were placed too long ago and were no longer eligible for cancellation. But I knew that could not be true: the orders were from last week. So I checked out database, turns out the ID's are not so unique: some refer to two or three orders. Somewhat worried, I contact the guy responsible at the other company and ask him how that could ever happen?
He: "Yeah, when we restart our server, the counter goes back to 1, you see. I didn't think that would be a problem...".
REALLY?! YOU DIDN'T THINK?5 -
Porting over code to python3 from python2 be like:
(Cakechat, in this case)
Day 0 of n of python 3 compatibility work:
This should be _easy_, just use six and do magic!
Day 1 of n:
Oh, true division is default instead of integer division, so I need to replace `/` with `//` in a few places.
Day 2 of n:
Oh, map in python2 behaves differently than map in python3, one returns a list, other an iterator. Time to replace it with `list(map())` then.
Day 3 of n:
Argh, lambdas don't evaluate automatically, time to fix that too.
Day 4 of n:
Why did I bother trying to port this code in the first place? It's been so long and I DON'T EVEN KNOW WHAT IS BROKEN BECAUSE THE STUFF RUNS WHEN I BREAKPOINT AND STEP THROUGH BUT NOT WHEN I RUN IT DIRECTLY?!
Day ??? of n:
[predicted]
*gives up*
I've had enough.4 -
A LOT of this article makes me fairly upset. (Second screenshot in comments). Sure, Java is difficult, especially as an introductory language, but fuck me, replace it with ANYTHING OTHER THAN JAVASCRIPT PLEASE. JavaScript is not a good language to learn from - it is cheaty and makes script kiddies, not programmers. Fuck, they went from a strong-typed, verbose language to a shit show where you can turn an integer into a function without so much as a peep from the interpreter.
And fUCK ME WHY NOT PYTHON?? It's a weak typed but dynamic language that FORCES good indentation and actually has ACCESS TO THE FILE SYSTEM instead of just the web APIs that don't let you do SHIT compared to what you SHOULD learn.
OH AND TO PUT THE ICING ON THE CAKE, the article was comparing hello worlds, and they did the whole Java thing right but used ALERT instead of CONSOLE.LOG for JavaScript??? Sure, you can communicate with the user that way too but if you're comparing the languages, write text to the console in both languages, don't write text to the console in Java and use the alert api in JavaScript.
Fuck you Stanford, I expected better you shitty cockmunchers.31 -
Dynamically typed languages are barbaric to me.
It's pretty much universally understood that programmers program with types in mind (if you have a method that takes a name, it's a string. You don't want a name that's an integer).
Even it you don't like the verbosity of type annotations, that's fine. It adds maybe seconds of time to type, which is neglible in my opinion, but it's a discussion to be had.
If that's the case, use Crystal. It's statically typed, and no type annotations are required (it looks nearly identical to Ruby).
So many errors are fixed by static typing and compilers. I know a person who migrated most of the Python std library to Haskell and found typing errors in it. *In their standard library*. If the developers of Python can't be trusted to avoid simple typing errors with all their unit tests, how can anyone?
Plus, even if unit testing universally guarded against typing errors, why would you prefer that? It takes far less time to add a type annotation (and even less time to write nothing in Crystal), and you get the benefit of knowing types at compile time.
I've had some super weird type experiences in Ruby. You can mock out the return of the type check to be what you want. I've been unit testing in Ruby before, tried mocking a method on a type, didn't work as I expected. Checked the type, it lines up.
Turns out, nested away in some obscure place was a factory that was generating types and masking them as different types because we figured "since it responds to all the same methods, it's practically the same type right?", but not in the unit test. Took 45 minutes on my time when it could've taken ~0 seconds in a statically typed language.11 -
What the fuck
Whoever designed the McD's website for India is a fucking moron! Who the fuck adds the fucking CVV number as a hidden fucking *integer*?
Can't fucking write a CVV that starts with 0! Had to shell out fucking cash!
Who the fuck ever developed and fucking tested it were probably high AF and fucked up in the head at the same fucking time!1 -
A lot of phrases we use in software would make awesome alternative-rock band names.
- Integer Overflow
- Curly Braces
- Recursion
- Callback Hell
- Daemon Processes
- Nested Loop
- Regular Expressions
Source: Twitter2 -
The moment when you learn Java for ~6 months at the university and someone in the back asks: "whats a integer?"...😅😐5
-
Yesterday, my new (Irish) co-worker comes to my desk and asks me a question about an issue in his code.
His commenting all done in Irish.
Him: "If you want me I can translate the comments for you?"
Me: "Ní gá, is féidir liom é a léamh go foirfe." ("No need to, I can read it perfectly fine")
co-worker looking at me like: "wtf just happened?"
After a while, I spotted the issue (I noticed the expected output from one of the functions not being of the correct format - an integer instead of an array).
So I fixed it.
Next day (this morning) I came back at work, looked into my food drawer to see what I would eat for breakfast (yes, I have a drawer specifically for food, and yes, I eat breakfast at work), found a small box containing an Ulster Fry :D
Best breakfast at work in a long time :D6 -
So we ordered a piece of software from external software house becouse I was low on time and we needed it asap.
So. Long story short, their software was bugged as hell, they deny all the bugs and they have their BDD that they done and anything we say about it like "feature XYZ is broken on firefox" they will deny it "becouse it wasn't on BDD" or "let's get on call" (in which +- 6-7 people participate from their side and we of course have to pay them for this...)
So they fixed like 20% of bugs (mostly trivials/minors) Application is fairly small scope. You have integration with like 3 endpoints on arbitary API, user registration/login, few things to do in database (mainly math running from cron).
They done it in ASP so I don't know the language and enviroment so can't just fix it myself.
2 days ago (monday) they annoyed me to point where I just started to break things. For starters I found that every numeric input is vunrable to integer overflow (which is blocker). I figured most of fields are purefect opportunity to XSS (but I didn't bother to do JS... anything but not JS...). I figured I can embed into my name/surname/phone (none validated) anything in HTML...
So for now we have around 25 bugs, around 15 of them are blockers.
They figured it's somehow our fault that it's bugged and decided to do demo with us to show off how perfectly it works. I'm happy to break their demos. I figured I will register bunch users that have name - image with fixed/absolute position top:0;left:0 width/height 100% - this will effectively brick admin panel
Also I figured I can do some addotional sounds in background becouse why not. And I just dont know what to put in. It links to my server for now so I can freely change content of bricked admin panel.
I have curl's ready to execute in case they reset database.
I can put in GIFs or heck, even videos, dosen't really matter. Framework escapes some things for them so at least that. But audio/image/video works.
Now I have 2 questions:
- what image + audio combo will work the best (of course we need to keep it civil). Im thinking finding some meme with bugs or maybe nuclear logo image with some siren sound
- am I evil person?
Edit:
I havent stated this clearly:
"There is no BDD that describes that if user inserts malicious input server should deny it" - that's almost literally what we get from them....11 -
Less rant, more mildly interesting Java trivia.
Integer i0 = 3; Integer i1 = 3;
Integer i2 = 300; Integer i3 = 300;
i0 == i1 is true as expected
i2 == i3 is actually false
Java caches -128 to 127 Integer objects for faster perf so when you're inside that range, the objects are indeed the same, but because == checks object equality, the Integer outside of the range is not cached and had to be initialized, so i2 and i3 are two different objects.
You can totally break some tests this way :)9 -
If you discount all the usual sql injections the most blatant was not our but a system one customer switched to after complaining over cost.
The new system was a bit more bare bones featurewize but the real gem was the profile page for their customers.
The only security was an id param pointing to the users primary key, which was an auto incrementing integer :)
And not only could you access all customer data but you could change it to.
But since the new system was built by their it chief’s son we realized it was not much we could do.2 -
In the Ruhr area (Germany) we have some very old, very strange words with strange meanings. One of those words is ‚Prutscher‘.
A Prutscher refers to a person who does things but never gets a good result, due to lack of knowledge or simple carelessness. Most of the time, Prutschers are people who are interested in certain subjects and often work in the related jobs, but who lack the motivation to properly train themselves, learn what there is to learn and to always keep up with their technologies .
Here are a few examples I've stumbled upon so far in my career:
- Developers in their 60's who read a book about PHP 25 years ago and decided to become a software developer. Since then haven't read anything about it. Who then now build huge spaghetti monoliths for large companies, in which they prefix every function, every variable and constant with their initials and, of course, use Hungarian notation.
- People who read half a fucking tutorial about <insert any fancy js framework here> and start blogging/tweeting about it
- Senior web developers who need to be told what the fuck CORS is and who can't even recognize CORS related errors in their browser console.
- People who have done nothing else for 18 years than building websites for companies on Wordpress 1.x and writing few lines of PHP and Javascript from time to time. Those who are now applying as a frontend dev due to the difficult economic situation and are surprised that they are not accepted due to a lack of experience.
- Developers who are the only ones working on Windows in the team and ask their Linux colleagues for help when Windows starts bitchin.
- People who have been coding for 30 years, have worked with ~42 languages and don't know the difference between compiled and interpreted languages in the job interview.
- Chief developers at a large newsletter-publisher who think it's a good idea to build your own CMS (due to a lack of good existing ones, of course).
- Developers who have been writing PHP applications for multinational corporations for 25 years and cannot explain how PHP is executed. They don't even know what the fucking OPcache is, let alone fpm. FML
- People who call themselves professional developers but never ever heard of DRY, KISS, boy-scout rule, 12-Factor App, SOLID, Clean Code, Design Patterns, ...
- Senior developers wondering why the bash script won't run on their fucking Windows machine.
- Developers who consider Typescript to be a hindrance and see no value in it.
- Developers using ftp for deployments in 2022
- Senior Javascript Developer applying for a job and for whom Integer is a primitive data type in JS.
- Developers who prefer to code without frameworks and libraries because they are only an unnecessary burden/overhead and you can quickly code everything up yourself.
- Developers who think configuring their server(s) manually is a good idea.
You fucking Prutscher. What you have already cost me in terms of work and nerves. I can't even put it into words how deeply I despise you. I have more respect for the chewing gum that has been stuck in my damn trash can for the past 3 years than I do for you guys. You are the disgrace of our profession. I will haunt you in your dreams and prefix every fucking synapse of your brain with MY initials.
As a well-known german band once sang in a very fitting song: I wouldn't even piss on you if you were on fire.
If you recognized yourself in one of the examples here: FUCK YOU!29 -
We are taking over an Android application source code from an external company to continue development in-house...
I present to you floateger:
(one of many crimes the previous developer has commited)15 -
Just found this in our code:
UINT8 variableName = 500;
Any developer who is getting paid should know the largest value an unsigned 8 bit integer can hold12 -
A colleague of mine had to debug performance problems in a foreign, proprietary application that is ancient.
To be crystal clear: Only reason that thing exists is because some old geezers fear change.
Asked me for help cause it's an _ancient_ MS SQL server that is luckily running on hardware owned by us.
Finding the credentials was already a funny task.
We had to access the vault (not joking here, we have a physical vault for storing sensitive data and critical backups), grab a folder and find the necessary data cause no one ever dares to touch that thing.
The application is btw for a sort of ERP / inventory system that is used in some ancient shops not yet migrated...
Yeah. Story speaks for itself.
Anyway, after dusting off ourselves, we were able to connect.
Was a bit ... Interesting. Everything's in german. The worst kind of german.
After looking at the first tables, I started giggling.
My colleague knew immediately that this was a sign of danger (insert Simpson meme here), raised his eyebrows and asked "How bad is it....".
Me, still giggling, "lemme take a further look, this is gold".
*long sigh from the colleague*
Well... It ended with me putting my hands in front of my eyes, turning around and saying: "I cannot look at it anymore, it hurts too much...."
To summarize:
- German table names
- When a table exceeded 300 plus columns, they added another table with the same plus suffix "_ddd"… where ddd is an zero filled integer sequence like 001
- To join this mess, they created views... Named "generator" - Sequence Number ... Some had the beginning of table names appended, which doesn't make it less confusing.
- the process list was listing queries running longer than 5 mins.
Which isn't at all surprising when generating carrtesian products of N tables with left join.
I've seen shit.... I've seen a lot of shit.
But that shit scared me.1 -
When you know so many programming languages that you start typing something like:
int i as integer1 -
2038 because of integer overflow we can finally start time travel and maybe a few satellites will fall down.4
-
While trying to integrate a third-party service:
Their Android SDK accepts almost anything as a UID, even floats and doubles. Which is odd, who uses those as UIDs? I pass an Integer instead. No errors. Seems like it's working. User shows up on their dashboard.
Next let's move onto using their data import API. Plug in everything just like I did on mobile. Whoa, got an error. "UIDs must be a string". What. Uh, but the SDK accepts everything with no error. Ok fine. Change both the SDK and API to return the UID as a string. No errors returned after changing the UIDs.
Check dashboard for user via UID. Uh, properties haven't been updating. Check search properties. Find out that UIDs can only be looked up as Integers. What? Why do you ask me to send it as a string via the API then? Contact support. Find out it created two distinct records with the UID, one as a string and the other as an Integer.
GFG.3 -
In C# you are not able to do bitwise operations on generic enums so you have to cast them to an integer via object... 😐 Apart from that, this awesome code shows what C# can do 😊7
-
Once upon a time, one or two jobs ago, a really awesome engineer specced out a distributed search application in response to a business need. This company was managed pretty oldschool and required a ton of paperwork and approvals.
The engineer spent many weeks running tests and optimizing the hell out of this app cluster. It flew, and he had the data to prove it could handle production workloads (think hundreds of terabytes of data being processed every single day)
Part of the way he achieved this was having RAID0 on all of the servers to maximize I/O throughput. He didn't care much about data loss, since the application itself was fault tolerant on a much more granular level.
Management, hearing about this, absolutely flipped their shit and demanded RAID6 instead. This despite the conclusive data that the engineer had that proved RAID6 couldn't keep up.
He more or less got told to STFU.
Even this despite the fact that a RAID restripe would actually take many times longer than rebuilding the failed node from scratch (a process that took about 30 minutes by hand, and could probably be automated to be done in less than five), causing a longer exposure to actual data loss throughout the length of the days-long array rebuild time.
The ill-thought-out requirement added about 50% to the cost of the project (*many* more hard drives now required), beyond the original budget, and the subsequent bureaucratic wrangling resulted in a late product launch.
6 months or so later, after real customers were using this product, the app was buckling under around half of its expected workload. A friend of the engineer suggested to management to try RAID0. Sure enough, that resolved the I/O bottleneck.
This rage-inducing story has a happy ending, though! Said engineer left the company not long after this incident, citing it as a reason for his departure. He was immediately hired by another company, making integer multiples of his prior salary.
The product the company botched the launch of by ignoring his spec? It died a few months later. Maybe the poor customer experience was to blame? Maybe the late launch? Maybe it was another reason entirely.
Either way, millions of dollars of hardware now sat fallow. This was a black eye on the company all the way up to the C-level.
tl;dr: Listen to your engineers. You hired them for their expertise.5 -
Reading up on how floats are stored and it's pretty cool how you can store numbers as large as 3.4×10^38 in the same amount of memory that an integer can store only about 2 billion.
Absolutely wonderful7 -
Fuck you javascript and your bizarre Date object.
May your ass itch, and arms become too short to reach.
Spend a good hour debugging why this fucker:
(new Date).getDay();
Returns 3, when it's actually the 2nd of May.
Turns out the value returned by getDay is an integer corresponding to the day of the week.
(new Date).getDate(); it is, ಠ_ಠ15 -
I was working on a project lately where I needed to convert an array of bits (1s and 0s) to floating numbers.
It is quite straightforward how to convert an array of bits to the simple integer (i.e. [101] = 5). But what about the numbers like `3.1415` (𝝿) or `9.109 × 10⁻³¹` (the mass of the electron in kg)?
I've explored this question a bit and came up with a diagram that explains how the float numbers are actually stored.
There is also an interactive version of this diagram available here https://trekhleb.dev/blog/2021/....
Feel free to experiment with it and play around with setting the bits on and off and see how it influences the final result.13 -
PHP arrays.
The built-in array is also an hashmap. Actually, it's always a hashmap, but you can append to it without specifying indexes and PHP will use consecutive integers. Its performance characteristics? Who knows. Oh, and only strings, ints and null are valid keys.
What's the iteration order for arrays if you use them as hashmaps (string keys)? Well, they have their internal order. So it's actually an ordered hashmap that's being called an array. And you can produce an array which has only integer keys starting with 0, but with non-sequential internal (iteration) order.
This array weirdness has some non-trivial implications. `json_encode` (serializes argument to JSON) assumes an array corresponds to a JSON array if its keys are consecutive integers in increasing order starting with 0, otherwise the array becomes a JSON object. `array_filter` (filters arrays/hashmaps using callback predicate) preserves keys, so it will punch holes in the int key sequence if non-last items are removed, thus turning arrays into hashmaps and changing your JSON structure if you forget to discard keys before serialization.
You may wonder how JSON deserialization works, then? There's a special class for deserialized JSON objects, `stdClass`. It's basically a hashmap too, but it's an object, not an array, and all functions that would normally accept arrays won't work with it. So basically its only use is JSON (de)serialization. You can even cast arrays to objects, producing `stdClass`.
Bonus PHP trivia:
Many functions return nonsensical values. `preg_match`, the regex matching function, returns 1 for success, 0 for no matches and false for malformed regular expression. PHP supports exceptions, so it could just throw one on errors. It would even make more sense to return true, false and null for these three cases. But no, 1, 0 and false. And actual matches are returned by output arg.
`array_walk_recursive`, a function supposed to recursively apply callback to each element of an array. That's what docs say. It actually applies it to leafs only. It will also silently accept object instead of array and "walk" it, but without recursing into deeper objects.
Runtime type enforcing is supported for function arguments and returned values. You can use scalar types, classes, array, null and a few special keywords. There's also a `mixed` keyword, which is used in docs and means "anything". It's syntactically valid, the parser will accept it, but it matches no values in runtime. Calling such function will always cause a runtime error.
Strings can be indexed with negative integers. Arrays can't.
ReflectionClass::newInstanceWithoutConstructor: "Creates a new class instance without invoking the constructor". This one needs no commentary.
`array_map` is pretty self-explanatory if you call it with a callback and an array. Or if you provide more arrays of equal length via varargs, callback will be called with more arguments, one from each array. Makes sense so far. Now, you can also call `array_map` with null instead of callback. In that case it treats provided arrays as rows of a matrix and returns that matrix, transposed.5 -
My computer science class in school is learning c# so slowly that last year it took 3 weeks for them to learn what an integer is.
I learned most of the language on a vacation last year and now I don't show up for class.
and actually, my teacher doesn't mind it, she encourages me about learning more and doing projects.
best teacher I've had so far.
recently the class teacher noticed me when I go home instead of going to class and he made me come to every lesson. Really frustrating.10 -
Empty your memory,
with a free(),
like a pointer.
If you cast a pointer to an integer,
it becomes the integer.
If you cast a pointer to a struct,
it becomes the struct.
The pointer can crash and can overflow.
Be a pointer my friend.1 -
Teaching new devs, hired straight from India.
This is today.
Bug1: We have four lists, each item in these lists has a variable called "Charge". This var is a double and we need to convert it to currency.
Dev creates fifth list called "All lists" and converted it's charge to currency then questioned why it didn't work.
I explained, his solution? Convert each list into currency.
I explained that's wrong and told him what he needed to do. He did List1:Charge into currency, but left his other conversion in place just in case.
I walked him through fixing it which took 10 times as long as necessary, only to find out he randomly converted four booleans into currency for no reason.
Bug2: we take integer, convert to string and concat "Months" on the end.
Doesn't work for him, tells me he doesn't know why.
I told him that he's not outputting the variable that we did it to, he is instead outputting a custom variable he made and didn't do anything to.
Bug 3: followup to #2, he fixed it as I instructed, but then added months as static text to the output so now it reads "Months months".
Bug 4: to make his code cleaner, he presses enter in the text box. Unfortunately he did that IN A STRING so his output is full of random /r/n
How do you guys deal with coworkers like this? He isn't new, this is supposed to be an experienced developer. Im only in my 2nd year23 -
There are so many weird hacks in the quite legacy app I work with I could write a book about all them hacks…
But I must admit, the worst of them all is internal time. Yes, so some blockhead thought it’s a good idea to represent time in a manner completely removed from Datetime objects or timestamps or even string representations. Instead we deal with them as intervals represented by integers - and because this is not fucked up enough by itself, the internal time doesn’t start at midnight, yet the integer representations do. It’s a bloody mess. No wonder most of the bugs we face have to do with dates and time…5 -
Why does MySql least and greatest functions return null if any of the arguments are null? Who was the genius behind the idea that it's the best way to implement it, and to change this behavior in a minor version?
Why does MySql return bigint when i convert a value to integer?
Why does MySql exist?17 -
Got to admit. Got a little surprised when stream.ReadByte() returned an integer instead of a byte.8
-
I found it yesterday that 6 and null is false and 4 is true in our database in addition to a previous rant. I went to see how it's stored. I assumed it was an integer.
It was a nvarchar(6). I just sat there in disbelief and felt disgusted.
It kept me up later than usual last night
Why tho? 😐1 -
ArmA 3, a great sandbox that I "wasted" a lot time scripting modding or, if you like to call it that: developing for.
A game so great, the Multiplayer-server-browser stores the amount of players on a server in an 8 bit integer.
Someone complaint a few years ago.
Response: " be happy, it were 4 bits not to long ago"
There were Servers who ran into that problem.
To clarify, that only affected the shown number, not the amount of players, at least not directly.
Who likes to be lonely in a multiplayer game.1 -
I have not researched it so I'm not sure if this is a widely known thing but I figured out a sort of hacky way to get a max integer value:
-Declare an unsigned int.
-Subtract 1
-Divide 2
That is your max signed int value
int main(){
unsigned int a = 0;
a--;
std::cout << a / 2 << std::endl;
}7 -
I hope devRant doesn't store ++ count as a signed 8-bit integer... Otherwise the next ++ this rant gets sets it to -128!2
-
Client from hell, next chapter.
As money comes in, project won't be canceled.
Only madness comes for free.
Newest insanity.... We had to explain that in a warehouse system a unique article number as an identifier is a must.... This discussion took 20 minutes.
The reason? Saving 2 secs as they don't have to enter the supplier item number....
Their plan?
Article Number can be...
Integer, automatically assigned
String, Supplier Name and Supplier Item Number seperated by a delimiter....
The argument that stopped this insanity... Costs.
We argued that if we are forced to implement something which we believe will be a high costs, no value, nonsense feature we won't do the necessary migration and programming after reversal as in 'find someone else who unbreaks this insanity'...
Did they understand that a warehouse system without article number for reference is dumb? Nope.1 -
How do you deal with massively poorly-performing and unknowledgeable teams?
For background, I've been in my current position for ~7 months now.
A new manager joined recently and he's just floored at the reality of the team.
I mean, a large portion of my interview (and his) was the existing manager explicitly warning about how much of a dumpster fire everything is.
But still, nothing prepares you for it.
We're talking things like:
- Sequential integer user ids that are passable as query string args to anonymous endpoints, thus enabling you to view the data read by that view *for any* user.
- God-like lookup tables that all manner of pieces of data are shoved into as a catch-all
- A continued focus on unnecessary stored procedures despite us being a Linq shop
- Complete lack of awareness of SOLID principles
- Actual FUD around the simplest of things like interfaces, inversion of control, dependency injection (and the list goes on).
I've been elevated into this sort of quasi-senior position (in all but title - and salary), and I find myself having to navigate a daily struggle of trying to not have an absolute shit fit every time I have to dive into the depths of some of the code.
Compounded onto that is the knowledge that most of the team are on comparable salaries (within a couple thousand) of mine, purely owing to length of service.
We're talking salaries for mid-senior level devs, for people that at market rates would command no more (if even close) than a junior rate.
The problem is that I'm aware of how bad things are, but then somehow I'm constantly surprised and confronted with ever more insane levels of shitfuckery, and... I'm getting tired.
It's been 7 months, I love the job, I'm working in the charity sector and I love the fact that the things I'm working on are directly improving people's lives, rather than lining some fintech fatcat's pockets.
I guess this was more a rant than a question, and also long time no see...
So my question is this:
- How do you deal with this?
- How do you go on without just dying inside every single day?8 -
Hmm. So have you ever argued in a job interview? Like really standing your ground? In a technical interview?
Today I had a live coding session with a company I'm interested in. The developer was giving me tasks to evolve the feature on and on.
Everything was TDD. Splendid!
However at one point I had to test if the outcome of the method call is random. What I did is basically:
```
Provider<String> provider = new SomeProvider("aaa", "bbb", "ccc", "ddd", "eee", "fff")
for(int i=0; i<100; i++) {
String str = provider.get();
map.put(str, incrementCount(str));
}
Set<Integer> occurences = new HashSet(map.values());
occurences.removeIf(o -> o.equals(occurences.get(0)));
assertFalse(occurences.empty());
```
and I called it good enough, since I cannot verify true randomness.
But the dev argued that this is not enough and I must verify whether the output is truly random or not, and the output (considering the provider only has a finite set of values to return) occurences are almost equal (i.e. the deviation from median is the median itself).
I argued this is not possible and it beats the core principle of randomness -- non-determinism. Since if you can reliably test whether the sequence is truly random you must have an algorithm which determines what value can or cannot be next in the sequence. Which means determinism. And that the (P)RNG is then flawed. The best you can do is to test whether randomness is "good enough" for your use case.
We were arguing and he eventually said "alright, let's call it a good enough solution, since we're short on time".
I wonder whether this will have adverse effect my evaluation . So have you ever argued with your interviewer? Did it turn out to the better or to the worse?
But more importantly, was I right? :D21 -
Fuck you Twitter for making your widgets createTweet-method only work with the tweet-id as string. Fuck you especially for don't returning nor throwing any error for giving an integer value to it.
This took some time... -
FUCK THE WINDOWS TEXT EDITOR FOR USING UNICODE WITHOUT TELLING ME. I SPEND HALF AN OUR FIGURING OUT WHY "1" COULDN'T BE PARSED INTO AN INTEGER.
-
So yeah XML is still not solved in year 2018. Or so did I realize the last days.
I use jackson to serialize generic data to JSON.
Now I also want to provide serialization to XML. Easy right? Jackson also provides XML serialization facitlity similar to JAXB.
Works out of the box (more or less). Wait what? *rubbing eyes*
<User>
<pk>234235</pk>
<groups typeCode="usergroup">
<pk>6356679041773291286</pk>
</groups>
<groups typeCode="usergroup">
<pk>1095682275514732543</pk>
</groups>
</User>
Why is my groups property (java.util.Set) rendered as two separate elements? Who the fuck every though this is the way to go?
So OK *reading the docs* there is a way to create a collection wrapper. That must be it, I thought ...
<User typeCode="user">
<pk>2540591810712846915</pk>
<groups>
<groups typeCode="usergroup">
<pk>6356679041773291286</pk>
</groups>
<groups typeCode="usergroup">
<pk>1095682275514732543</pk>
</groups>
</groups>
</User>
What the fuck is this now? This is still not right!!!
I know XML offers a lot of flexibility on how to represent your data. But this is just wrong ...
The only logical way to display that data is:
<User typeCode="user">
<pk>2540591810712846915</pk>
<groups>
<groupsEntry typeCode="usergroup">
<pk>6356679041773291286</pk>
</groupsEntry>
<groupsEntry typeCode="usergroup">
<pk>1095682275514732543</pk>
</groupsEntry>
</groups>
</User>
It would be better if the individual entries would be just called "group" but I guess implementing such a logic would be pretty hard (finding a singular of an arbitrary word?).
So yeah theres a way for that * implementing a custom collection serializer* ... wait is that really the way to go? I mean common, am I the only one who just whants this fucking shit just work as expected, with the least amount of suprise?
Why do I have to customize that ...
So ok it renders fine now ... *writes test for it+
FUCK FUCK FUCK. why can't jackson not deserialize it properly anymore? The two groups are just not being picked up anymore ...
SO WHY, WHY WHY are you guys over at jackson, JAXB and the like not able to implement that in the right manner. AND NOT THERE IS ONLY ONE RIGHT WAY TO DO IT!
*looks at an apple PLIST file* *scratches head* OK, gues I'll stick to the jackson defaults, at least it's not as broken as the fucking apple XML:
<plist version="1.0">
<dict>
<key>PayloadOrganization</key>
<string>Example Inc.</string>
<key>PayloadDisplayName</key>
<string>Profile Service</string>
<key>PayloadVersion</key>
<integer>1</integer>
</dict>
</plist
I really wonder who at apple has this briliant idea ...2 -
When creating auto incrementing integer keys on a MySQL database, please mark then as unsigned, you don’t need a negative primary key 😞😞😞4
-
The tons of undefined behaviour in C that ought to have been implementation defined instead, and increasingly sadistic compiler writers on the other side.
Like signed integer overflow that should just do what the underlying machine does, i.e. in practice, wrap around two's complement.
But the wierdest UB is when a C source code line has a non-matching ' or ". WTF, this should have been a compile time error!2 -
I hate that "integer overflows" have become somewhat pop culture because anytime I see someone try to use it in a joke, they use it wrong.
I've even seen people confuse them with stack overflows and be like "my intelligence is so low it stack underflowed and became the max of an integer value!"
Or "It overflowed and became zero again" ah, I guess it happened to be unsigned and overflowed by precisely 1 then eh?
So cringe15 -
after beginning to learn numpy , i believe these packages were really created by some clown of a circus xD.
Everything is sooooo entertaining!!!
i learned java 3 years ago, but today if i had to crap out some crazy java or c++ expert , i would tell him about numpy's arrays...
Like , "hey dude python has this cool data structure in the numpy library called arrays, which can hold any datatypes in a kind of arraylist like fashion, and you can convert them from 1 dimensional to 1000 dimensional in just 1 line , and also do you know we can select any column with just array[position]? and even this position does not needs to be an integer, you can use a list , like array[[1,2,3]] will give you elements at array[1],array[2],array[3], and...."
wait, why is my friend dead ? xD
HAhahahaha8 -
I just finished writing an Integer Java Virtual Machine in C.
Being able to write an echo server in IJVM Assembly, connect to it through netcat and see it run on my machine is legitimately one of the most satisfying moments I've had so far in programming. -
Riddle:
Alice and bob want to communicate a secret message, lets say it is an integer.
We will call this msg0.
You are Chuck, an interloper trying to spy on them and decode the message.
For keys, alice chooses a random integer w, another for x, and another for y. she also calculates a fourth variable, x+y = z
Bob follows the same procedure.
Suppose the numbers are too large to bruteforce.
Their exchange looks like this.
At step 1, alice calculates the following:
msg1 = alice.z+alice.w+msg0
she sends this message over the internet to bob.
the value of msg1 is 20838
then for our second step of the process, bob calculates msg2 = bob.z+bob.w+msg1
msg2 equals 32521
he then sends msg2 to alice, and again, you intercept and observe.
at step three, alice recieves bob's message, and calculates the following: msg3 = msg2-(alice.x+alice.w+msg0)
msg3 equals 19249. Alice sends this to bob.
bob calculates msg4 = msg3-(bob.x+bob.w)
msg4 equals 11000.
he sends msg4 to alice
at this stage, alice calculates ms5.
msg5 = (msg4-(alice.y)+msg0.
alice sends this to bob.
bob recieves this final message and calculates
the sixth and final message, which is the original hidden msg0 alice wanted to send:
msg6 = msg5-bob.y
What is the secret message?
I'll give anyone who solves it without bruteforcing, a free cookie.18 -
I've been using the Square REST API and I spent one hour thinking there was something wrong in my code until I f** found that THEY were not following OAuth 2 guidelines, which made their workflow incompatible with the OAuth lib I was using, so I had to mark an exception for Square's OAuth from the rest of my OAuths. Specifically, RFC 6749 Section 4.2.2 and 5.1.
However, after reading OAuth 2 guidelines, I became angry at THEM instead. The parameter `expires_in` should be the "lifetime in seconds" after the response. This will always be innevitably inaccurate, since we are not taking into account the latency of the response. This is, however, not a huge problem, since the shortest token lifetimes are of an hour (like f** Microsoft Active Directory, who my cron jobs have to check every ten minutes for new access tokens). Many workflows (like Microsoft, Square, and Python's oauthlib) have opted to add the `expires_at` parameter to be more precise, which marks the time in UTC. However, there's no convention about this. oauthlib and Microsoft send the time in Unix seconds, but Square does this in ISO 8601. At this point, ISO 8601 is less ambigious. Sending a raw integer seems ambiguous. For example, JavaScript interprets integer time as Unix _milliseconds_, but Python's time library interprets it as _seconds_. It's just a matter of convention, a convention that is not there yet.
Hope this all gets solved in OAuth 2.1 pleeeaasseee1 -
You know, I kinda wished that my school had really old and crappy PCs with a few KBs of ram... that way people would learn not to use an integer for the age5
-
I was looking up for a bug in my code that caused a fail in one of the test.
Hours later I found that negative integer division in python is just stupid and -1 / 10 = -1.
The sad part is that -1/10 != -(1/10) contradicting the associative property of multiplication over the real numbers.
FUCK YOU PYTHON.12 -
Inspired by @shahriyer 's rant about floating point math:
I had a bug related to this in JavaScript recently. I have an infinite scrolling table that I load data into once the user has scrolled to the bottom. For this I use scrollHeight, scrollTop, and clientHeight. I subtract scrollTop from scrollHeight and check to see if the result is equal to clientHeight. If it is, the user has hit the bottom of the scrolling area and I can load new data. Simple, right?
Well, one day about a week and a half ago, it stopped working for one of our product managers. He'd scroll and nothing would happen. It was so strange. I noticed everything looked a bit small on his screen in Chrome, so I had him hit Ctrl+0 to reset his zoom level and try again.
It. Fucking. Worked.
So we log what I dubbed The Dumbest Bug Ever™ and put it in the next sprint.
Middle of this week, I started looking into the code that handled the scrolling check. I logged to the console every variable associated with it every time a scroll event was fired. Then I zoomed out and did it.
Turns out, when you zoom, you're no longer 100% guaranteed to be working with integers. scrollTop was now a float, but clientHeight was still an integer, so the comparison was always false and no loading of new data ever occurred. I tried round, floor, and ceil on the result of scrollHeight - scrollTop, but it was still inconsistent.
The solution I used was to round the difference of scrollHeight - scrollTop _and_ clientHeight to the lowest 10 before comparing them, to ensure an accurate comparison.
Inspired by this rant: https://devrant.com/rants/1356488/...2 -
I want to explain to people like ostream (aka aviophille) why JS is a crap language. Because they apparently don't know (lol).
First I want to say that JS is fine for small things like gluing some parts togeter. Like, you know, the exact thing it was intended for when it was invented: scripting.
So why is it bad as a programming language for whole apps or projects?
No type checks (dynamic typing). This is typical for scripting languages and not neccesarily bad for such a language but it's certainly bad for a programming language.
"truthy" everything. It's bad for readability and it's dangerous because you can accidentaly make unwanted behavior.
The existence of == and ===. The rule for many real life JS projects is to always use === to be more safe.
In general: The correct thing should be the default thing. JS violates that.
Automatic semicolon insertion can cause funny surprises.
If semicolons aren't truly optional, then they should not be allowed to be omitted.
No enums. Do I need to say more?
No generics (of course, lol).
Fucked up implicit type conversions that violate the principle of least surprise (you know those from all the memes).
No integer data types (only floating point). BigInt obviously doesn't count.
No value types and no real concept for immutability. "Const" doesn't count because it only makes the reference immutale (see lack of value types). "Freeze" doesn't count since it's a runtime enforcement and therefore pretty useless.
No algebraic types. That one can be forgiven though, because it's only common in the most modern languages.
The need for null AND undefined.
No concept of non-nullability (values that can not be null).
JS embraces the "fail silently" approach, which means that many bugs remain unnoticed and will be a PITA to find and debug.
Some of the problems can and have been adressed with TypeScript, but most of them are unfixable because it would break backward compatibility.
So JS is truly rotten at the core and can not be fixed in principle.
That doesn't mean that I also hate JS devs. I pity your poor souls for having to deal with this abomination of a language.
It's likely that I fogot to mention many other problems with JS, so feel free to extend the list in the comments :)
Marry Christmas!34 -
Each time my colleague pronounces “integer” with a hard “g”, I feel like cutting my ears off with a rusted and blunt hacksaw. Anything to make it stop!17
-
Company has a severe lack of fresh blood.
"let's recruit everyone who has an IQ over room temperature and barely passes the mark".
Me protesting bloody murder cause I know that the idea is not just profoundly dumb, but frustration from high staff turnover takes a toll on *everyone*.
"nah can't be that bad".
Then the discussion started who could do monitoring and mentoring, so we can sort out the bad apples *quickly*.
Me reminding again that this is exactly what leads to a high staff turnover, as this is nothing else than "hire, hire - quickly fire".
Guess who won the award of being the mentor / monitor ....
*drum roll*
Come on, I know you would NEVER expect this.
Let me surprise you: M E.
Yeah. They chose the person that was absolutely against this idea...
Because that person is "most qualified for the task at hand and has the necessary qualifications".
Today was the first 4 h workshop with a new recruit.
The Lord has had zero mercy on me.
I started to mute myself after 30 minutes in regular intervals to just scream and curse the world.
How profound dumb a person can be amazes me.
Person has had a "very expensive 6 month boot camp course".
I was close asking if the boot camp course was in watching porn and wanking their brain cells out....
Git... Yeah he knew what he was doing...
Except that he messed up every commit by either not sticking to the companies format or - what I found funny the first 2 times, then not so much anymore - just writing a git commit message like a 15 year old teenage girl would write to their diary.
Programming. Oh yeah. He should be a programmer.
He had much Bootcamp.
Bootcamp expensive. Bootcamp good.
If someone is unable to iterate over an iterator... And instead starts creating an integer based array of a map's key name to then fetch the map value in an for loop based on the created key array.
Yeah. Bootcamp much good.
Creating DTOs...
It took an hour to write a DTO with him... Cause constructors are hard and it's even harder when you have to explain primitive datatypes in Java, null safety, constructors, NPEs, final, ...
Like really no experience at all.
The next week's will be amazing.
Either I get a valium drop or I'm gonna blow my head off, cause mentoring will drain the last bit of hope I had left in me.
Note that I do not blame the recruit (yeah he's dumb. But he has ZERO work experience, so it's not unexpected), I'm just too fed up with getting the poo crown despite being against the whole process.
I think the recruit could make it..........
But that I got the shittiest job ever is really haunting me.
I dunno how I survive the next weeks.
And this is just the first recruit... There will be more.2 -
One thing when working with a ton of data:
If there is a slight, infinitesimal probability that something will be wrong, then it will 100% be wrong.
Never make assumptions that data is consistent, when dealing with tens of gigabytes of it, unless you get it sanitized from somewhere.
I've already seen it all:
* Duplicates where I've been assured "these are unique"
* In text fields that contain exclusively numeric values, there will always be some non-numeric values as well
* There will be negative numbers in "number sequences starting with 1"
* There will be dates in the future, and in the far far future, like 20115 in the future.
* Even if you have 200k customers, there will be a customer ID that will cause an integer overflow.
Don't trust anything. Always check and question everything.5 -
86 lines of code...duplicated 3 times in the same file...and only a single integer constant is different. This is the shit that makes my day to day work tedious.
Im glad I dont personally know the previous dev, he would get his throat punched...though calling him a dev is more of a compliment than he deserves.2 -
I once made an oopsie in an API for a logistics provider (one of the biggest in Germany...).
To understand the oopsie...
Based on input data a string must be created containing several hex / string / formatted values.
Think of ...
$return .= sprintf("%02X", ...)
I think there were around 15 to 20 lines, although more complicated.
The bug happened because I had a brainfart.
What was previously one line with... Many many many many variables, I had to split into multiple lines since internal stuff changed and it was impossible to change this oneliner of hell with >50 formatting codes.
Of course we didn't test everything.
XD
What we didn't test was - funnily enough - wether the casting was correct in all cases.
I misplaced a formatting code.
And we had a major brainfart because we tested integer, but not double / float values....
We sent for a long time packages much cheaper than allowed (took thw logistics provider nearly 3-4 months to realize this :) ).
Spot the difference:
@highlight
print sprintf("%01.2s", $money).PHP_EOL;
print sprintf("%01.2f", $money).PHP_EOL;1 -
While I was exploring multiplication tables I stumbled on something cool.
Take any power of 2 on the multiplication chart.
Now look at the number in the bottom left adjacent box.
The difference of these two numbers will always be a Mersenne number.
Go ahead. Starting on the 2's column of a multiplication table, look in the bottom left of each power of 2 and get the difference.
2-2 = 0
4-3= 1
8-5 = 3
16-9=7
32-17=15
etc.
While the online journal of integer sequences lists a lot of forumlas, I just wrote what came to mind (I'm sure its already known):
((2**i)-(((2**i)/2)+1))
The interesting thing about this is it generates not only the Mersenne numbers, but if you run i *backwards* it generates *additional* numbers.
So its a superset of mersenne numbers.
at i = 0 we get -0.5
i=-1 -> -0.75
i=-2 -> -0.875
i=-3 -> -0.9375
i=-4 -> -0.96875
And while this sequence is *not* mersenne numbers, mersenne numbers *are* in this set.
Just a curious discovery is all.10 -
What idiot uses 0 for a success response!!! Integrating with a 3rd party I found a bug in our code that uses the default value for an int when the external server can't be reached.
As it happens 0 is the default integer in most languages so no surprise when our system accepted the 3rd party as a success when it blew up 😒4 -
Stop fucking with the numbers.
A number is a number, integer or float.
Just because you wanted your stupid decimal place doesn't mean you need to fuck things up and make the front-end break because now its sending a string the server instead of a float. For fuck sakes. How long have we been doing this?5 -
Gotta make a decision matrix like the one in the picture. It's for a recommendation report concerning whether or not to distribute laptops to the CSCE students at my university and what kind of laptop if so.
I need help determining the weights for my matrix, because my personal preferences may not reflect the majority. As a programmer, how would you weigh the following three (very broad) categories?
Power(CPU, GPU, memory, HDD, I/O, etc..)
Quality (Durability, material, aesthetics, etc..)
Comfort(Weight, size, shape, keyboard, screen-eye comfort, OS familiarity, etc..)
Please write an integer 1-10 in the following format:
Power/Quality/Comfort ex: 7/4/9
Thanks, everyone!
-The Adderall'd-up devRant Noob, Benby15 -
Integer range is 2,147,483,647. Facebook has 2.96B users. Facebook is the only company that graduated from int to unsigned int, which is 4,294,967,295.
And you're using bigint as an id for the “users” table. I just laugh.10 -
Question - is this meaningful or is this retarded?
if
2*3 = 6
2*2 = 4
2*1 = 2
2*0 = 0
2*-1 = -2
then why doesnt this work?
6/3 = 2
6/2 = 3
6/1 = 6
6/0 = 0
6/-1 = -6
if n/0 is forbidden and 1/n returns the inverse of n, why shouldn't zero be its own inverse?
If we're talking "0" as in an infinitely precise definition of zero, then 1/n (where n is arbitrarily close to 0), then the result is an arbitrarily large answer, close to infinite, because any floating point number beneath zero (like an infinitely precise approximation of zero) when inverted, produces a number equal to or greater than 1.
If the multiplicative identity, 1, covers the entire set of integers, then why shouldn't division by zero be the inverse of the multiplicative identity, excluding the entire set? It ONLY returns 0, while anything n*1 ONLY returns n.
This puts even the multiplicative identity in the set covered by its inverse.
Ergo, division by zero produces either 0 or infinity. When theres an infinity in an formula, it sometimes indicates theres been
some misunderstanding or the system isn't fully understood. The simpler approach here would be to say therefore the answer is
not infinity, but zero. Now 'simpler' doesn't always mean "correct", only more elegant.
But if we represent the result of a division as BOTH an integer and mantissa
component, e.x
1.234567 or 0.1234567,
i.e. a float, we can say the integer component is the quotient, and the mantissa
is the remainder.
Logically it makes sense then that division by zero is equivalent to taking the numerator, and leaving it "undistributed".
I.e. shunting it to the remainder, and leaving the quotient as zero.
If we treat this as equivalent of an inversion, we can effectively represent the quotient from denominators of n/0 as 1/n
Meaning even 1/0 has a representation, it just happens to be 0.000...
Therefore
(n * (n/0)) = 1
the multiplicative identity
because
(n* (n/0)) == (n * ( 1/n ))
People who math. Is this a yea or nay in your book?25 -
Did the loan amount offered to me just cause an integer overflow !!!
I dont know if i should be happy or sad6 -
Light Shot is the worst app and website ever .... No privacy
So I write a simple PHP script for Windows machine, to randomly generate integer and char for randomly open URL.
By running ```php run.php``` you able to see some sensitive information sometimes.
Refer https://github.com/johnmelodyme/...6 -
Today's rant: JavaScript's type system.
I realized halfway through that I can't happily call JavaScript a "programming language" so just assume
alias programming="scripting"
I'm sure it's not actually as frustrating as it seems to me. Thing is, I'm used to either statically-typed languages or dynamically-typed languages that actually make sense. If I were to try to add an integer to something I'd forgotten was a string in Python, it'd immediately tell me "look, buddy, do you want me to treat this as a concatenation or an addition? I have no idea the way you've got this written." I've found that mistakes are a common thing with dynamic typing. Maybe I'm just not experienced enough yet, maybe it's really as stupid as it looks. JavaScript just goes "hey look I'm gonna tack all of these guys together and make a weird franken-string like '$NaN34.$&' because that's absolutely what we want here!" Then I run my webpage and instead of a nice numeric total like I wanted, good old JavaScript just went "Yep, I have no idea what I'm doing here I'm just gonna drop this here and pretend it's right." Now absolutely I do not expect my programming language to make correct assumptions and read my mind, otherwise JavaScript would be programming me and not the other way around. But it could at least let me know that I had incompatible types going on rather than just shamelessly going along with what it's doing. Good GRIEF, man, some of the idiosyncrasies of the EMCAScript language definition itself just make me want to punch a horse.6 -
Unlike the built-in ** operator, math.pow() converts both its arguments to type float. Use ** or the built-in pow() function for computing exact integer powers.
Well who knew?
source: python docs3 -
int i = 0; // i is an integer initialized to 0
wtf?!?!?
comments should explain why not how or what the code is doing...1 -
When you’re trying to write a function to convert a base 10 integer to a base 2 integer in Javascript without using parseInt() and it takes you a while to realize that you’re used to integer division being integer division and have forgotten that JavaScript stores numbers as double precision floating point. *facepalm*1
-
The past few months i got a bunch of emails and calls from my previous "boss" (hes the head of the research), that he would be grateful if i helped them out. I got a few friends still working on that piece of shit project so i said yeah, i can help.
Now this whole thing is a research involving most of the big universities, lots of math phds, and is kinda secret. They couldnt find anyone to sketch up a few stupid algorithms for them so i did just that.
Yesterday i got the specifications for the task. Its the core functioning algo, the one i made from fucking discrete integer data, it took me 3 fucking months to correct their mistakes, and now they want me to create 2 similar patterns for 2 completely different...things. Yeeeah no.3 -
so i have to practice on codewars for homework and my code.. doesnt work! what a surprise. i was wondering if anyone could tell me whats wrong since yall are professionals. its probably a stupid mistake. this is the challenge: Implement a method that excepts three integer values a, b, c. The message return true if a triangle can be built with the sides of given length and false in any other case.13
-
I spent the whole day coding in python (usually I code in php or perl) and this language is a fucking joke. C'mon, why everything have to be done in such a weird way? And don't say it's python way because it's bullshit way. Want some examples?
", ". join(str(x) for x in array)
to join array of integers. wtf is that?
True|False
why in hell you need the first letter to be uppercase when your own fucking standard says to use lowercase letters in eg. var names and method names. why?
math.isnan(float(x))
to check if a variable (expected to be integer) is NaN. I won't fucking comment that...
Even prolog don't have such stupid things6 -
¡rant|rant
Nice to do some refactoring of the whole data access layer of our core logistics software, let me tell an story.
The project is around 80k lines of code, with a lot of integrations with an ERP system and an sql database.
The ERP system is old, shitty api for it also, only static methods through an wrapper to an c++ library
imagine an order table.
To access an order, you would first need to open the database by calling Api.Open(...file paths) (yes, it's an fucking flat file type database)
Now the database is open, now you would open the orders table with method Api.Table(int tableId) and in return you would get an integer value, the pointer.
Now for the actual order. first you need to search for it by setting the search parameter to the column ID of the order number while checking all calls for some BS error code
Api.SetInt(int pointer, int column, int query Value)
Then call the find method.
Api.Find(int pointer)
Then to top this shitcake of an api of: if it doesn't find your shit it will use the "close enough" method of search.
And now to read a singe string 😑
First you will look in the outdated and incorrect documentation given to you from the devil himself and look for the column ID to find the length of the column.
Then you create a string variable with ALL FUCKING SPACES.
Now you call the Api.GetStr(int pointer, int column, ref string emptyString, int length)
Now you have passed your poor string to the api's demon orgy by reference.
Then some more BS error code checking.
Now you have read an string value 😀
Now keep in mind to repeat these steps for all 300+ columns in the order table.
News from the creators: SQL server? yes, sql is good so everything will be better?
Now imagine the poor developers that got tasked to convert this shitcake to use a MS SQL server, that they did.
Now I can honestly say that I found the best SQL server benchmark tool. This sucker creams out just above ~105K sql statements per second on peak and ~15K per second for 1.5 second to read an order. 1.5 second to read less than 4 fucking kilobytes!
Right at that moment I released that our software would grind to an fucking halt before even thinking about starting it. And that me & myself and I would be tasked to fix it.
4 months later and two weeks until functional beta, here I am. We created our own api with the SQL server 😀
And the outcome of all this...
Fixes bugs older than a year, Forces rewriting part of code base. Forces removal of dirty fixes. allows proper unit and integration testing and even database testing with snapshot feature.
The whole ERP system could be replaced with ~10 lines of code (provided same relational structure) on the application while adding it to our own API library.
Best part is probably the performance improvements 😀. Up to 4500 times faster and 60 times less memory usage also with only managed memory.3 -
An anti-rant: I just made some code and out of nowhere it suddenly had an awesome feature that I didn't even program. No, not a euphemism for "bug", an actual feature.
Here's the story: A few months ago I made a shortcut for "System.out.println(…)" called "print(…)". Then I developed it further to also print arrays as "[1,2,3]", lists as "{1,2,3}", work with nested arrays and lists and accept multiple arguments.
Today I wanted to expand the list printing feature, which previously only worked for ArrayLists, to all types of List. That caused a few problems, but eventually I got it to work. Then I also wanted to expand it to all instances of Collection. As a first step, I replaced the two references to "List" with "Collection" and magically, no error message. So I tested it with this code:
HashMap<Integer, String> map = new HashMap<>();
map.put(1, "1");
map.put(2, "");
map.put(3, "a");
print(map);
And magic happened! The output was:
{1=1, 2=, 3=a}
That's awesome! I didn't even think yet about how I wanted to display key-value pairs, but Java already gave me the perfect solution. Now the next puzzle is where the space after the comma comes from, because I didn't program that in either.
I feel a bit like a character in "The subtle knife", who writes a barebones program to communicate with sentient elementary particles (believe me, it makes sense in context) and suddenly there's text alignment on the left and right, without that character having programmed any alignment.4 -
When we subtract some number m from another number n, we are essentially creating a relationship between n and m such that whatever the difference is, can be treated as a 'local identity' (relative value of '1') for n, and the base then becomes '(base n/(n-m))%1' (the floating point component).
for example, take any number, say 512
697/(697-512)
3.7675675675675677
here, 697 is a partial multiple of our new value of '1' whose actual value is the difference (697-512) 185 in base 10. proper multiples on this example number line, based on natural numbers, would be
185*1,
185*2
185*3, etc
The translation factor between these number lines becomes
0.7675675675675677
multiplying any base 10 number by this, puts it on the 1:185 integer line.
Once on a number line other than 1:10, you must multiply by the multiplicative identity of the new number line (185 in the case of 1:185), to get integers on the 1:10 integer line back out.
185*0.7675675675675677 for example gives us
185*0.7675675675675677
142.000000000000
This value, pulled from our example, would be 'zero' on the line.
185 becomes the 'multiplicative' identity of the 1:185 line. And 142 becomes the additive identity.
Incidentally the proof of this is trivial to see just by example. if 185 is the multiplicative identity of 697-512, and and 142 is the additive identity of number line 1:185
then any number '1', or k=some integer, (185*(k+0.7675675675675677))%185
should equal 142.
because on the 1:10 number line, any number n%1 == 0
We can start to think of the difference of any two integers n, as the multiplicative identity of a new number line, and the floating point component of quotient of any number n to the difference of any number n-m, as the additive identity.
let n =697
let m = 185
n-m == '1' (for the 1:185 line)
(n-m) * ((n/(n-m))%1) == '0'
As we can see just like on the integer number line, n%1 == 0
or in the case of 1:185, it equals 142, our additive identity.
And now, the purpose of this long convoluted post: all so I could bait people into reading a rant on division by zero.30 -
Look at this amazing chaos game fractal.
Three vertices of an equilateral triangle and a random point p between any two vertices are taken,then we generate a random integer between 1 and 6 (just like throwing a dice) .if 2 or 4 comes on the dice we draw a point between the random point p and the vertex v1.similarly if 3 or 4 comes on dice , we draw a point between the previously drawn point and vertex v2.for 5 or 6 the vertex is v3.after a few iterations we get to see this amazing pattern30 -
DAYLIGHT SAVING!!
Up to this point, I was indifferent to the issue if it should be kept or not. My sleep schedule is fucked and non-routine anyway so one hour plus or minus doesn't play any role.
I got to a meeting scheduling problem, when I have 2 timestamps in variable timezones and want to calculate time difference. Both can have DST active. There is no algortihmic way to figure out. I checked SO and pytz and it's just a list of hardcoded dates when DST starts and ends. WHATHTEHELL.jpg
Not only we should abolish the DST, we should force the whole world into UTC/Zulu. And those, who refuse to adapt to UTC, will be forced to work with plain integer epoch dates.3 -
Swift SUCKS
Why?
Because of its absolutely useless complexity...
a total simple thing: i have a string and want to concat a integer with it, so:
var x = stringVar + intVar; right? NO
its var x = stringVar + String(intVar);
or getting the index of a element in a array?
var index = array.indexOf(element); thats logic, right??? Not for swift, gotta go with: var index = array.index(of: element); WTF??!!
And all the other shit: nil instead of null, int++? Nope.
And there are SO MANY MORE things, where u just think, Apple really though different........than all normal coding languages.......
I´ll honestly rather learn C and recode Ios or have a look at objective-c...14 -
It appears I've discovered myself quite talented at solving problems.
And also, that I'm surrounded by idiots, who don't know what an integer is.
Also, that im an idiot.2 -
Why do io-interfaces usually use a signed integer to return the number of bytes processed?
Like seriously, you literally can't write/read less than 0 bytes.4 -
Anyone else like... REALLY bad at algorithms and logic stuff?
I just hate them so much.
Tell me to build something and gg done. But all these tests for jobs freak me out.
Like. It probably ends up being something simple and when it's explained I know what to do but at first I just instantly shut down and can't think.5 -
So here I am trying to understand the database schema in order to write a REST interface. Then I find that one of the tables contains an id and a name columns but the name is Integer not a string!
I contacted the developer who gladly explained that it was easier for them to store the ids in the database but the actual names strings were hard coded in the source files so they can handle translations! -
Just remembered that I still had a foobar invite link in my email inbox 😋
The challenges are odd though, first challenge was super easy (basically an idiot check), but while I was able to convert 3 cans of energy drink into a functional solution in half an hour, the verification utility is not very verbose at all. So in Python 3.7.3 in my Debian box it worked just fine, yet the testing suite in Foobar was failing the whole time. After sending an email to my friend that gave the link (several years ago now, sorry about that! 😅) asking if he knew the problem, I found out that Google is still using Python 2.7.13 for some reason. Even Debian's Python is newer, at 2.7.16. To be fair it does still default to Python 2 too. But why.. why on Earth would you use Python 2.7 in a developer oriented set of challenges from a massive company, in 2020 when Python 2 has already been dead for almost a whole year?
But hey now that it's clear that it's Python 2.7, at least the next challenges should be a bit easier. Kind of my first time developing in SnekLang regardless actually, while the language doesn't have everything I'd expect (such as integer square root, at least not in Debian or the foobar challenge's interpreter), its math expressions are a lot cleaner than bash's (either expr or bc). So far I kinda like the language. 2-headed snake though and there's so much garbage for this language online, a lot more than there is for bash. I hate that. Half the stuff flat out doesn't work because it was written by someone who requires assistance to breathe.
Meh, here's to hoping that the next challenges will be smooth sailing :) after all most of the time spent on the first one (17.5 hours) was bottling up a solution for half an hour, tearing my hair out for a few hours on why Google's bloody verification tool wouldn't accept my functioning code (I wrote it for Python 3, assuming that that's what Google would be using), and 10 hours of sleep because no Google, I'm not scrubbing toilets for 48 hours. It's fair to warn people but no, I'm not gonna work for you as a cleaning lady! 😅
Other than the issues that the environment has, it's very fun to solve the challenges though. Fuck the theoretical questions with the whiteboard, all hiring processes should be like this!1 -
Can any sql guru take a look at this problem?
I try to select number array from a JSON object, but have no idea how to do it.
https://stackoverflow.com/questions...5 -
How the fuck does php type juggleling evaluate an variable as an integer on my system and passing all tests.
Then on the server as string, failing a typesafe comparison for authentication.8 -
find /etc/www/jobs/good | lncount
Count: 0
find /etc/www/jobs/crap | lncount
Error: integer overflow: "count too big" -
public static Map<Integer, List<Integer>> stuff(arguments) {
HashMap<Integer, List<Integer>> map = new HashMap<>();
method(map, otherVariables);
return map;
}
public static void method(HashMap map, otherVariables) {
map.put(things);
}
So... You know how to return a map from a method. Then why do you create the map outside the method and make it an argument that does not get returned, making it confusing because the map gets created empty, given to a different method, then returned, making it look like you're returning an empty map...
...instead of just creating it inside the called method, returning it and assigning it to a map in the calling method? Even if you think that would create another map (it doesn't), the compiler is intelligent and can optimise that away.9 -
When every related field has a god damn different way of working with the data on hand..
For example:
`tht_date` ("Y-m-d", Date) - expiration date on the product, hence, there can be multiple of the same products with a different THT
`tht_alert` ("-2 months", varchar, DateTime modify mutation string) - sending an alert when this interval is hit, and being the activator of the tht_date field (unless value is "none")
`tht_minimum` ("28", integer, quantity of days before tht_date) - to lock them from being sent out/collected.
...
How would you expect this ×not× to become a friggin' spaghetti when trying to resolve the best row ID?
These values are in the wrong spot in the first place, then they also act entirely different in relation to eachother..
I hate the person that set this up, for doing this. When is the madness going to stop...
FFS!! -
"DataSource.Factory<Integer, Rv1data>"
>>"Error, Factory doesn't existt"
>> checked every tutorial on internet: twice.
>> rebuild the whole project: thrice
>> checked the xmls,activities,views,gradle: 4 times
>> thoughts of throwing my laptop : 5 times
.
.
.
checked the import modules:
>>imported javax.sql.DataSource instead of androidx.paging.DataSource
FUUUUUUUUUUUUUUU😡😡😡😡 -
1. Find a function: getDayDiff(d1, d2)
2. d1 and d2 are momentjs dates.
3. See that function performs complex ancient math rituals and then returns an integer
4. Try to rewrite function, return d2.diff(d1, 'days')
5. Should be OK right? Run tests
6. Whole module melts down. WTF?!
Turns out the math performed returned the difference + 1 because it included the current day which moment's diff() function does not (out of the box).
Processes that depended on this function then uses the result like this:
const diff = getDayDiff(d1, d2)
if (diff-1 == should_match) { /* more fun logic */ }
$ git checkout .
$ run-shutdown-script-because-fuck-you2 -
Both the FAT32 and ISO9660 file systems have a 4 GB file size limitation due to storing file sizes as a 32-bit integer. However, the developers of ISO9660 had an idea that the geniusheads at Microsoft failed to think of.
ISO 9660, the first widely used file system on optical discs, bypasses its own 4 GB file size limit by supporting multiple entries for the same file! So a 12 GB file can be represented as three entries for the same file name.
This is what future-proofing looks like.
If only Microsoft had had (sic.) this idea for FAT32 (and FAT16).2 -
This is probably a standard pattern/algorithm, but I feel pretty good about myself figuring this out.
I was doing a programming challenge and found myself with 2 lists of integer points (x,y). I needed to see where the points converged and identify those locations. Of course I started with a brute force approach and did nested loops to find these locations. This was taking WAY TOO LONG. These lists were 200K each. So checking with naive looping is 200K * 200K operations. Which is a lot.
Then I thought, well I am checking equality, so I will create a third map. The index to the map will be the point, and the data will be an integer. I then go through each list once incrementing the integer for each point that exists in each respective list. Any point with a value greater than 1 is a point convergence.
Like I said, this has got to be a standard thing, so can someone tell me what algorithm this is? I am not sure how to search for this.
I am fuzzy on complexity notation but I think the complexity started at n^2 and was reduced to n. Each list is cycled over once.4 -
So, here we are using postgres in production with the fancy feature of UPSERT. We’ve got loads of request popping in, both new and updates - so the UPSERT getting triggered alot. Today we faced a problem with integer within our app stating that the number is too high. We were like «WTF? Already?!»! After looking in to the features of UPSERT, we came to realize that any sequence will be incremented regardless of an insert being handled. This results then in an ID field being defined with ids such as:
1
2
5
19
222
73377
282828282
Etc. You get the point..
This design is so WTF and I have absolutely no idea why anyone would like their IDs to be generated and incremended even though there is no insert. I hope it is due to my naivity that I cannot comprhend it. Oh well. UPSERT, you’re forever gone 👍🔥2 -
!Rant
Why in hell did we try to get smart with this shit!? As simple as storing 2 values and reading them... But no... Someone wanted to get pretty with it, stored the two values but just read one because the other can be calculated...
Makes sense (btw it's [field] in minutes and [field] in seconds)... Some problems:
1. Why? Oh because someone designed it as int...
2. Why not just in seconds? Fuck you that's why...
3. Who the fuck thought that getting seconds from minutes is better then getting minutes from seconds when we only store integer values?
Thank you... I feel better4 -
Approaching the limit of what TI-BASIC can do without busting out the modern calcs. Doing a simple operation on the whole 95x63 1bpp graph mode screen, say, turning all pixels on or off, takes over a minute. Add any sort of calculation to that...
I'm already using BASIC-callable machine code snippets to scroll the screen one pixel (which are nigh instantly finished,) and i'm so fucking tired of scrolling effects...
God, adding sound is gonna be a nightmare...
EDIT: for reference, dev machine is a TI-84+ Silver Edition. Not one of the ones with the eZ80 and backlit color screens, the greenish Z80 1bpp screened one. The one that's an 8MHz Zilog that TI decided to make multitask. The one where oscillating the screen at an integer division of full framerate fries it in seconds? -
A bit longer rant, somehow triggered by the end of this rant:
https://devrant.com/rants/7145365/...
The discussion revolved around strpos returning false or a positive integer.
Instead of an Option or a Exception.
I said I'm a sucker for exception, but I'm also a sucker for typing.
Which is something most languages lack - except the lower level ones like C / C++.
I always loved languages which have unsigned and signed types.
There, I said it... :) I know that signed / unsigned is controversial, Google immediately leads to blog entries screaming bloody murder because unsigned can overflow – or underflow, if someone tries to use a -1on an unsigned integer.
Note that my love is only meant for numeric types, unsigned / signed char is ... a whole can of insanity on its own.
https://phoronix.com/news/...
If you wanna know more.
Back to the strpos problem, now with my secret love exposed:
strpos works on a single string, where a string is a sequence of chars starting with 0.
0 is a positive integer.
In case the needle (char that should be looked up in the string) cannot be found in the haystack (the string), PHP returns "false".
This leads to the necessity of explicitly checking the type as "0" (beginning of string, a string position)... So strpos !== false.
PHP interprets 0 as false, any other integer value is true.
In the discussion, the suggestion came up to return -1 if a value could not be found – which some languages do, for example Scala.
Now I said I have a love for unsigned & signed integers vs. just signed integers...
Can you guess why the -1 bothers me very much?
Because it's a value that's illogical.
A search in a sequence that is indexed by 0 can only have 0 or more elements, not less than zero elements.
-1 refers to a position in the sequence that *cannot* exist.
Which is - of course - the reason -1 was chosen as a return value for false, but it still annoys me.
An unsigned integer with an exception would be my love as a return value, mostly because an unsigned integer represents the return value *best*. After all, the sequence can only return a value of 0 ... X.
*sigh*
Yes, I know I'm weird.
I'm also missing unsigned in Postgres, which was more or less not implemented because it's not in the SQL standard...
*sob*29 -
"Most memorable bug you fixed?"
A recent instance happened in one of my Scratch projects, and the bug involved "Infinities."
I had an opportunity to teach kids programming, and it involved Scratch. So, to have something to show those kids at least, I decided to make a small game.
In that game, I had an object that takes some time before appearing after being cloned (i.e., instantiated.) The duration was calculated by dividing a constant with a variable:
[Wait for ((3) / (variable)) seconds]
The bug is that I forgot about the case where 'variable' can be 0, which is classic and insignificant.
Well, the thing is that I learned two things the hard way:
1: Scratch is very flexible about integers and floats (e.g., at one second, it looks like an integer, but one operation later, it's a float.)
2: Scratch does not provide any 'runtime errors' that can crash the project.
In other languages, similar "wait" methods take "milliseconds" in an integer, so it would have barfed out a "DivideByZeroException" or something. But Scratch was so robust against project-crashing behavior that it literally waited for f*<king "infinity seconds," effectively hanging that clone without warning or runtime errors. This masked my bug. It took way too long to debug that s#!+.
Don't blanket-mask any errors. -
Spent quite some time debugging an odd problem.
A null check failed to trigger correctly, and when checking in eclipse I saw the null value.
Much digging later I finally noticed that the value wasn't null, it was "null", but eclipse doesn't quote strings...
The problem was that somebody at one time decided to convert an Integer to String by prepending an empty string...
Integer val=getInt()
return "" + val; -
Math question time!
Okay so I had this idea and I'm looking for anyone who has a better grasp of math than me.
What if instead of searching for prime factors we searched for a number above p?
One with a certain special property. BEAR WITH ME. I know I make these posts a lot and I'm a bit of a shitposter, but I'm being genuine here.
Take this cherry picked number, 697 for example.
It's factors are 17, and 41. It's trivial but just for demonstration.
If we represented it's factors as a bit string, where each bit represents the index that factor occurs at in a list of primes, it looks like this
1000001000000
When converted back to an integer that number becomes 4160, which we will call f.
And if we do 4160/(2**n) until the result returns
a fractional component, then N in this case will be 7.
And 7 is the index of our lowest factor 17 (lets call it A, and our highest factor we'll call B) in our primes list.
So the problem is changed from finding a factorization of p, to finding an algorithm that allows you to convert p into f. Once you have f it's a matter of converting it to binary, looking up the indexes of all bits set to 1, and finding the values of those indexes in the list of primes.
I'm working on doing that and if anyone has any insights I'm all ears.9 -
!rant
finally after months and months of just planning and doing boring stuff a piece of code that was really just fun to code and plan for some days:
i just wrote my first "real" parser for a simple DSL. so much fun! i just really can recommend that to everybody.
i've use a parser combinator. the concept of this parser combinator ist to combine simple parsers (like when it starts with a number or a "-" and continues with numbers then its an integer etc) into a big one. i've written it in c# and used "Sprache" first and after some time i switch to "Superpower". a really great lib, but lacks a bit of documentation. anyway, i've your're interested in these things and want learn how your "daily code" gets parsed i would recommend that to you! :)
greetings to all fellow devRanters and happy coding / parsing! :)1 -
Mozilla you stinking kangaroo pouches!
When you set an object's CSS translation via JS like so:
obj.style.transform="translate(0px,0px)";
and then read it back, every browser including FF until 66 gives this, with additional space:
"translate(0px, 0px)"
However, bloody FF 67 returns "translate(0px)". Because it's always a good idea to just introduce external changes nilly-willy, right?
That screwed up my crappy string slicing because it relied on the presence of the comma. It was a quick and dirty solution, but with additional future proof if/else logic, it wouldn't even be quick anymore.
Besides, the whole string slicing looked like yo-yo code anyway so that I instead added shadow integer variables to the objects. That solution not only works, but is even faster.10 -
Not sure if other programming languages class a Boolean as an integer value buuuuuuut...
The amount of times I've seen people do code such as...
if(value == true) {
variable = "blah blah";
} else if(value == false) {
variable = "blah";
}
Instead of doing a simple 1D array and going...
variable = strings[value];
It drives me crazy, such a small thing that has no real benefit but... Ugh... Whyyyyyyy3 -
Me: so zero is an integer meaning it means the number value equivalent of nothing but it’s an integer and actually represents a number that exists. Null means the number doesn’t exist and is not an integer.
Idiot in the back seat: So ThEyR’re tHe SaMe5 -
Screw Java. Spent the last two days in this language and it's driving me to fits. Tried making a generic function. Java can't seem to easily handle generic typed arrays. Java threw a fit when I converted an array function to an integer function. Java has all this stupid boilerplate code that you put on every stupid thing.
Programming in Java is about as pleasurable as running face first into a brick wall.2 -
!rant, but funny
tl;dr I made something that was to protect me in case the customer doesn't pay, wanted to check if it's still there, messed up a little :D
>do an Android app project for almost 6 months
>issues with payment for it
> =.=
>firebase
>"Add new application"
>Remote Config
>add single integer variable
>back to app code
>if (integerFromFirebase != 0) navigateTo(new Fragment())
>mwahahahaha
>but they ended up paying me in the end
>huh...
>see another post on how to secure yourself if customer doesn't want to pay
>well, consider yours as more sophisticated
>hmm... wonder if they removed it
>firebaseconsole.exe
>change "enableJavaScript" (needed a legit name, so it can't be easily backtracked) to 1
>publish changes
>app still works fine
>mhhh... they removed it? really?
>can't fking believe it
>apkpure.com
>search for the app
>download apk
>unzip
>decompile dex file
>find the fragment
>can't find the code that navigates to blank fragment, but the config fetch is still there
>wtf
>look at the app
>restart it
>SHIT ITS NOT WORKING NOW XDDDDD
>changed the variable back to 0
>found out that the lambda in which I navigate to the blank fragment is in other .java file. New thing learned :v
>idk if I'm in trouble but I highly doubt it (console shows max 10 active users atm)
Was fun tho :v3 -
Something you really should not do:
*adds a new feature*
*build & run*
*See no difference*
Me: "Hmm.. Maybe 1 is not the best test integer, let me pick something higher..."
*build & run*
*INTEGER OVERFLOW EXCEPTION*
Feel free to share your "let me choose anothee test integer"-stories, which gone terribly wrong.1 -
(I'm not completely sure of what I'm saying here, so don't take this too seriously)
Settling on a language to write the api for ranterix is hard.
I'm finding a lot of things about elixir to be insanely good for a stable api.
But I'm having a lot of gripes with the most important elixir web framework, phoenix.
Take a look at this piece of code from the phoenix docs:
defmodule Hello.Repo.Migrations.CreateUsers do
use Ecto.Migration
def change do
create table(:users) do
add :name, :string
add :email, :string add :bio, :string
add :number_of_pets, :integer
timestamps()
end
end
end
Jesus christ, I hate this shit.
Wtf are create, add and timestamps. Add is somehow valid inside the create, how the fuck is that considered good code? What happens if you call timestamps twice? It's all obscure "trust me, it works" code.
It appears to be written by a child.
js may have a million problems. But one thing I like about CJS (require) or ESM (import) is that there's nothing unexplained. You know where the fuck most things come from.
You default export an eatShit() function on one file and import it from another, and what do you get?
The goddamn actual eatShit function.
require is a function the same way toString is a function and it returns whatever the fuck you had exported in the target file.
Meanwhile some dynamic langs are like "oh, I'll just export only some lang construct that i expect you to specify and put that shit in fucking global of the importing file".
Js is about the fucking freedom. It won't decide for you what things will files export, you can export whatever the fuck you want, strings, functions, classes, objects or even nothing at all, thanks to module.exports object or export statement.
And in js, you can spy on anything external, for example with (...args) => debugger; fnToSpyOn(...args)
You can spoof console.log this way to see what the fuck is calling it (note: monkey patching for debugging = GOOD, for actual programming = DOGSHIT)
To be fair though, that is possible because of being a dynamic lang and elixir is kind of a hybrid typed lang, fair enough.
But here's where i drop the shit.
Phoenix takes it one step further by following the braindead ruby style of code and pretty DSLs.
I fucking hate DSLs, I fucking hate abstraction addiction.
Get this, we're not writing fucking poetry here. We're writing programs for machines for them to execute.
Machines are not humans with emotions or creativity, nor feel.
We need some level of abstraction to save time understanding source code, sure.
But there has to be a balance. Languages can be ergonomic for humans, but they also need to be ergonomic for algorithms and machines.
Some of the people that write "beautiful" "zen" code are the folks that think that everyone who doesn't push the pretty code agenda is a code elitist that doesn't want "normal" people to get into programming.
Programming is hard, man, there's no fucking way around it.
Sometimes operating system or even hardware details bleed into code.
DSLs are one easy way to make code really really easy to understand, but also make it really fucking hard to debug or to lose "programming meaning".7 -
WHY THE ACTUAL FUCK CAN'T KENDO UI PRODUCE NORMAL FUCKING HTML AND PREDICTABLE GODDAMN BEHAVIOR I CAN EASILY WRITE GODDAMNED E2E TESTS FOR.
Shouldn't take me a fucking week to figure out how to get a fucking Kendo Integer Textbox to goddamned work in Cypress.
Fuck Kendo UI2 -
Was just fucking around with MyBB in order to figure out how it works on the control panel - whatever, right? Install a crap ton of plugins, and quite a lot of them wouldn't install due to an SQL statement being wrong. I check them, and either:
- the plugin ID is specified (it's auto-increment, it really shouldn't be specified at all)
- the database expected an integer and instead got a word
like for fucks sake, it's either 1 or 0 for being default, yet a lot of developers PUT YES OR NO?? HOW IS THAT EVEN REMOTELY AN INTEGER WHAT THE FUCK
So that was my past hour, running through plugin files, finding SQL statements and altering them. Safe to say that for what I got out of the plugins, it really wasn't worth it. -
It should be possible to prove the collatz conjecture by mapping the unit digit transitions between numbers, namely into a finite state machine. From there we could use predicates and quanitifiers to prove, by process of exclusion, that for any given combination of 10s digit and 1s digit, no number can transition to anything but whats specified in the state machine assuming that number equals x in x3+1 or x/2
Ipso facto, a series of equations proving by process of elimination, that state machines transitions are the only allowable ones, would prove the collatz conjecture by proving the fsm is a valid representation for any given integer N.
I'm actually working on it now but I don't know enough about modular arithmetic and predicate logic to write a proof. I just have the state diagrams on some dot matrix paper at the moment.
If anyone wants to beat me to it, feel free.
So for example any number ending in 13, will, after x3+1, end in 40.
Any number ending in 40 will end in 20. Any number ending in 20 will end in 10, which will end in 5 as the unit digit.
It's easier to prove in the single digit case, and the finite state machine for that is already written, at least on paper.
I'll post pictures when I get a chance.7 -
Not gonna lie, been chipping away at this for almost an hour and I can't figure out how to solve it, let alone elegantly:
https://leetcode.com/problems/...37 -
I once used try/catch the other way around. I tried to convert a string to an integer, and if it failed, I new that the string weren't a number (success)
-
Argument exception message convention: is it better to specify what is allowed or what is not allowed? Eg: "value must be a positive integer" or "value can not be negative"?2
-
TypeScript types are fun. Problem is: the check is compile-time only.
I just wasted an hour not understanding that an integer passed from command line was actually getting transmitted as a string. The library, where that value landed as parameter, happily ignored the non-matching type and worked as if the value has not been set at all!
Dear library maintainer, please enforce your parameter types! Throw an error right into my face saying I shall not pass anything but an integer! Don't just continue to work to produce false output correctly. Thank you!
Dear TypeScript, I really want type checks on runtime.
Dear JavaScript: Why did you ever think loose types were a good idea? (And I say that as a PHP developer as well.)2 -
When you think everything is fine and you can enjoy your holiday, but then your boss opens a ticket that customers lose money someone buys their product.
Fuck payment gateways for sending a formatted string instead of a unified integer -
The strcmp(3) manual page takes me closer to god: "strcmp() function compares the two strings s1 and s2. It returns an integer less than, equal to, or greater than zero if s1 is found, respectively, to be less than, to match, or be greater than s2."
-
The bug: Some string values for an identifier property in the data objects are being sent from our frontend prefixed with a '0'. Sometimes. When it happens, it usually gets stripped away again by the time it's passed to our backend. But not always.
This 0 is never explicitly set anywhere. I even searched for a few variants of " = 0" in both the frontend and backend projects without receiving any results. You might already be suspecting where this is going.
So it turns out.
The data object which holds this value is being initialized in the aspnet (don't ask) backend and passed to the frontend, which then hydrates it. This value is always an integer number, albeit incidentally so which is why string is used as the actual type. When this object is initialized, it's hardcoded with an anonymous type where this property is set as int because I guess someone figured "it's always an int though". Being a typed language, primitive scalars can't be null objects which means the property's value becomes the concrete int 0.
Okay weird. I can think of better ways of doing this but let's just set it to string as I can't start overhauling things right now. Let's just go find where this value is somehow concatenated into the incoming parameter.
You see, this happens because at the point where the frontend sets this value, it may be an int or string depending on where it came from, and I guess someone figured that in order to cast it to string you just go prop += arg seeing as the prop is empty string and all. Because explicitly casting it or - as much as I get a rash whenever I see it - going prop = "" + arg would be too verbose and unoriginal.
Bonus round: How come the 0 only sometimes made it all the way to our backend? The thing is that this bug has been fixed before. The fix is that because this string is "always" an int, you can parse it to int before passing it to the backend in case it has leading zeroes. This path is only taken in certain views because someone forgot to copypaste their fix into all the places this is repeated.
Sometimes you find a bug and you are just somehow more grumpy after fixing it.1 -
This is how to find the base needed for any integer value p, where p>=5, such that the logarithm always equals e in python.
log(p, e**(log(p, e**e))) # equals e
Doesn't do anything besides that but this is another identity isn't?24 -
Top 12 C# Programming Tips & Tricks
Programming can be described as the process which leads a computing problem from its original formulation, to an executable computer program. This process involves activities such as developing understanding, analysis, generating algorithms, verification of essentials of algorithms - including their accuracy and resources utilization - and coding of algorithms in the proposed programming language. The source code can be written in one or more programming languages. The purpose of programming is to find a series of instructions that can automate solving of specific problems, or performing a particular task. Programming needs competence in various subjects including formal logic, understanding the application, and specialized algorithms.
1. Write Unit Test for Non-Public Methods
Many developers do not write unit test methods for non-public assemblies. This is because they are invisible to the test project. C# enables one to enhance visibility between the assembly internals and other assemblies. The trick is to include //Make the internals visible to the test assembly [assembly: InternalsVisibleTo("MyTestAssembly")] in the AssemblyInfo.cs file.
2. Tuples
Many developers build a POCO class in order to return multiple values from a method. Tuples are initiated in .NET Framework 4.0.
3. Do not bother with Temporary Collections, Use Yield instead
A temporary list that holds salvaged and returned items may be created when developers want to pick items from a collection.
In order to prevent the temporary collection from being used, developers can use yield. Yield gives out results according to the result set enumeration.
Developers also have the option of using LINQ.
4. Making a retirement announcement
Developers who own re-distributable components and probably want to detract a method in the near future, can embellish it with the outdated feature to connect it with the clients
[Obsolete("This method will be deprecated soon. You could use XYZ alternatively.")]
Upon compilation, a client gets a warning upon with the message. To fail a client build that is using the detracted method, pass the additional Boolean parameter as True.
[Obsolete("This method is deprecated. You could use XYZ alternatively.", true)]
5. Deferred Execution While Writing LINQ Queries
When a LINQ query is written in .NET, it can only perform the query when the LINQ result is approached. The occurrence of LINQ is known as deferred execution. Developers should understand that in every result set approach, the query gets executed over and over. In order to prevent a repetition of the execution, change the LINQ result to List after execution. Below is an example
public void MyComponentLegacyMethod(List<int> masterCollection)
6. Explicit keyword conversions for business entities
Utilize the explicit keyword to describe the alteration of one business entity to another. The alteration method is conjured once the alteration is applied in code
7. Absorbing the Exact Stack Trace
In the catch block of a C# program, if an exception is thrown as shown below and probably a fault has occurred in the method ConnectDatabase, the thrown exception stack trace only indicates the fault has happened in the method RunDataOperation
8. Enum Flags Attribute
Using flags attribute to decorate the enum in C# enables it as bit fields. This enables developers to collect the enum values. One can use the following C# code.
he output for this code will be “BlackMamba, CottonMouth, Wiper”. When the flags attribute is removed, the output will remain 14.
9. Implementing the Base Type for a Generic Type
When developers want to enforce the generic type provided in a generic class such that it will be able to inherit from a particular interface
10. Using Property as IEnumerable doesn’t make it Read-only
When an IEnumerable property gets exposed in a created class
This code modifies the list and gives it a new name. In order to avoid this, add AsReadOnly as opposed to AsEnumerable.
11. Data Type Conversion
More often than not, developers have to alter data types for different reasons. For example, converting a set value decimal variable to an int or Integer
Source: https://freelancer.com/community/...2 -
Using float in a simple structure for a network project running on Contiki. I was trying to print this structure for debug purpose and I noticed that all my float don't show up 😦
After some Googling, I ended-up on a mailing list saying that float and double are not useable in Contiki 😒
I get that double is too large (8bytes) but seriously a float is just 4bytes!
Well for now our floating numbers are just integer 😌 -
My coworkers get annoyed at my insistence that we stress test our inputs. Today, whilst doing just that, I tried to put a big ass integer into an environment variable in Postman. It’s been frozen for 10 minutes. 🤣🤣 THIS is why we test our inputs!!!! 😫2
-
I really thought i would never run into integer overflow issues, but damn, not being able to set a date as 100 years into the future for comparison is pretty shite. Fuck this bug.2
-
Its everyones favorite time again. Wisecrack's 8th grade hoborants about mathematics.
Lets start with the example
a=89
b=223
p=a*b=19847
If
(1/(5/p))/b = 17.8
and naturally
p/5 =3969.4
3969.4/b = 17.8
What I find interesting is that...
p/17.8 = 1115.0
..for any product and factors (given two factors), the result will always be an integer.
Why is this?
You can see that
t= 1115.0*b = 248645.0
And if
17.8*(p/a) = 3969.4
Then
17.8*(t/p) = 223.0 (our factor, b)
a*(t/p)
1115.0
p/1115
17.8
also a*(t/p) = 1115.0
I could be once again misunderstanding but
what it looks like is that theres some real number that always transforms p into an integer on the ring of integers (Z) representing multiples of the factors of p.
Now notice
b/17.8 = 12.52808988764045
We can also get that number like so..
t/p = 12.52808988764045
I think (though I could be mistaken) is that the reason is because t is b*1115 and 12.52808988764045 is the ratio between b and 17.8 as well as the ratio between
p and 1115.
And if we do
t/√p = 1764.9495488858483
1764.9495488858483^2 = 3115046.9101123596
also incidentally
3115046.9101123596/t =12.52808988764045
3115046.9101123596/12.52808988764045 =
t (this is obvious but I want to point it out anyway), or 248645.0
and
1115/b = 5.0
248645.0/5 = 49729.0
and
√49729.0 = b
Why is this last part true, that √(t/5) = b?11 -
Anyone can become a designer, some just face a longer journey than others.
Like people who set a monospace font and then specify section margins that aren't an integer number of characters.5 -
Resource not found exception occurred when i tried to set an integer text inside a TextView in android.
Spent an hour trying to comb through my entire android app's layout resources looking at all the declared ids and cross checking then.
Didn't work. Tried googling and stumbled upon a stray human who had encountered a similar issue.
Turns out if you print an integer inside the setText, it will not consider it a normal printable value, it will think that's it's a resource id and try to use it.
Fucking misleading exception. FML ANDROID5 -
Duuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuck off you bloody infamous basterds flattening their fat asses at Microsoft.
I wasted half of my dev day to configure my wcf rest-api to return an enumeration property as string instead of enum index as integer.
There is actually no out-of-the-box attribute option to trigger the unholy built-in json serializer to shit out the currently set enum value as a pile of characters clenched together into a string.
I could vomit of pure happiness.
And yes.
I know about that StringEnumConverter that can be used in the JsonConvert Attribute.
Problem is, that this shit isn't triggered, no matter what I do, since the package from Newtonsoft isn't used by my wcf service as a standard serializer.
And there is no simple and stable way to replace the standard json serializer.
Christ, almighty!
:/ -
in vb.net i can declare a void function:
Declare Function some_func& Lib "some_lib.dll" ()
then try to assign its return value to a variable:
some_return = some_func()
and get no errors during compilation, not even a warning
but in runtime it produces integer arithmetic overflow exception
in what way it is not even a warning?4 -
!rant
So I decided to collab with a website's maker (who i wont name here) to create something like r/place. (not an exact copy.)
I decided to start by learning their API, and customizing the server later.
I asked the guy for some help, and HOLY SHIT.
Let's start off by this: I had to request a chunk. The response data was in binary. 4 bits meant 1 pixel, so right away, I had to deal with that in my code.
No problem, just decided to use C# instead of JS. (see https://www.devrant.io/rants/547013)
I was finally done after a couple of mental breakdowns, and decided to implement updates.
I needed to use webhooks, and that was completely fine. But when I got "C1FFFF0000CA06" as response (in hex), I seeked some help.
C1 is the operation type: it means that a pixel was updated.
FFFF and 0000 were the chunk coordinates. But remeber: it's a signed integer. Guess what, I had to use Two's compliment. I decided to be a lazy asshole and only check for "00000000" because I was only displaying chunk 0,0.
CA06: This is a weird one. It's 2 bytes, and CA0 contains the X and Y coordinate of the pixel (in the chunk), and 6 contains the new color of the pixel.
I was sent the following code to work with 0xCA06:
color = 0xF & buffer
x = buffer >> 10
y = (buffer >> 4) & 0x3F
So I tried to do it, and it didn't work. I'm not blaming the developer of the server (original dev is reddit) because maybe I screwed up, but which guy will have a night of frustration and debugging?
Me.
P.S.: Dev, if you see this, I'm sorry. This API is way too complicated. I know we need to save bandwith and stuff, but damn.1 -
Just to use de 5000 characters :v.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut non velit vel odio sodales hendrerit non a urna. Nunc tortor orci, fermentum quis blandit eu, auctor in arcu. Vivamus mollis auctor sem sit amet egestas. Etiam fermentum purus sed est venenatis fringilla. Maecenas imperdiet pharetra volutpat. Suspendisse vitae maximus purus, id scelerisque magna. Nulla maximus, nisl nec pharetra consectetur, dui nunc tempor dui, quis porta magna arcu at justo. Integer maximus euismod magna, a sodales leo interdum vel. Phasellus malesuada eros volutpat eros blandit dictum. Maecenas velit tortor, rhoncus id orci vitae, venenatis condimentum elit. Nulla ante mi, viverra sit amet tempus vel, pharetra eu ex. Maecenas blandit, lorem non tincidunt facilisis, ligula lectus scelerisque tellus, ac facilisis est diam nec turpis. Vivamus nec ante ut justo dignissim rutrum. Curabitur ut odio et nisl convallis pellentesque eu ut lorem.
Pellentesque imperdiet egestas cursus. Mauris at dui facilisis, feugiat elit in, bibendum odio. Vestibulum magna purus, aliquam quis tincidunt et, accumsan vel est. Morbi commodo viverra aliquet. Sed dignissim vehicula nulla id sodales. Curabitur lobortis cursus nisl at congue. Ut bibendum leo nisi, quis consequat velit pharetra vitae. Nam laoreet, odio ut tincidunt pulvinar, sapien ex consequat metus, id venenatis massa lorem ultrices orci. Mauris ac metus mauris.
In ac feugiat leo, ac blandit arcu. Donec sit amet dolor non nunc pharetra vulputate. Curabitur in velit ac odio egestas semper. Ut mattis ex sodales scelerisque venenatis. Pellentesque dolor lorem, eleifend vitae nisl eu, ultrices pellentesque justo. In vel vulputate lectus. Sed hendrerit sem vel blandit dapibus. Suspendisse ut eleifend lacus, a laoreet turpis. Vivamus eu ultricies lectus. Vestibulum imperdiet magna semper mi cursus facilisis. Fusce et interdum mauris, vitae tincidunt sapien. Curabitur non congue dolor, a varius dui. Maecenas nisl diam, lobortis et odio sit amet, ullamcorper euismod turpis.
Nullam vitae tempus eros. Sed varius sit amet sem faucibus euismod. Curabitur congue nulla lectus, sed aliquam mauris ultricies sed. Maecenas non felis ut orci commodo commodo. Mauris pharetra, tellus nec fringilla molestie, erat ligula tempus urna, ut faucibus elit ante in dolor. Nullam eu est fermentum, malesuada eros sed, rhoncus libero. Donec dignissim sapien quis aliquet auctor. Pellentesque a laoreet lorem. Suspendisse in feugiat odio. Maecenas venenatis auctor pretium. Maecenas et dolor eu leo faucibus auctor vel sed ligula. Curabitur lacinia ac leo eget posuere. Aliquam erat volutpat. Ut ultricies justo id tellus vulputate euismod. Phasellus sagittis ipsum ac odio rhoncus lobortis. Nullam vestibulum mauris sit amet augue euismod, viverra hendrerit sem convallis.
Integer tellus orci, rhoncus vel dignissim non, convallis at urna. Nam eu neque vel leo luctus varius eu in augue. Nunc consectetur cursus est nec bibendum. Integer erat tellus, feugiat ac aliquam in, volutpat semper tellus. Pellentesque in auctor magna. Donec feugiat magna in lacus ultricies fermentum. Phasellus bibendum, dolor ut aliquam feugiat, elit augue tincidunt justo, nec consequat tellus diam vitae risus.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla convallis et enim vel congue. Suspendisse luctus sapien ac maximus dapibus.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut non velit vel odio sodales hendrerit non a urna. Nunc tortor orci, fermentum quis blandit eu, auctor in arcu. Vivamus mollis auctor sem sit amet egestas. Etiam fermentum purus sed est venenatis fringilla. Maecenas imperdiet pharetra volutpat. Suspendisse vitae maximus purus, id scelerisque magna. Nulla maximus, nisl nec pharetra consectetur, dui nunc tempor dui, quis porta magna arcu at justo. Integer maximus euismod magna, a sodales leo interdum vel. Phasellus malesuada eros volutpat eros blandit dictum. Maecenas velit tortor, rhoncus id orci vitae, venenatis condimentum elit. Nulla ante mi, viverra sit amet tempus vel, pharetra eu ex. Maecenas blandit, lorem non tincidunt facilisis, ligula lectus scelerisque tellus, ac facilisis est diam nec turpis. Vivamus nec ante ut justo dignissim rutrum. Curabitur ut odio et nisl convallis pellentesque eu ut lorem.
Pellentesque imperdiet egestas cursus. Mauris at dui facilisis, feugiat elit in, bibendum odio. Vestibulum magna purus, aliquam quis tincidunt et, accumsan vel est. Morbi commodo viverra aliquet. Sed dignissim vehicula nulla id sodales. Curabitur lobortis cursus nisl at congue. Ut bibendum leo nisi, quis consequat velit pharetra vitae. Nam laoreet, odio ut tincidunt pulvinar, sapien ex consequat metus, id venenatis massa lorem ultrices orci. Mauris ac metus mauris.
In ac feugiat leo, ac blandit arcu. Donec sit amet dolor non nunc pharetra vulputate. Curabitur in velit ac odio egestas semper. Ut mattis ex sodales scelerisque venenatis. -
Unix Epoch should have started in 2000, not 1970.
Those selfish people in the 1970 who made up the Unix epoch had little regard for the future. Thanks to their selfishness, the Unix date range is 1902 to 2038 with a 2³² integer. Honestly, who needs dates from 1902 to 1970 these days? Or even to 1990? Perhaps some ancient CD-ROMs have 1990s file name dates, but after that?
Now we have an impending year 2038 problem that could have been delayed by 30 years.
If it started on 2000-01-01, Unix epoch would be the number of seconds past since the century and millennium.13 -
In my early programming days I wrote a C++ program to store marks of n no of students but didn't got the output I checked for 3 hours then found that I was storing the data in another integer value and not in the array.
-
Do you know a hash-function (doesn't need to be cryptographic) that I can implement, without fixed size integer-types?
I already searched for a while, but couldn't find an actual fit.
It's for implementing a hasher, used by a hashmap.5 -
*through gritted teeth* BLUEJ WHATS UR FKIN PRBLM. DON'T LET ME MAKE SOMETHING THAT WORKS IN YOUR OWN COMMAND LINE BUT NOT MY TERMINAL.
I just want to read a single integer from System.in on different occasions during the same program. You even let me close System.in without a warning and try to reopen it later, which I'VE LEARNED ISN'T SUPPOSED TO WORK. EVER.
BlueJ you have beautiful bracket highlighting but that's it, I'm leaving.
#edit
What the shit javac let's me compile this without warnings from command line?2 -
No matter how hard you try to stick magnet with a wood it just won’t work out in any way.
i hope its possible to change the wood into metal just like as easy as type-casting an integer into string, but it just won’t happen anyway~~2 -
Maybe it's a dumb question, I don't know…
Why "Math.Truncate()" (trunc() in C++) returns a double?
Its only purpose is to return the integer part of a double, which is a fucking integer…
Same for floor() and ceil().
My point is that you can put an int in a double without any problem (so they could have return an int), not the other way around, so you have to convert it if you need it in an int.3 -
Why the hell does mysql not have boolean fields? why do I have to use a whole integer for a bit? REEEEEEEEEEEEE10
-
New to AWS, is my best option for having a integer value (maximum number of items to process) that I can override for a lambda step function
to read a value from an S3 bucket where I can overwrite the value if I want to change it. This seems silly and I feel silly as I expect my situation should be simple and not novel at all.
For some reason I expected I could use an environment variable, but didn't see an option to overwrite it in the web GUI https://docs.aws.amazon.com/lambda/...2 -
Oh yeah ... Java is cool in an utterly sick way even that i can't seem to find a non-retarded built-in stack data structure
Call me a racist, but java.util.Stack has a removeIf() method in case you want to remove odd numbers:
import java.util.Stack;
public class App {
public static void main(String[] args) {
int arr[] = { 2, 4, 7, 11, 13, 16, 19 };
Stack<Integer> s = new Stack<Integer>();
for (int i = 0; i < arr.length; i++) {
s.push(arr[i]);
}
s.removeIf((n) -> (n % 2 == 1));
System.out.println(s); // [2, 4, 16]
}
}
Stop using java.util.Stack they said, a legacy class they said, instead i should use java.util.ArrayDeque, but frankly i can still keep up being racist (in a reversed manner):
import java.util.ArrayDeque;
import java.util.Deque;
public class App {
public static void main(String[] args) {
int arr[] = { 2, 4, 7, 11, 13, 16, 19 };
Deque<Integer> s = new ArrayDeque<Integer>();
for (int i = 0; i < arr.length; i++) {
s.push(arr[i]);
}
s.removeIf((n) -> (n % 2 == 1));
System.out.println(s); // [16, 4, 2]
}
}
The fact that you can iterate through java.util.Stack is amazing, but the ability to insert element in a specified index:
import java.util.Stack;
public class App {
public static void main(String[] args) {
int arr[] = { 2, 4, 7, 11, 13, 16, 19 };
Stack<Integer> s = new Stack<Integer>();
for (int i = 0; i < arr.length; i++) {
s.push(arr[i]);
}
s.add(2, 218);
System.out.println(s); // [2, 4, 218, 7, 11, 13, 16, 19]
}
}
That's what happens when you inherit java.util.Vector, which is only done a BRAIN OVEN person, a very brain oven even that it will revert to retarded
If you thought about using this type of bullshit in Java get yourself prepared to beat the disk for hours when you accidentally call java.util.Stack<T>.add(int index, T element) instead of java.util.Stack<T>.push(T element), you will probably end up breaking the disk or your hand, but not solving the issue
WHY THE F*** CAN'T WE HAVE A WORKING NORMAL STACK ?5 -
Hi everyone, I have such a task: “Given an integer square matrix. Determine the minimum among the sums of diagonal elements parallel to the main diagonal of the matrix.” I have a code but I have problems compiling a flowchart for it, can you help me with compiling a flowchart or give tips? thanks in advance!
Thats my code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define N_MIN -3
#define N_MAX 5
int main(int argc, char *argv[]){
int s,i,j,k,l,s1,t2,t1;
int a[5][5];
srand(time(NULL));
for(i=0;i<5;i++){
for(j=0;j<5;j++){
a[i][j]=rand()%(N_MAX-N_MIN+1)+N_MIN;
}
}
for(i=0;i<5;i++){
for(j=0;j<5;j++){
printf("%3d ",a[i][j]);
}
printf("\n");
}
k=0;
s=0;
l=0;
for (i=0; i<5; i++){
for (j=0; j<5; j++){
if (a[i][j]>=0){
if(a[i][j]%2==0)
l+=a[i][j];
k++;
}
}
if (k==5){
l=l;
}
else {
l=0;
}
s=s+l;
k=0;
}
s1=a[0][5-1];
for(i=1; i<5; i++){
t1=t2=0;
for(j=0; j<5-i; j++){
t1+=a[i+j][j];
t2+=a[j][i+j];
}
if(t1<s1) s1=t1;
if(t2<s1) s1=t2;
}
printf("vivod %d %d\n", s,s1);
return 0;
}2 -
When the SCA checker is so bad that it recommends you to initialize an unsigned integer with the nullptr literal...