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 - "collisions"
-
I asked my teammates if it would be ok if I made multithreading code for the collisions of our game engine and they just sent me this, I'm going to try anyway. Yolo.2
-
This facts are killing me
"During his own Google interview, Jeff Dean was asked the implications if P=NP were true. He said, "P = 0 or N = 1." Then, before the interviewer had even finished laughing, Jeff examined Google’s public certificate and wrote the private key on the whiteboard."
"Compilers don't warn Jeff Dean. Jeff Dean warns compilers."
"gcc -O4 emails your code to Jeff Dean for a rewrite."
"When Jeff Dean sends an ethernet frame there are no collisions because the competing frames retreat back up into the buffer memory on their source nic."
"When Jeff Dean has an ergonomic evaluation, it is for the protection of his keyboard."
"When Jeff Dean designs software, he first codes the binary and then writes the source as documentation."
"When Jeff has trouble sleeping, he Mapreduces sheep."
"When Jeff Dean listens to mp3s, he just cats them to /dev/dsp and does the decoding in his head."
"Google search went down for a few hours in 2002, and Jeff Dean started handling queries by hand. Search Quality doubled."
"One day Jeff Dean grabbed his Etch-a-Sketch instead of his laptop on his way out the door. On his way back home to get his real laptop, he programmed the Etch-a-Sketch to play Tetris."
"Jeff Dean once shifted a bit so hard, it ended up on another computer. "6 -
!dev
It's raining. I love it.
It's foggy. I love it.
But I live in a desert and nobody here seems to know how to handle the rain, let alone the fog. (It isn't hard, people!) Last night during my ~30 min drive home from work, five separate accidents/collisions happened just a little ways behind me because it was raining. Now it's foggy, too.
I have to go to work.
I'm scared.12 -
ARGH. I wrote a long rant containing a bunch of gems from the codebase at @work, and lost it.
I'll summarize the few I remember.
First, the cliche:
if (x == true) { return true; } else { return false; };
Seriously written (more than once) by the "legendary" devs themselves.
Then, lots of typos in constants (and methods, and comments, and ...) like:
SMD_AGENT_SHCEDULE_XYZ = '5-year-old-typo'
and gems like:
def hot_garbage
magic = [nil, '']
magic = [0, nil] if something_something
success = other_method_that_returns_nothing(magic)
if success == true
return true # signal success
end
end
^ That one is from our glorious self-proclaimed leader / "engineering director" / the junior dev thundercunt on a power trip. Good stuff.
Next up are a few of my personal favorites:
Report.run_every 4.hours # Every 6 hours
Daemon.run_at_hour 6 # Daily at 8am
LANG_ENGLISH = :en
LANG_SPANISH = :sp # because fuck standards, right?
And for design decisions...
The code was supposed to support multiple currencies, but just disregards them and sets a hardcoded 'usd' instead -- and the system stores that string on literally hundreds of millions of records, often multiple times too (e.g. for payment, display fees, etc). and! AND! IT'S ALWAYS A FUCKING VARCHAR(255)! So a single payment record uses 768 bytes to store 'usd' 'usd' 'usd'
I'd mention the design decisions that led to the 35 second minimum pay API response time (often 55 sec), but i don't remember the details well enough.
Also:
The senior devs can get pretty much anything through code review. So can the dev accountants. and ... well, pretty much everyone else. Seriously, i have absolutely no idea how all of this shit managed to get published.
But speaking of code reviews: Some security holes are allowed through because (and i quote) "they already exist elsewhere in the codebase." You can't make this up.
Oh, and another!
In a feature that merges two user objects and all their data, there's a method to generate a unique ID. It concatenates 12 random numbers (one at a time, ofc) then checks the database to see if that id already exists. It tries this 20 times, and uses the first unique one... or falls through and uses its last attempt. This ofc leads to collisions, and those collisions are messy and require a db rollback to fix. gg. This was written by the "legendary" dev himself, replete with his signature single-letter variable names. I brought it up and he laughed it off, saying the collisions have been rare enough it doesn't really matter so he won't fix it.
Yep, it's garbage all the way down.16 -
"Quality CSS" is much a fucking misnomer. As someone whose been writing this shit at scale for 15+ years I can tell you all CSS code is garbage. The only thing you should do is make sure you don't have name collisions. Classes/components are self contained. And use variables when possible. DRY makes sense usually, but if you're dogmatic about it you shoot yourself in the foot.9
-
I am much too tired to go into details, probably because I left the office at 11:15pm, but I finally finished a feature. It doesn't even sound like a particularly large or complicated feature. It sounds like a simple, 1-2 day feature until you look at it closely.
It took me an entire fucking week. and all the while I was coaching a junior dev who had just picked up Rails and was building something very similar.
It's the model, controller, and UI for creating a parent object along with 0-n child objects, with default children suggestions, a fancy ui including the ability to dynamically add/remove children via buttons. and have the entire happy family save nicely and atomically on the backend. Plus a detailed-but-simple listing for non-technicals including some absolutely nontrivial css acrobatics.
After getting about 90% of everything built and working and beautiful, I learned that Rails does quite a bit of this for you, through `accepts_nested_params_for :collection`. But that requires very specific form input namespacing, and building that out correctly is flipping difficult. It's not like I could find good examples anywhere, either. I looked for hours. I finally found a rails tutorial vide linked from a comment on a SO answer from five years ago, and mashed its oversimplified and dated examples with the newer documentation, and worked around the issues that of course arose from that disasterous paring.
like.
I needed to store a template of the child object markup somewhere, yeah? The video had me trying to store all of the markup in a `data-fields=" "` attrib. wth? I tried storing it as a string and injecting it into javascript, but that didn't work either. parsing errors! yay! good job, you two.
So I ended up storing the markup (rendered from a rails partial) in an html comment of all things, and pulling the markup out of the comment and gsubbing its IDs on document load. This has the annoying effect of preventing me from using html comments in that partial (not that i really use them anyway, but.)
Just.
Every step of the way on building this was another mountain climb.
* singular vs plural naming and routing, and named routes. and dealing with issues arising from existing incorrect pluralization.
* reverse polymorphic relation (child -> x parent)
* The testing suite is incompatible with the new rails6. There is no fix. None. I checked. Nope. Not happening.
* Rails6 randomly and constantly crashes and/or caches random things (including arbitrary code changes) in development mode (and only development mode) when working with multiple databases.
* nested form builders
* styling a fucking checkbox
* Making that checkbox (rather, its label and container div) into a sexy animated slider
* passing data and locals to and between partials
* misleading documentation
* building the partials to be self-contained and reusable
* coercing form builders into namespacing nested html inputs the way Rails expects
* input namespacing redux, now with nested form builders too!
* Figuring out how to generate markup for an empty child when I'm no longer rendering the children myself
* Figuring out where the fuck to put the blank child template markup so it's accessible, has the right namespacing, and is not submitted with everything else
* Figuring out how the fuck to read an html comment with JS
* nested strong params
* nested strong params
* nested fucking strong params
* caching parsed children's data on parent when the whole thing is bloody atomic.
* Converting datetimes from/to milliseconds on save/load
* CSS and bootstrap collisions
* CSS and bootstrap stupidity
* Reinventing the entire multi-child / nested params / atomic creating/updating/deleting feature on my own before discovering Rails can do that for you.
Just.
I am so glad it's working.
I don't even feel relieved. I just feel exhausted.
But it's done.
finally.
and it's done well. It's all self-contained and reusable, it's easy to read, has separate styling and reusable partials, etc. It's a two line copy/paste drop-in for any other model that needs it. Two lines and it just works, and even tells you if you screwed up.
I'm incredibly proud of everything that went into this.
But mostly I'm just incredibly tired.
Time for some well-deserved sleep.7 -
Well two days ago, i was in a sap codin g camp (ranted about that)
The challenge: moke a robot that avoid collisions and 6inds a black mm spot on tha floor
We marginally had enough time te implement sth but well i tried to do an algo.
10 mins before deadline i realized that it wouldnt work. So i took an old prototype (without algo) from the trash bin, fixed compilation errors and went to the competition without testing. Because we had to do a little explanation for the parents about arduinos, we all were shaky. A friend of mine even failed to remember his text xD
Asso, because of Fortuna wanting to beat us down, we were the last team driving in the arena. Everybody got pretty fast times. (with a random algo). At the end, we took our robot with the untestet thrash bin program.
It drove pretty well, avoided collisions and then it happened: it reached (only robot not to collide) the black spot in 1:09!!! 😁7 -
My first dev project was making a small 3D engine in GameMaker 7 when I was 14. I had been using gamemaker for two years then but I never got past the "platformer movement and collisions" and "top down movement and collisions"
It was the first thing I made myself without following a tutorial and spend quite a few afternoons at school to ask my Math teacher to explain things like sin cos and tan. Words I saw on the internet but did not understand.1 -
I mean... It's entirely possible that goingToCrashIntoEachOther is a variable that is set by some code constantly testing for upcoming collisions and dont() is a class for course correction.3
-
Core library was giving serious blow out of execution speed as data file size increased.
Traced it back to a GetHashCode implementation that was giving too many collisions for unequal objects, so when used as the key in a hash table it was causing the lookup to fall back to checking Equals (much slower).
Improved the GetHashCode implementation, and also precalculated it on construction (they were immutable objects), and run time went to warp speed! Was very happy with that.
Obviously put in a thread sleep to help manage expectations with the boss/clients going forwards. Can’t give those sort of gains away in one go. Sets a dangerous precedent.1 -
When you have to made a little game with javascript, and because it's your first game you made a beautiful maze with lot of wall.
Ahahah... i'm shit.
I forgot wall have collision.
I'm here now, with 40 different fuckin' walls and much if and else if conditions.
I hate me.
Yeah i know, I can just change my maze but no... I'm lazy. Cry against the collisions is better.
Have good day.9 -
i was helping a friend with their coding assignment - snake game.
we spent about 45 minutes of trying to figure out why the snake's self-collisions are not working.
then we realized that she's using two separate arrays/grids - one for the food, one for the snake itself.
she was checking both for food collisions and self-collisions on the food array.
it was very painful to realize it took me so embarassingly long to notice it.6 -
For my graduate level people(aka Masters degree students or holders)
How normal would you say that: giving dense ass lectures in NN with absolutely NO practical examples and just a fuckload of theory + 1 simulation project in Pytorch in which a robot is to detect collisions is?
is it normal? i mean I knew about Pytorch from a very shallow overview, but these assholes gave that project and expected it completed in a week with a fuckload of dense ass lectures and no practical exmaples.
I know school is supposed to be hard, that is not my gripe, but in yalls experience are teachers more descriptive and fun in other institutions? do I just have shit luck with teachers? I don't feel like wasting my money. If your experience was better then let me know, cuz I want education yes, but i want it better.4 -
v0.0005a (alpha)
- class support added to lua thanks to yonaba.
- rkUIs class created
- new panel class
- added drawing code for panel
- fixed bug where some sides of the UI's border were failing to drawing (line rendering quark)
v0.0014a (alpha) 11.30.2023 (~2 hours)
- successfully retrieving basic data from save folder, load text into lua from files
- added 'props' property to Entity class
- added a props table to control what gets serialized and what doesn't
- added a save() base method for instances (has to be overridden to be useful beyond the basics)
- moved the lume.serialize() call into the :save() method on the base entity class itself
- serialized and successfully saved an entities property table.
- fixed deserializion bugs involving wrong indexes (savedata[1] not savedata[2])
- moved deserialization from temp code, into line loading loop itself (assuming each item is on one line)
- deser'd test data, and init()'d new player Entity using the freshly-loaded data, and displayed the entity sprite
All in all not a bad session. Understanding filing handling and how to interact with the directory system was the biggest hurdle I was worried about for building my tools.
Next steps will be defining some basic UI elements (with overridable draw code), and then loading and initializing the UI from lua or json.
New projects can be set as subfolders folders in appdata, using 'Setidentity("appname/projectname") to keep things clean.
I'm not even dreading writing basic syntax highlighting!
Idea is to dogfood the whole process. UI is in-engine rendered just like you might see with godot, unity, or gamemaker, that way I have maximum flexibility to style it the way I want. I'm familiar enough with constructing from polygons, on top of stenciling, on top of nine-slicing, on top of existing tweening and special effects, that I can achieve exactly what I want.
Idea is to build a really well managed asset pipeline. Stencyl, as 'crappy' as it appeared, and 'for education' was a master class in how to do things the correct way, it was just horribly bloated while doing it.
Logical tilesets that you import, can rearrange through drag-n-drop, assign custom tile shapes to, physics materials, collisions groups, name, add tag data to, all in one editor? Yes please.
Every other 2D editor is basic-bitch, has you importing images, and at most generates different scales and does the slicing for you.
Code editor? Everything behavior was in a component, with custom fields. All your code goes into a list of events, which you can toggle on and off with a proper toggle button, so you can explicitly experiment, instead of commenting shit out (yes git is better, but we're talking solo amateurs here, they're not gonna be using git out the gate unless they already know what they're doing).
Components all have an image assignable to identify them, along with a description field, and they're arranged in a 2d grid for easy browsing, copying, modifying.
The physics shape editor, the animation editor, the map editor, all of it was so bare bones and yet had things others didn't.
I want that, except without the historic ties to flash, without the overhead of java, and with sexier fucking in-engine rendering of the UI and support for modding and in-engine custom tools.
Not really doing it for anyone except myself, and doubt I'll get very far, but since I dropped looking for easy solutions, I've just been powering through all the areas I don't understand and doing the work.
I rediscovered my love of programming after 3-4 years of learning to hate it, and things are looking up.2 -
Turns out MD5 collisions are hard to iterate through. Max combinations of bytes in a 100,000 byte file is (as calculated by Python:)
413502433742660544726868172195767861427618658445205343992065892230166930397146583182005172845204489533665188550385797247605830027690030912310887164176364954875069038057666590769687571726193148717652368418744731692453987107907857683242360451588862381980796040785447771748097295949966591258383632274557701138287596503423452399232536933583768184114874795654760979888748015241761933209111943015224044366005903481415990946152075730054176507652408593662525624208010788644701872255643844493769499469673271219048262961476704374776988472648537308308011235412742501908803475102336862442166237905095612511941476299337727729022024118389323121828087330601048095646801171259973845170877342411799823272475101891307296782554819753985119403152255745494789644397312746702721825997945525576
i'm getting 1227.97 iterations a second. (Note: no, not using C, i don't know enough to do it in C. If someone wants to take my script, redo it in C, and send it to me for comparison, that'd be great.)12 -
You know how people want to avoid collisions with a hash map?? Well a buddy and I went to a hackathon about 2 years ago, and the idea we had was kinda cool, but to get a prototype working, we decided to defy the logic of a hash table and purposefully cause collisions with a hash map. I took a look at the project and it is soooo poorly implemented.
-
How do you approach generating "random" unique numbers/strings ? Exactly, when you have to be sure the generated stuff is unique overtime? Eg. as few collisions in future as possible.
Now I don't mean UUIDs but when there is a functionality that needs some length defined, symbol specific and definitely unique data, every time it does it's stuff.
TLDR STORY: Generating 8 digits long numbers so they are (deterministically - wink wink) unique is hard but Format Preserving Encryption saves the day. (for me)
FULL STORY:
I had to deal with both strings and codes today.
One was to generate shortlink word for url, luckily found a library that does exactly this. (Hashids)
BUT generating 8 digits long, somewhat random number was harder then I thought, found out on SO something like "sha256(seed) => bytes => ascii/numbers mangling" but that had a lot of collisions because of how the hash got mangled to actually output numbers and also to fit the length.
After some hours I stumbled upon Format Preserving encryption (pyffx) and man it did what I wanted and it had max 2 collisions in 100k values. Still the solution with this feels hacky af. (encrypting straddled unix timestamp with lots of decimals)6 -
Rant to myself: Don't try to be too smart, you dipshit!
3 weeks ago I packed 2 small changes in one commit, because I was sure (and obviuosly lazy) that no one will ever need these special changes separate.
Guess what happened today? Right, I had to make a change on an old version and needed the one half of this commit.
Cherry-picking ended up in changes I don't need and furthermore some nice collisions.
Thank you very much, past me, for saving 2 minutes 3 weeks ago, which now wastes half an hour. -
Anyone who would like to help me with this problem? (Collisions)
https://stackoverflow.com/questions...1 -
Did someone already thought about how color highlight can be better? It's been 4-5 years now that I'm coding on a virtual console that run on iPad with a monochrome code editor. Despite the fact that's remind me the old days when I was 8 years old, that doesn't stop me for coding with it.
I mean, is it really important to know that strings are red and numbers are yellow? How does that help me? They are both literal and behave to the user-content categories.
I was talking with my friend, and he says he likes to know if something is a keyword or an identifier. In C++, a lot of common keywords to define stuff and control the flow are often the first word and easy to spot.
A couple of months ago, I tried Flutter, and the editor can highlight ident blocks and give them different colors, but with Flutter, it's easy to get 10 or more ident levels, Does the color help? Splitting the code does.
I think, there is so much stuff that is more important than coloring the grammar of a language. For instance: knowing if an identifier belongs to which Rust Crate because, It's easy to stack 10 or more dependencies in one file that as better chances of names collisions.
Knowing if an identifier was recognized, if it used, if it's a local, a member, a global, a compiled value or a macro seems more important.
I would like to color block of code that is important or sensible. That will help my coworker about the severity of a particular place in the code.
What do you think?1