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 - "for loop"
-
I have an array of 1037 records. The soap service only accepts 100 at a time. So, I write code to send an array of 100 records at a time to the soap service in a loop and get a response back of, "The maximum number (100) of records allowed for this operation has been exceeded." Well, I'll try 99 records then. Nope same error. I'll try 50 records, nope I'll just bang my head on the desk now since the documentation and error say it is a record limit of 100. 😠
Look at my code again. I was grabbing 100 records out of the array of 1037 records and storing it in a new array, but I was sending the original array with 1037 records instead of the temporary array in the loop. 😢 I'm going to bed.7 -
Dude you've been in college for 4 years and you still don't know how to make a for loop in C. Why are you still here?!! I hate it when I have to carry 2-4 of these people every semester because of "group projects"!14
-
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 -
Started being a Teaching Assistant for Intro to Programming at the uni I study at a while ago and, although it's not entirely my piece of cake, here are some "highlights":
* students were asked to use functions, so someone was ingenious (laughed my ass off for this one):
def all_lines(input):
all_lines =input
return all_lines
* "you need to use functions" part 2
*moves the whole code from main to a function*
* for Math-related coding assignments, someone was always reading the input as a string and parsing it, instead of reading it as numbers, and was incredibly surprised that he can do the latter "I always thought you can't read numbers! Technology has gone so far!"
* for an assignment requiring a class with 3 private variables, someone actually declared each variable needed as a vector and was handling all these 3 vectors as 3D matrices
* because the lecturer specified that the length of the program does not matter, as long as it does its job and is well-written, someone wrote a 100-lines program on one single line
* someone was spamming me with emails to tell me that the grade I gave them was unfair (on the reason that it was directly crashing when run), because it was running on their machine (they included pictures), but was not running on mine, because "my Python version was expired". They sent at least 20 emails in less than 2h
* "But if it works, why do I still have to make it look better and more understandable?"
* "can't we assume the input is always going to be correct? Who'd want to type in garbage?"
* *writes 10 if-statements that could be basically replaced by one for-loop*
"okay, here, you can use a for-loop"
*writes the for loop, includes all the if-statements from before, one for each of the 10 values the for-loop variable gets*
* this picture
N.B.: depending on how many others I remember, I may include them in the comments afterwards19 -
I just learned that a web application I've been developing for the last six months will only be live for three days.
I could have, if they had kept me in the loop, knocked it out in the same week.
But no.
I built it to last.
End my suffering.12 -
My company contracted a 3rd party to do an internal system for us...
We only knew about it when it was almost done and we got the code... Oooooo boy.... What a fucking shit they did and got paid for...
They have a encryptPassword() and decryptPassword() functions...
What they do you may ask?
Well...
Encrypt: for loop that reverse the string and base64 it 5 times...
Decrypt: the opposite...
That's how they store passwords....
Our intern snapped at a company meeting when they where talking about maintaining it 😂😂22 -
"How do I use a for loop?"
I mean I can't fault them for being open to being taught, but if you're working as a software engineer...and can't use loops...11 -
Instagram coding pics are so fucking cringe worthy....like for real man. A picture of a simple cpp loop, or averyfuckingbasic Express hello world in some hipster filter with inspirational quotes and everyone looses their shit for it.
Instagram people are so easy.11 -
Friend: Do you think you could make an app that does X?
Me: Yes but I'm not an app developer so haven't had much experience with app design so might take a while
Also friend: What sort of programmer are you? It's basic shit
My friends don't seem to understand that the programming loop for game development (Mostly background asset management) and app development is like trying to ask why a bull and a bull frog won't breed...Yes they both have bull in the name but they are 2 fucking different cunting things...8 -
18000 duplicate lines that were manually copy pasted by the previous programmer.
I replaced them with a for loop.
I don’t think it was that hard…11 -
Boss: Oh can you add this feature?
Me: I added that function already and you said to take it out.
Boss: Can't you just copy and paste it from an earlier version?
Me: No its really not that simple, I removed a bunch of tables and went to town cleaning the code so it's super quick and "sexy fast" as you put it.
I go home, work all night and forget to eat.
nextDay++;
Boss: Actually just hold back on that, I'm having second thoughts.
When a project seems to be in an endless for (fucks sake) loop.8 -
Hey everyone! Recently there was a bug discovered which caused many (but not all) “user x posted a new rant” subscription notifs (both in-app and push) to not get sent out for the last week or so. It should be fixed now. Unfortunately though, they won’t be backfilled, so make sure you take a look at your favorite ranters’ profiles since you might not have been notified about their most recent rants.
A big thanks to @gitpush for reporting the issue and thanks to @linuxxx for help testing/confirming the fix worked.
For the basic cause: when we overhauled/fixed push notifs on Android in the last build (about a week ago), we had to convert to FCM. When a “user posted rant” notification was getting sent out, the asynchronous worker would process all of the subscription notifs in a loop. So for users who have a lot of subscribers, somewhere in the loop, something was failing, likely having to do with the new FCM send method. This is now fixed and all push notifs in that worker are also done asynchronously.
Let me know if you have any questions and apologies for the loss of subscription notifs!13 -
GUYS WE HAVE BEEN WRITING FOR LOOPS IN JAVA WRONG THE WHOLE TIME. Here is how it should be done correctly...
int i = 0;
for(;(i<10) ? true : false;)
{
i++;
System.out.println(i);
}
Jokes aside though does anyone have any more horrid ways to write this?20 -
Going to forums asking for help as to why my nested for loop wasn't working correctly after the first loop only to realise I was using the variable i for both loops...
Felt like an absolute twat4 -
Gooooood morning devRant! Fucking friday, fuck yeah.
Hereby a rant which @dfox asked to make to test if a possible bug is fixed.
Have a great day everybody and thanks to dfox for keeping me in the loop on this!12 -
in python script; a for loop inside a recursive function to slow down stdout. i don't know time.sleep(n) back then4
-
this is the state of hiring tests:
1. can you take an english sentence, and without a tutorial, write a for loop?
2. okay now write a full parser. but not in the language we want to hire you in.
also we can afford to pay you in bananas, experience, and exposure.
p.s. we also need you to do this backend test because this is a backend job even though the ad is for front end and you specified an hour ago when the interview started that you only trained for front.
on the positive side, we have a ping pong table and a bean bag chair. and a two hour commute. Think of the benefits!16 -
VBA is not the language of choice for many of you. But in a big non-software company, Excel is tool numero uno, and VBA saves so much time. Almost nobody bothers to learn it, which drives me nuts already, but those who learn it, suck.
Wrote a beautiful VBA script with SQL inside to fill in excelsheets automatically.
Why the living fucks would someone go in the code and alter it? Why do you ignorant idiot with almost no excel and vba knowledge alter the range of the for loop and delete a few lines.
After that completely knocked out the file, I got a call for help. "¡Your code broke!"
These useless morons.16 -
Dear javascript, you think you're sooooo fucking special. You just HAD to be asynchronous everywhere, losing all connections to natural sequential human thinking. I just want to work with the result of A GOD DAMN FOR LOOP you ASYNC FUCK.12
-
My first poem for programmer girl 😘😘😘
My life is incomplete without you,
You are semicolon of my life
You are my increment operator,
you make my value increases
I am username and you are my password,
without you No one can access me
You are my initializer,
without you my life would point to nothing (NULL or “0”)
If I were a function you must be my parameter,
Because I will always need you
Can you be my private variable?
I want to be only one who can access you
You are my compiler,
My life wouldn’t start without you
You are my loop condition ,
I keep coming back to you
My love to you is like recursive function,
It will never ends & Will never enter into infinite loop
Forever and Ever10 -
A friend was writing a small game. He asked me to take a look at why the FPS where horrible although he was only drawing the background each tick.
He had about 10 different images that were used to draw the background tiles. Each iteration of the game loop he would loop over all tile positions, determine which image to use for this tile, load the image from disk and create a new tile using the image, which then would be drawn and forgot.4 -
My life in a nutshell.
I've been stuck in this timeless loop for 10 years, anyone that relates?
1. Set alarm before going to bed.
2. Alarm rings, I turn it off.
3. Wakes up late.
4. Work from 08 AM to 4 PM.
5. Take the train back home
6. Plan what to do for the rest of the day.
7. Come home, do everything except what was initially planned.
8. Watching time goes by while doing non-productive things.
9. I feel alone, watch porn to fill this void.
10. I get depressed and unhappy afterward
11. Set the alarm for the next day.
12. Repeat.11 -
That time I joined the robotics club and made the pid loop for the robot was one of my favorite projects. I learned ROS, and I created the entire chain of software and hardware to control six motors. That one project set up my experience for the next 4 years and led to a few jobs. I miss robotics.6
-
Always remember: Every time you write a for loop like that: for (int i = 1; i <= n; i++) a cat dies!5
-
The client requested an ability to create reports in the app I had been working on. It was completed to their specification and they were happy with it for about a week.
Then, they asked me to redo the report, changing various components around so I told them it can be done, but is time consuming because they're essentially asking for a completely different report.
Now, they never even looked at the code before and the extent of their coding knowledge is excel formulas. Their repond to me was "it's easy, just reverse the loop."
I simply did not know how to respond. "Just reverse the loop." ...I mean it's so simple, just reverse the loop... It doesn't matter that I've spent a good amount of time on this already, or that the client have never seen the code, doesn't understand coding, doesn't care about programming, none of that matter. ...just...reverse...the...loop...6 -
Why the fuck do teachers take points off for coding style. Like really placing my open house brace on the same line as an if is what looks good TO ME. And breaking from a while loop with an inverted condition is nicer than a huge if TO ME. Fuck it I like the m_ for member variables too. And yes C++ usually names functions like someFunction, but I like how c# does SomeFunction. Like shit, it's personal I don't care that I lose 5points every test I do it just to say fuck you21
-
Of all people that apply for a job at our company, 95% can't write a loop that counts from 1 to 10.
And if that's not bad enough: our bosses state "we shouldn't ask such difficult tasks."18 -
5 years ago i was working on a 2D game using C and we needed to use the sleep function (I forgot why ) .but however one of my team member did something new , for each second he did an empty for loop from 0 to 1000000 .You never know maybe that's how it's implemented (sarcasm)1
-
So today I accidentally wrote a non-termating for loop that sent POST requests en masse to our server and likely crashed it while I was peer programming with my team lead, how's y'all's day goin?4
-
Man it's midnight and all I want to do is work. 5 hours from now I'll be dragging out of bed to go to work where nothing gets accomplished. In 17 hours when I drag in from work I can do real work for 7 hours before crashing while wishing I could just code through the night. It's an infinite loop and I dont know how to fix it!10
-
2nd year of college, in computer science course and they're teaching us how to create star patterns using 'for loop'. Feels like 9th grade all over again (sigh)6
-
Today I saw a code written by my junior. Basically excel export. The laravel excel package provide great ways for optimization.
My junior instead did 6 times loop to modify the data before giving that data to the export package. We need to export around 50K users.
When I asking him why this ? He said it works and it's fast so what the issue ???
Noob , you have only 100 users in the database and production has 10 million.
Sometime I just want to kill him.15 -
Teacher told me to write "I must do my homework" 100 times.
I wrote a for-loop that outputs "I must do my homework" 100 times.7 -
Okay, just wrote a program with memory allocation inside an accidental infinite loop and by the time I was able to kill it, it had already claimed 86% of my memory. Scared the shit out of me because my OS was CRAWLING for a while3
-
Hiring junior devs is a game of Russian roulette.
You can get some one who is smart and loves coding. In this case stack, limitations etc don’t matter and experience will be great for junior and the rest of the team
Or it will be a lazy person who watched 5 videos and think to be better than everyone else. 95% of juniors are these fuckers. Takes about 1 week to find out and fire… which starts the 3 months recruiting loop again.18 -
I just woke up in the middle of the night realizing that I have been dreaming of a for-loop the last few hours!3
-
Manager: Send me a MS Teams chat if you have any questions or updates, it's faster than email and you'll get quick feedback from me :) Let's get that feedback loop ROLLING!
Manager: *ignores my (multiple) requests for feedback on MS Teams for over a week.*
I just want to move my tickets into done :(5 -
Note to self:
Don't try to remove elements from a list using a for loop because the FUCKING LIST SIZE CHANGES!
Just copy required elements to another list and discard the previous.
Spent fucking 2 hours on this.
/Rant9 -
Writes code in C
Terminal: Seg fault
Rewrites code
Terminal: Seg fault
Rewrites again, opens gdb:
Seg fault
"I should open a brewery, I like beer. I've always wanted to make beer, it's analogic for the most part. No seg faults, can you believe that? Perhaps even a pub next to the brewery..."
"Oh, I was doing one extra iteration in a for loop. Nevermind"7 -
This F***ing government college faculty crossed my complete answer of a F***ing bubble sort in 3rd year of Mathematics & Computing by saying and I quote, " Why is this i loop inside of j loop?" and after getting again on my feet after listening and understanding this absurd statement, I tried to explain to which he asked ne to show any book where it is written like this.
To i loop and j loop he meant the variable name in for loops, 🤬🤬🤬🤬
these f***ing reserved government professors in elite institutions like IITs15 -
FUCK OFF, YOU FUCKING USELESS PILES OF CRAP
WHY THE FUCK CAN'T COMPANIES JUST TEST THEIR FUCKING APPS FOR ONCE?!?
LINKEDIN GOES INTO A FUCKING CAPTCHA LOOP
SNAPCHAT/INSTAGRAM ARE AS SLOW AND ATTRACTIVE AS A SLIGHTLY RUNNY SHIT
ROCKSTAR IS FULL OF MONGS WHO DON'T KNOW HOW TO MAKE A WORKING FUCKING GAME
GOOGLE IS FULL OF PERVERTED FUCKERS WHO TRACK YOU EVERYTIME YOU LOOK UP A FUCKING RECIPE.
FUCK THIS WORLD, WHY THE FUCK CAN'T BIG COMPANIES JUST MAKE SOFTWARE WITH THE USERS IN FUCKING MIND?!?!?
FUCK ME, I'M ANGRY10 -
Fucking fuck you STRATO. This cancer of a german hosting provider just should be shutdown for crimes against reason. Our website got infected by some shit (I'd like to not state why, there is only so much pressure my main arterie can handle) and now we are supposed to remove that file. Well they blocked all incoming and outgoing traffic to the server so we cannot connect via sftp, the only choice you got with STRATO. And they wont restore network access for the server unless we remove the file. No logical loop to see here citizen, please move on.26
-
Seen on HackerNews, couldn't left it for myself.
Mail loop from hell: https://blog.dbrgn.ch/2012/7/...2 -
for(i = 0; i < n; i++);//<-- this one
{
//Do stuff
}
One day struggling why this for loop in C just iterates once, found out that ";" was leaving the for body empty, and the "Do Stuff" ended beign out of the for.8 -
If programmers became musicians we would see
- Wake me up when my build ends, 21 cores, Boulevard of broken CI pipelines by Blue Screen Day
- Smoke from my cabinet by Deep For-Loop
- This is how you debug me by Loopback
- Post-release rhapsody by debug queen
- Another bug in the code by Programmer Floyd
- Smells like bad code by Coders from Botswana
- A place for my code, Cure for the bug by Likin to code at dark
etc etc..5 -
Making an infinite loop of cat /dev/urandom for anyone trying to login to server via ssh as an April Fool...
But on prod server instead of dev server...3 -
Loop counter conditions.
10 loops for example in this scenario:
i<=9
OR
i<10
Was arguing with a co-worker all week over this 😂11 -
So Friday afternoon is always deployment time at my company. No sure why, but it always fucks us.
Anyways, last Friday, we had this lovely deployment that was missing a key piece. On Wednesday I had tested it, sent out an email(with screenshots) saying "yo, whoever wrote this, this feature is all fucked up." Management said they would handle it.
The response email. 1(out of 20) defects I sent in were not a defect but my error. No further response, so I assume the rest were being looked into.
In a call with bossman, my manager states that the feature is fixed, so I go to check it quickly before the deployment(on Friday).
THERE IS NO FUCKING CODE CHECK-IN. THE DEV BASTARD JUST SAID THAT MY USECASE WAS WRONG, SO MY ENTIRE EMAIL WAS INVALID.
I am currently working on Saturday, as the other guy refuses to see the problem! It is blatant, and I got 3 other people to reproduce to prove I am not crazy!
On top of that, the code makes me want to vomit! I write bad code. This is like a 3rd grader who doesn't know code copy-pasted from stack overflow! There is literally if(A) then B else if(!A) then B! And a for loop which does some shit, and the line after it closes has a second for loop that iterates over the same unaltered set! Why?! On top of that, the second for loop loops until "i" is equal to length-1, then does something! Why loop???
The smartest part of him ran down his Mama's leg when it saw the DNA dad was contributing!
Don't know who is the culprit, and if you happen to see this, I am pissed. I am working on Saturday because you can't check your code or you lied on your resume to get this job, as you are not qualified! Fuck you!15 -
A programmer heads out to the store. His wife says "while you're out, get some milk."
He never came home.
The poor guy is stuck causing serious problems at a grocery store somewhere.
BREAKING NEWS: Man stuck in 'while' loop crashes global milk market. Will authorities resort to ctrl-x? This story, and more, at 7:00.
UPDATE: keyboard interrupts proving ineffective, authorities discussing resorting to kill -9
Aaaand he's broke.
And he has ALL the milk.
Should read as "return home"
Unfortunately, she gave no instructions for terminating the loop.3 -
Today I had the pleasure to introduce to my Professor (who teaches Python) that you could cause a keyboard interrupt typing Ctrl-c. Her logic was that "Ctrl-c is for Copy" and the only way to end a infinite Loop in the shell is to, "X out the Window." She also clearly has never dealt with linux or terminals.13
-
A follow up from my previous rant about a dev colleague in the security company we work for consistently forgetting to lock his screen...he's done it again, so I made him a dickbutt loop this time6
-
6 am, searching for the reason that put the programm in a non-responding state since 4 am. Turns out I forgot to manipulate the count variable in a while loop, so unless the first object wasn't the correct one, it hot stuck.
FML, don't programm when tired2 -
It's okay to make something nobody wants.
I wasted a lot of my life being too scared to make something out of fear. This community especially can be very toxic to people that are starting out, that aren't geniuses, that didnt make every perfect decision for their product.
Life is more enjoyable in a create-fail-learn loop than a consume-criticize-gloat loop.
I wish I'd learned that sooner.6 -
We have an API available for our customers to integrate our software with their Webshop.
A client and their developer complained because not all of the products came through. I checked the products, the validation, the parameters, the database .. everything looked fine and I was scratching my head why these articles wouldn't come through (but it did work at my end).
After some time, I checked the request logs..
Apparently it wasn't quite clear for them that a loop is required with the 'skip' and 'take' parameters to create an offset for pagination.They only synchronised the first 500 products.. everytime..
We have a limit of 500 products per batch (take) for performance reasons.
They asked if we could increase this limit, because they have "a large range of products" (not really, only 800 or so and we have clients with more than 2mil. products..) Oh pls.. I've sent them a link to the PHP manual for a basic 'while' loop..2 -
Threaded API Calls, or rather:
How I killed five server instances in one shot..
Creating 50000 Threads sounds like a good idea in general, the bad part starts when you use start() in a for loop to run them all at once.
No further comments your honor...7 -
Typos kill, kids! And deploying to production.
Instead of "for item in items" in my script, I accidentally did "for items in items". Thus, an exponential loop has been entering things into the database for the past few hours before I found the place to fix it.
By the way, this runs on cron every minute. So there are processes still running exponentially right now, possibly 180+.
Yeah, I'm setting up a a test server instead now.11 -
Bless the service APIs that don't charge you for failed requests, that fucking on-site team almost cost my client 7k$, just because of a typo and an endless loop, that they pushed to production, while bypassing the rate and resource limit I set in place, because it "wasn't working" - it was working, you fucking cunts, it was preventing your system running wild for a reason.
-
I used to prefer, think, and code in loops rather recursion.
Now though somehow it's the other way around...
And I have to assure myself why a piece of code I wrote won't cause a Stack overflow... and that if I really had to I could convert it back to a loop.
Haven't done it though for a awhile tho...7 -
The debugging loop for Minecraft Spigot plugins on a 4GB RAM laptop:
1. Start Eclipse - 1'
2. Edit code.
3. Build plugins - 2'
4. Close Eclipse to make RAM room for Minecraft.
5. Upload plugins to server with FTP - 1'
6. Start server and launch Minecraft - 2'
7. Enter the server.
8. Find bugs.
9. Stop the server, close Minecraft.
[Go back to 1.]17 -
Me: yo DEV2 parse this string into a hashmap. Use regex, 2 rows of code are enough for the job
DEV2: implemented 40 rows of switch/if cases into nested for loop.
Please kill me 🔫🔫🔫🔫🔫🔫🇮🇹3 -
When I just started my software engineering course in college, we had a group project every semester where we would use the skills learned during that semester to make a certain product or program.
For the semester in this story, we were tasked with making a reservation system for a campsite. Visitors would be able to select a free spot, and reserve it.
The spot reservation screen would be a map of the campsite, and visitors would click on the desired site on the map to select it. Sites were neatly laid out in a perfect grid.
My task in the group for this project was my favourite position: yelling at people for poor code quality. And boy did I get to yell.
Any semi competent programmer would probably come up with two simple loops to generate all the buttons (something like 144 buttons), one loop to fill a row, and then another to go down the rows until all were filled. Some other similar functionality in the program was solved this way.
However, my classmate that was responsible for this part of the code wasn't a big fan of concise programming. So instead, he wrote 144 functions aptly called `generateFirstButton()` all the way through `generateHundredFourtyFourthButton()`.
*what*
I called him out on his horribly smelly code, and his retort was "But it works, and now you don't have to think about complicated loop logic".
I rewrote the class and reduced it from ~1150 lines to about 20 lines.
He didn't pass the exam.2 -
Needed to convert a collection of .avi videos to .mp4. Online converters only allow 1-2 videos at a time, with slow uploads, so no option.
Can't find a program that quickly fulfills my needs. Interesting ... 🤔
Look for python and a quick and dirty solution, ffmpeg and subprocess it shall be then.
Install ffmpeg, run subprocess with ffmpeg, put it inside a for loop, iterate over all videos with their respective number. Done.
3 lines of code, saved some time.
It's great to be a developer (sometimes).😏16 -
!rant
The more I learn about advanced C++ the more I love this language. C++'s template system is so insanely cool!
Just made a proof of concept expression templates based linear algebra library for my own projects. It was actually a lot of fun to make, and seeing it spit out optimized, loop-fused code with no temporary variables...magic.
Long live C++.7 -
I feel so unimportant today. I'm feeling like an
else {
continue;
}
in a loop. (I wrote some code for 2 days and then I found out a way to do it better in 10 mins)2 -
Why do viedo tutorials always assume that one doesn't know anything about programming?
If I am looking up a framework or library there's a good chance I know what a for loop is, and even if I didn't it's not the place to teach me 😒13 -
La me working on a new chrome extension:
- ok, this page has some hidden divs, I need to tell the extension to make windows scroll to the bottom while there are still elements with a hidden class
- creates a while(1) loop with a condition inside it to break if no elements with hidden class are longer there.
- happy with the code
- uploads the extension
- goes to page
- brings out developer tools
- goes to console
- clicks on extension on chrome
- right clicks the extension and then inspect
- ok here we go: la me click on button inside extension popup
- console shows some logs
- nice it's still looking.
.
.
.
- wait! Why is the page not scrolling ???
- looks at logs, WTF nothing changes in logs .....
- OMMMMG a infinite loop .... infinite loop inside chrome ....
- OMMMMMG my pc's gonna crash .
-stop please stop stop.
- wait! how do I stop this?
- tries CTRL+C ... nothing
- tries CTRL+Z ... nothing ...
.
.
.
.
Abort abort Aboooooort.
.
.
.
- Deletes extension from chrome.
-..... loop still running
- clicks on X to close Chrome.....
- not closing O_o
- Oh God, i need to do something before Chrome sucks all the RAM left.
- remembers the savior...
.
.
.
- Task Manager heeeelp me.
- opens Task manager
- chrome is consuming ~ 2 GB of RAM.
- WTF! Kills chrome.
Thanks for reading my lil adventure 😅5 -
After getting stuck in the shower this morning; I am starting a petition to get shampoo manufacturers to wrap their instructions in a do-while loop. Telling a developer to "lather, rinse, repeat" is a recipe for disaster...1
-
Here is another rather big example of how C++ is WAY slower than assembler (picture)
Sure - std::copy is convenient
but asm is just way faster.
This code should be compatible with EVERY x86_64 CPU.
I even do duffs device without having the loop:
the loop happens in the rep opcode which allows for prefetching (meaning that it doesnt destroy the prefetch queue and can even allow for preprocessing).
BTW: for those who commented on my comment porn last time: I made sure to satisfy your cravings ;-)
To those who can't make sense of my command line:
C++ 1m24s
ASM 19s
To those who tell me to call clang with -o<something>:
1) clang removes the call to copy on o3 or o2
2) the result isnt better in o1 (well... one second but that might be due to so many other things, and even if... one second isn't that much)25 -
In college when we had programming labs where we had to use the schools unix server to compile and run.
My professor was very bad at explaining what actually needed to be done in the labs to the point where even the TAs didn't know what to do.
We were suppose to write an application in C to find out by "trial and error" how large we could make an array (or something like that, it's been too long). This not being explained well and no one knowing that much about C, I wrote a loop that just kept growing an array until it couldn't anymore. I watched it consume 72GB or memory from the servers before quitting the loop and realizing with the TA what the professor really meant.
I now feel bad for the IT staff monitoring the system wondering where 72GB just went...2 -
So, the other day, my teacher told me not to use goto in C#, with only the reason that "it is bad".
Okay teacher, I'm going to continue using it until you give me a valid reason. For example for making one loop instead of two. .-.24 -
Just found this absolute 5 head, galaxy brain implementation in a piece of code which is called in a loop by a background scheduler which has performance issues.
There are 20+ properties, some which are recursively calling other properties with the same implementation style in this class.
Constant out of memory errors have been reported for this software, I wonder why...15 -
short one.
So my CS course is full of people who can't write a fucking for loop (I shit you not) after more than half a year.
And then there's those that don't know what a return type is.
So I asked them once, after they stated that the course sucks, why they even chose it in the first place.
Freely translated it would be:
"I dunno, I thought we'd be doing cool hacker stuff in here..."
At that point I just wanted to jump out of the window.5 -
Do you guys think that in terms of a design, we're in a refresh loop?
Like, I don't think the goal of a design is to be user friendly and optimal for all human eyes. There's a million ways sideways to achieve that.
I think the real thing most designers go for is to just make something look "new". And every few years that needs to be redone. Forever. In an infinite loop.
Fuck actual usability, thought-out layouts, contrast rules, what-the-fuck ever. 99% of the goal is to make it look "modern"10 -
In college I was working on a PHP app that needed to get a list of people to send emails to from a DB and send an email to all of them.
The good news is, I had hard-coded my own email address for testing so I wouldn't annoy anyone if things got messed up.
The bad news is, I had done something wrong and had an infinite loop. It was only running for 30 seconds or so, but the emails were coming in for hours.1 -
Wasted a bloody hour today wondering why a route was giving weird errors...
Turns out I inadvertently wrote a for ... in ... loop instead of a for ... of ...
It's my bloody fault for being retarded, but I swear this unholy mix of JavaScript and python I'm dealing with is doing bad things to my brain. 😔5 -
"Non-devs never call Steven Spielberg to have their TVs fixed."
But sure they MUST call a dev to update their Android, iPhone, Windows, installation of Anti-virus, data recovery, malware removal, to shortlist 20 laptops from market, ask for what printer to buy, why is there a weird animation in Android sometimes, come borrow my WiFi, have their phones and computers fixed, RIP old audio CDs (yes!), fix Bluray, fix anything electronic, repair their bike, teach them science, politics...
This While True loop never escape.1 -
Tech Lead: We need to exclude logged in user from our all users API as we don't want to show user's self card on the frontend with other users.
Me (Backend dev): This should be handled by the frontend and they should exclude it by a condition in their loop:
If (user.id != loggedUser.id)
{
// Add card
}
We also need self user at several other places.
Tech Lead: Create a query param filter for that.
Me: We should keep our APIs as generic as possible.
(Real thing starts)
Tech Lead: Which has more processing power frontend or backend?
Me (confused): Backend
Tech Lead: This will add a break to our loop and Do you know how much processing power it will take because of this condition?
Me (dead): WHAAAA....?18 -
when code comments be like
# loop over the array
for i in 1...10
# divide by 2
x = i / 2
# return the result
return x4 -
Was accused of plagiarism because I could write a bubble sort algorithm without a reference (and therefore without a source) in my SECOND year of courses.
Their low expectations bit them in the ass when the admin. made all undergrads take a basic test (for loop going through an array, average of values, etc) and lots of people in their third year failed.7 -
This was when I was pursuing my bachelors degree. One of the professors was of the opinion that only her code was right and anything else is wrong! For example if she did something with a for loop and I did the same with a while loop, my answer would be wrong -_- What the hell -_-
(Also, often her code would be wrong too and sometimes wouldn't even compile.. She used Notepad btw)10 -
End of Hackathon. Students and faculty voted on applications. My group got student voted best overall. Now to sleep for the first time since before Hackathon. So tired, my brain’s literally got “background Zoom meeting sounds” - typing, soft cursing under breath, etc) on loop. I haven’t been in a Zoom in hours.2
-
Just had to write an old-skool for loop. Index...termination condition...whole works. I feel dirty.
Bit embarrassing as someone saw me writing it, thought I was a hacker and informed the authorities. Spent the last hour being waterboarded.
We had a big laugh about it when they realized I was just fixing bugs in a legacy app.
National Security. Hilarious.10 -
I just wrote a function with a while loop AND recursion because I wasn't paying attention.
That was fun. Also, MySQL isn't happy right now. I'm posting while I'm waiting for my local service to restart.3 -
You know you did good for the week, when you realize that the infinite loop looking logs you were trying to recreate for the last half hour was in fact caused by how you held your thumb on the side of the thin bezeled device you were inspecting...
Have a nice weekend!1 -
Another oldie - apologies if it has been done before.
So there were these two developers in a light aircraft looking to land, but they were completely fog bound and had no clue where they were (I said it was an oldie - no GPS).
So they flew around for a while, getting lower and lower hoping to see a landmark, when they flew past this office building.
As they went by, they saw a single light on in one of the windows, so they flew around again and attracted the guy's attention.
On the next loop around, the pilot shouted "WHERE ARE WE?"
Then on the next loop around, the guy in the office shouted back "YOU'RE IN AN AIRPLANE".
They looped around again, and the pilot shouted "THANKS!" and set course south west for 15 miles and made a perfect touchdown at Seattle airport.
Hi passenger looked at him and said "How did you do that??"
He said "Quite simple really. I asked that guy a perfectly reasonable question, and got an answer that was 100% correct, but totally useless, so I deduced that must be Microsoft, and I knew that the airport is 15 miles to the south west"2 -
We did retrieve the whole list 20 lines ago, didn't we?
Well, who cares... Let's retrieve it again IN A LOOP, im EACH ITERATION.
and then for good measure lets make another query for each item, each time we retrieve the list. Why not?
I have to make an effort not to swear right now. I have been asked to optimize a particular oiece of code...
Ffs3 -
When I started at my company I was full of energy and wanted to improve the whole codebase. After years of getting blocked by new projects with deadlines month short of the actual time required and missing a lot or all important bits (texts, images. you name it, it's missing) I kind of have up.
I do refractoring now and then but it's not as extensive.
My biggest sin was a nested for-loop that I came across (50+ times nested, previous dev really loved c+p).
I looked at it and started to write the recursive function but stopped half way through, fixed that one error I'm the loop somewhere around 30 levels down, committed and made myself a coffee.
I hate myself to this day for giving up.
Shit I'll just factor that loop tomorrow3 -
When you're doing a demo and switch to a workspace with a green-on-black terminal with tmux on it, sending requests in a while loop and polling some output every second.
And then people (mostly devs) start posting Matrix memes in the meeting chat
Feels good :)
This always reminds me that what's a casual tool for me, for others it may be an esoteric unicorn-magic-powered super geeky stuff.3 -
When I was really new to JavaScript, I wanted to create an image gallery with images which I stored in a MySQL database. Well, I did not really had a clue how to load all the image sources into my JavaScript to load the images. I also didn't know much about fetching an endpoint of my website to get the data asynchronously.
I also wasn't a good database architect at that time and my database had an image table wich was for the gallery. Within this table there were multiple columns for one image slider (there should be multiple sliders on one page in the gallery (I know... 🤢)).
So I ended up writing an PHP loop wich printed Javascript loops for each row in my images table. Within my JavaScript loop I created the sliders and set the images.
In my defense I can say: It worked. 😅
It hurts to remember this. And I hope you won't judge me.2 -
A few weeks ago, I was kept up until the wee hours of the morning trying to figure out how in the hell the Monty Hall problem works. After finally getting it (I'm slow, okay?), I decided to write a program to run simulations of it.
First incarnation of program took user input. User enters what door they choose (1, 2, or 3), then is told what door Monty opens, then given the decision of staying with the door they originally chose or switching, then informed how that worked out for them.
Second incarnation of program ran on a loop. At the start of each loop, a random door is picked for the user guess. Then the door Monty opens is calculated from the remaining doors (excludes user guess and prize door). Then user switches doors (choosing the door that was not their original door or the door Monty opened). At the end of each loop, if the door they switched to was the prize door, it would increment a win counter, else increment a loss counter. After running the loop 1000000000 times, it printed to console `You always switched doors, resulting in ${wins} wins and ${losses} losses`.
THEN I decided to write a variation to run a while loop on the outside of the loop to increase the number of total doors until the point where the decision to switch doors hurt more often than it helped. At this point, I decided to incorporate file I/O and write to a file rather than a console. And that was neat!
And then I decided it would be cool to go back to the three door variation, printing on each loop the original door, the door Monty opened, the door that was switched too, the result of the switch (win or lose) and what the prize door was.
But for the life of me, I couldn't seem to get the file to write properly. It would, like, always crash my terminal. I tried open + append, I tried append. I tried createWriteStream. Still just failure.
And then I changed it to an appendFileSync and happened to look at one of the files that I was writing to. "Huh, over a gig seems a lot."
"Well, how much are you writing each loop? Did you forget to keep in mind how many bytes that would be?"
TLDR: If you're going to write a program that's going to write data to a file on a loop, you might want to figure out how much it's going to end up writing .... before trying to run it. And running a loop 1000000000 times may be a little excessive.
*face palm*2 -
I am currently refactoring some code which exists before my time in this company.
The code was so inefficient before. To put into perspective for every function call it used to loop through some data 100+ times .
I replaced it with a map and voila, no more loops anymore.
The person who wrote this code don't even realise how bad his code was. He sits besides me writing more stupid hacky code for other parts of the app.3 -
Debugging a java program for hours only to find that the mistake was a semicolon just after the for loop declaration FML
-
Apple products are so fucking overpriced. Here is an "Apple TV Remote Loop" (that holds the remote to your wrist). It costs ₹ 1500
For people outside India, his shit costs more than 1 year of unlimited calling phone plan from the leading provider, with 24 GB data and complementary TV and Movies subscription. (₹ 1299)15 -
Company has me giving interviews and today brought the second "Sr JavaScript Developer" that's gotten past multiple people that can't even construct a fucking "for" loop.
Get the fuck out of here... And those excuses at the end trying to explain your "industry experience" just annoy me further.
If I have to smile, thank, and shake another one of these fucktards hands, I'm gonna scream!11 -
I need to delay execution of code in a for loop, how do I do that?
PHP: Sleep(3000)
Javascript:
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
console.log(num)
})
console.log('Done')
}
start()
Fuck you Javascript17 -
Burn I hell whoever designed this font.
I just spend 20 minutes trying to figure out what special thing this for-loop does if it's just from 0 - 12 -
Was fixing a bug and suddenly got an error that the lodash library could not be loaded. Funny, didn't even know the project used that lib. Looked for the reference and the previous dev used _.times instead of a for loop. Ha okay, interesting. Wonder where else this library is used.
Searched the whole project for references, dependencies, whatever, any sign of it. Fucking. Nothing.
Rewrote the _.times part as a simple for loop, then removed the library. The rest of the project still worked perfectly. Took me about a minute and a half.
Who the fuck uses an entire damn library to... Not write a for loop I guess?!7 -
*trying to install arch linux for the first time*
> reboot
> system goes into a boot loop
> cant get into BIOS
> taking pc apart rn8 -
I help first year Computer Science students at my uni. In the first few weeks I reviewed someone's code to find he had 253 variables called var1, var2, var3 and so forth. The even worse part: he made the same if-else structures for every variable without using a loop.
if (var1 == something) {
//huge chunk of code here
}
else if (var1 == something) {
}
else {
}
... var2... var3
The funniest thing about this is that we had a discussion about this, because he claimed this was the right way to solve his problem.5 -
This was a while back... Like 20 years ago. I was doing some crappy development with asp/vbscript. Once I had a task to send emails in certain cases and while testing, I used my personal mail as recipient. In a loop. If you ever did asp/vbscript you know how easy it is to have an infinite loop... And my mail was forwarded as text messages to my phone. I deleted incoming text messages for days.
And I made the same mistake next week.2 -
I hate it when I reject their laughable offer and then they just go on and ask from me to recommend any friend for THAT position. Bitch, I rejected your offer for a reason, what makes you think I'll just throw my friends into those positions that I find offensive for myself. And also it's your job to find people, not mine.
And worst of all is when that come the other day with a different and even more laughable offer and I reject again and they again ask me for recommendations and the loop goes on until I HAVE to become an asshole and tell them some swearing words they could never think of.4 -
after staring my stupid code for 10 mins, the facepalm. Better even before this my program went into infinite loop cause i had initialized a counter and if(counter<10) WITHOUT INCREMENTING IT. Its 1 am i should sleep.2
-
For robotics I decided to write a program that would automatically tune a PID loop (a loop with three magic constants that tells you how much power to give the motors).
Being a high school student who hasn't been taught anything about the theory of PID loops or the right way to tune them, I had no clue what I was doing. So instead of actually learning the calculus to do it, I just made an evolutionary tuner that keeps guessing slight variations of the last-best three constants.
Basically, you press start and the robot spins in circles until you come back in 15 minutes.3 -
When you see
int i = 0;
while (int i == 0) {
//Code where nothing changes i
}
If you're going to create an infinite loop you could at least write it as
while (true) { }
and save me a little time wondering what the hell 'int i' is for!3 -
Yesterday a scammer spam me with emails. So I decided to write a code to automate writing emails using SMTP methods for spamming them back... In a while loop...
So today I look at their website (using Tor in VM) the website is gone. Seriously I want to know what happened. Yesterday I visit their site, they are a gambling platform blablabla...but today the site is gone.
http://moneydot.com/
Btw , I'm not a hacker , but I am just an ordinary software engineer (nothing special about me here) who know how a while loop function.14 -
uni prof: "you can't make an infinite for loop. Infinite loopsnare only possible with while loops"....
I think it's not what he meant, but it was a while ago and I forgot the context, but multiple students made a 'what the fuck?' noise.5 -
Fucking corporate bullshit. My laptop, when plugged in, has no need for power saving settings. I leave it plugged in with the screen locked, when I'm not at the office. But if I ever change any power settings, the corporate rootkit changes them back to unreasonable settings about once an hour. So I put this on a 300 second while loop.
https://pastebin.com/ALET2wSa2 -
Why do big companies hire such loser engineers ??? I mean what the hell man. When you are hiring a fresher to code they should at least know how to apply/write a for loop. I once had a colleague who assigned each array element individually instead of writing a for loop and asked me why I refused to approve his stupid code. What do I reply to this ? It was so dumb, I could not articulate an answer.13
-
Time Wasted: 30 Minutes
Problem: Put the .add(myObject) statement OUTSIDE the for loop.
Solution: Today.Quit() || Coffee.Make();2 -
The programming things I've seen in code of my uni mates..
Once seen, cannot be unseen.
- 40 if's in 10 lines of code (including one-liners) for a mineswepper game
- looping through a table of a known size using while loop and an 'i' variable
- copying same line of code 70 times but with different arguments, rather than making a for loop (literally counting down from 70 to 0)
- while loop that divides float by 2 until it's n < 1 to see if the number is even (as if it would even work)
..future engineers
PS. What are the things you've been disgusted by while in uni? I'm talking about code of your collegues specifically, I'm also attaching code of my friend that he sent me to "debug", I've replaced it with simple formula and a 2D distance math, about 4 lines of code.6 -
Forgive me devLords, for I have sinned.
Today, I took while() loop and made it true, it was a dirty ordeal, however it's not entirely my fault, you see the api I called doesn't have a webhook of any kind and doesn't return results in real time either, you have to poll for them..... so here I am writing while(true){} to poll for results that could take seconds or even hours to finish.
😟11 -
We are switching to an infinite scroll mode for our app. I told the backend dev in my project (we're just 2 people) I need an API to get more than one post at once.
He told me to use a loop to call the old URL 15 times.
...Not sure if stupid or just too lazy4 -
I can’t anymore with those companies hiring unicorns only, reposting the same job offer for 6 months while they could have hired someone more junior and taught them. 1 year my girlfriend is in the “no experience” death loop while she outsmarts me by far.9
-
A coder and a non-coder were travelling on a boat together. Due to some reason there was a hole in that boat and it started to drown. Non-coder survived but coder didn't. Why? Coder thought it was just another loop hole which he could fix using his laptop. So much for his confidence!3
-
I had a list that was built off a for loop.
One day the list was off by 1, and continued to be for a solid week...
Instead of solving the problem.. Added +1 to the incrementer variable.
Hasn't happened since (3 years)1 -
WTF if you want to program stuff learn how to use your programming language. Why is it so hard for that many people to learn how stuff works and stop copying blindly from the internet?
I have two colleagues who are doing nothing else that to just google their problems going to the first answer and cooping it then trying to run the program and if it doesn’t work ether give up completely or starting a loop of inserting the error message to google and copy the first result?3 -
I am on a mission to go thru all the of bibliographies of all the books I have, and create a checklist of the books I have and don’t have, and continue to buy all the books in that list, add to the list for each new book I buy that references another book. UNTIL! The day I have a closed loop reference. to essentially “in this room all the books that each book references may also be found in this room, if the book isn’t in this room no other book references it.”13
-
wk48 best question:
My go to question for dev interviews is how do you find all prime numbers from 2 to x because there's so much room for optimisation.
Start with the basics, loop over every number and check if it's divisible by any number less than it, then record the prime numbers and check only those, then move to something like the sieve of eratosthenes then reduce the problem space and only iterate through 2 to sqrt(x)5 -
Ok so I'm taking a developer survey, and since this is the best community of devs I know I'm taking it here first. This is for research purposes attempting to draw parallels between thing such as favorite language and favorite editor, tabs vs spaces and years of development experience, etc.
If you would be so kind as to help me out I will post my findings here once I've collected enough data. Anyone that inputs a valid email address will also be kept in the loop.
Thanks! Here's the link!
https://goo.gl/forms/...14 -
> Be me
> Programming for an embedded system
> It's not interruptable
> Got ISR Fault (Interrupt Service Register)
> WTF
> Breakpoints are useless
> WTF
> Comment out some lines
> Turns out it goes ISRF Infinite Loop because of the multi dimensional array of strings
> WTF
> Use pointer intead of defining actual size
> Works
> WTF
WTF?1 -
I was wondering !
As a computer geek I would like to know everything from mathematics to programming , robotics and machine learning but as I go , new technologies appear and it's
just like an endless while loop!
I don't mean I wanna stop learning new things but just looking for a more effitient way for doing this!
Any idea about this?1 -
Windows Update prompted me to install the 1809 update for Windows 10 recently.
I left the machine for a while and came back to find it frozen at a completely blank screen.
It eventually restarted...and got stuck in a continual loop where the Windows logo would flash for a second and then instantly restart again.
The restart occurred so early in the boot process that I couldn’t even get it into recovery mode or do anything with it to fix it.
So I had no choice but to reinstall Windows from scratch and reinstall and restore all my software and files. Took about 7 hours.
Not happy!2 -
Following on from my previous SQL script to find prime numbers
https://devrant.com/rants/2218452/...
I wondered whether there was a way to improve it by only checking for prime factors. It feels really dirty to use a WHILE loop in SQL, but I couldn't think of another way to incrementally use the already found prime numbers when checking for prime factors.
It's fast though, 2 mins 15 seconds for primes under 1,000,000 - previous query took over an hour and a half.5 -
Last year I was asked to optimize a code in our legacy portal (yet to be replaced with the new portal). The legacy system didn't have a design phase. Straight away went to development by whatever developer available at that time.
It was seriously fucked up.
So I went and had a look at the vanilla PHP code that served data for a datatable.
** I nearly fainted **
A query was done to get data from a table without any joins.
Then for loop to display those data.
Then inside for loop, for every single column that gets data from a related table there's a fucking query.
Eg: select * from users where.... to display username. Then again select * from users where..... to display user's email, then another query for his phone number. Then another query to get service providers name, then another to get their phone number.
I think the guy who did it wrote his first hello world app with a bunch of queries and sent it to production. No one bothered to check until 4 years later when it slowed down like a friggin snail.
I'm surprised it even survived that long. -
It's 3am, just submitted an app for review for iOS... go to take one last test drive on the release build for android, and I get stuck in an infinite loop of "system up stopped working". An factory reset and an hour later, I'm saying fuck this, android waits, and fuck whatever Xamarin did to my phone. While I'm at it, fuck Apple for making me have 20+ icons in different sizes, and their shitty walled garden approach to a so called marketplace.4
-
Ladies and gentlemen... It finally happened... I finally killed a Linux install!
Was stuck at 1024 x 768, installed NVIDIA drivers, crashed, restarted and ended up in an endless login screen loop and then boom, crash and is no longer recognised in Grub.
Don't know what I did seeing as the machine hasn't been on for 3 days ¯\_(ツ)_/¯
Guess I'll have to do a reinstall when I have internet again!4 -
Oh, crikey: Windows 10 "Inaccessible boot device". Good old "bootrec /fixboot" didn't work, and any claims that "automatic repair" does anything useful is apparently bollocks.
So for the first time ever, I had to use a restore point to revert the system to where it was before Xamarin was installed. The prime suspect for this cock-up is Intel HAXM, since I don't belive anything else in Xamarin possesses the power to accomplish a boot loop. -
How to conduct yourself in a job interview
Simple test"Write a for loop".
First, write some nonsense bullshit for twenty minutes. Then, when you realize time is up, pass to the next question. After write more nonsense bullshit in SQL and jQuery, it's time to breath fast and panic.
Deliver your exam.
Pack your stuff and go to a cave where nobody ever will find you, cry the next three years and commit to a life of self punishment, shame and tears.
That's how you nail a job interview, suckers.3 -
loop {
So I want to write a simple program in language X. Create a new project. Language X does not have this feature. Okay, Let me write a library that does that for language X. Create a new project. What was I doing again?!
}1 -
Somehow, a continue instead of break in a switch-case looks weird. Although it makes perfectly sense with regard to the outer for loop.8
-
How to spend more time writing docs then code?
15m = doc
1m = code
<code>
/* Motor DC + Mosfet IRF520 + Servo
Materials:
IRF520 (Mosfet) + Dc motor + Batery (3V min)
diode (1N4007?)
Changed Tip122 for IRF520: Tip122 has less resistance and produces more heat
Hardware:
ARDUINO = A(port , 5V , GND)
MOSFET = M(A[port] , + , GND)
MOTOR = MOTOR(+ , -)
BATERIA = BAT(+ , -)
DIODO = D(sinal_1 , sinal_2)
MOSFET
M(port) = A(port)
M(+) = D(sinal_1) AND MOTOR(+)
M(GND) = A(GND)
D(sinal_2) = B(+) AND MOTOR(-)
ARDUINO
A(port) = M(port)
5V = null
A(GND) = M(GND) AND BAT(-)
*/
#define motorPIN 8 // A(port)
int loopy = 0; // Loop variable to limit de program
void setup()
{
// Initialize the motor pin as an output:
pinMode(motorPIN, OUTPUT);
}
void loop() // 1 loop == 100ms
{
if (loopy < 10) // Turns motor ON for 1 second
{
digitalWrite(motorPIN, HIGH);
}
else // Turns motor OFF
{
digitalWrite(motorPIN, LOW);
}
}
</code>22 -
While I'm doing my hacker rank problem I have seen new word instead of using letter like I,j,k .but it is weired .Can I just know what is t_itr is that has any operation? In for loop "for "t_itr" in range t"16
-
lecturer teaching us ASP.NET in the final year of degree: Are you guys familiar with a foreach loop?
(we've been studying C# for the past 3 years and are advanced students)
me: -facepalm and leaves the class-2 -
>be intern me
>switch between JavaScript and python all day
>make some extra effort to comply with linters
>slowly forget how to write a for-loop block -
Just learned how to write a for loop in kotlin and I now want to burn Java to the ground. When I first learned for loops in Java my brain almost imploded.2
-
Today I wrote a python messenger bot which listens to only one command;
get ip
It then replies with its public IP address. I figured this would be the easiest hotfix until I fix my dynamic DNS client.
Now thinking of it I could also make an "update domain" command for doing the API call, and then link the two with a loop and minute delay. Marvelous.4 -
Was writing a multithreaded program in Java with an infinite while loop (for waiting). The thread was never preempted. Added a print statement inside the while loop and everything started working :/
Now I need to print a stupid message just so the program works :P3 -
!rant
Recently I started to be interested in how code actually work. I do a for-loop or an if-statement but how do they actually work at the lowest level.
Another thing I've been interested in is security. I thought about learning how to hack my own systems in order to learn how to write more secure code and keep people out. But I'm a little afraid that as soon as I start look at how to hack, the police will storm through the window and take my computer 😂😂8 -
Today I was asked a question on JavaScript regarding the difference between normal `for` loop and a `map` function on an array with regards to closures. Can anyone help me understand? #javascript #interview12
-
Spotify you little shithead how often do I have to reset the random mode for you to finally play stuff at random and not loop the same 20 songs? WTF? you literraly have like 1k of them in this list and you loop 20! HOW AND WHY <.< i even pay for you. Get it together.
Anyone else feeling murderous mood today for no reason? I'm not even at work yet...1 -
A word of advice to any new Arch user: don't use lxdm for your display manager. It's utter shit. The package hijacks the symlink of any other DM when you install it, and it refocuses the DM on a 5 second loop while it's running, making it a pain in the ass to use a VT. LightDM was broken temporarily so I had to install it, but frankly, I don't ever want to touch thiis piece of software again.4
-
I wanna make a c+friends language and it'd be dev friendly and will throw lots of errors on compile to show love. Also it'll compile slower with each newline so you can always say "it's compiling" there will be classes but people instead and then instead of new I'll have create. As for loops let's go with a friendly do while loop and dontdo while as normal while or dowith i while to have a friendly for loop. Instead of ifs let's say decide() and instead of else let's have or. Instead of functions I'll have well you need no functions you'll have jumps and tests before jumps just like assembly has. Oh and everything will be a pointer because then it runs nicer. To create a variable you can't use = because that's the equal sign in decide you need to use "var int myint is 69" because why not. Then to print to the console "console.outputstream.out(myint)" instead of threads I'll have please like "please work" where work is a jump target. I hope you'll enjoy this language ^^
-
So I spent all day today trying to debug a C++ Program and after hours of digging into the code , I realized i had copy-pasted a for loop and had forgotten to change the loop variable from i to j. 😑4
-
When you open problematic code and someone actually queried all the items from db inside for loop... And took only one item on specific index... Instead of iterating over items from query result... 😓😓5
-
Just fixed my broken htc one m9 (boot loop after legitimate update) by powering it up month after putting in back to box for future repair. Who to blame? NSA? Android 7? SD Card?
-
Brought to you from the 5000+ line Java file. Contained within the 1500 line method. I bring you the following pattern. Let's guess all the ways we could've done this better?
- Streams
- For loop
- Iterator
What gets really fun is when this you get this pattern doubly nested so you have a random i's and j's floating all over the place.
Note: this isn't ancient code it was developed about 3 months ago.
[Code has been lightly anonymized]5 -
> Teacher uses a for loop to draw random dots
> Teacher explains we can't adjust the individual dots after the loop
> Teacher says we need to use classes
> Teacher creates classes
> Teacher doesn't show a solution to the initial problem
> Me is triggered as fuck3 -
My craziest interview prep was for the role I just started last week. I applied to AWS and forgot about it, a month later I got invited to do a phone interview followed by a 5 hour on-site loop
I had just 4 days to prepare while already working full-time so I basically didn’t do anything after work for those few days other than cramming through over 50 hours of content on ds & algo, linux, networking and scalable system designs.
It helped that I’ve been working as a software engineer for many years so I just needed to review what I already knew1 -
I was pulling background data from a job in PowerShell, and it kept coming up short from the same, final section of data that I just KNEW should be there.
Fiddled with the primary application for hours... HOURS! Then, I checked the log. There it was in all its Glory, tee'd out to the log during job execution.
What. The. Shit.
So, it seems that, since I was asynchronously pulling data in a loop keyed to the job status and had inserted a little sleep statement in the wrong place, I'd been missing the last second's worth of data. You just couldn't tell most of the time.
Nice.
5 minutes later it was working fine with a new loop/control structure. Jesus.1 -
I just copied the exact same code from another program into mine, actually left out a loop because I didn't need it. Also took some other stuff out, nothing much, just some var = othervar that I didn't need.
The other program, from where I copied the code, works fine, is fast, I see no issue, has been in production for a while now and no complaints. Mine, WITH THE SAME CODE, doesn't move. I don't understand how this is possible.21 -
I always confuse `for..in` with `for..of` and have to look up their respective meaning. Again.
It drives me crazy.
Do you have any mnemonic on this? How do you remember the difference?
(Now, as in this very moment, I know that for..in is for looping over keys of an object and for..of for looping over iterators. But tomorrow I will have forgotten it again.)10 -
So I'm writing a function in Unity3D that walks a rectangular grid. At one place in the code, I got the x+y coordinates backwards, which caused the function to infinitely loop between two coordinates.
Not seeing a way to kill the loop, I looked it up on Google. The suggestions I get are. . .
1. You need to kill the Unity3D task and lose your edits because the environment and the player run on the same thread.
2. You can pay ten bucks for an extension that lets you break out of infinite loops.
3. You should really avoid writing infinite loops. That's just bad form.
SERIOUSLY?1 -
I don’t remember exactly how old I was when my dad gave me the BASIC manual that came with his IBM XT. What I do remember is that he took it away shortly after I figured out how to put the beep command inside a for loop.
-
" Under the hood... the program is using a mix of condition-based learning, procedural generation of sentences/questions, and relational queries based on weighted 'topic' identifiers. It can create its own original statements and questions. It is real-time, and it really does 'think' (an internal dialogue feedback loop)." = If Statement
I saw this in the description for an app aclled "Real AI" -
Today is the fourth time in my career I needed a function that oscillates... to animate a 3D model slowly rotating left and right for my personal project.
Yay for the sine and cosine functions :D
...I never used them outside working with (mostly 3D) stuff that has to animate in a loop8 -
I shall delay your PR with my giant egotistical scrotum by:
- Use less words for your function name
- Use this obscure pattern you have not learnt in your outdated compsci degree
- Each loop should get their own function
- Your function has too many parameters
- You must name every instance of magic numbers / strings
- Here, have another obscure test case to write9 -
As a beginner at programming, I've never really appreciated or understood the point of a simple for loop until I've had to use an if/else loop 200 times2
-
Me *looking at the project* : it won't be difficult, it's going to be piece of cake.
Me *really reads more about it* : maybe it's not what I thought
Me *now doubting myself* : Google has all the answers
Me : runs to Google for something as simple as a while loop😩.1 -
HELP ME I used to conduct Java interviews for junior dev candidates, but since changing jobs three years ago, I've barely had to look at Java at all, and now I've forgotten everything.
Am I stuck in a never-ending loop of learning and relearning everything over and over again for eternity???8 -
The biggest problem I see with current state of AI is the feedback loop it creates in people.
For example, some (usually older people in higher positions) perceive long emails as a sign of courtesy, involvement, and hard work. As a result, others have started using AI to write longer emails for them, to get on "the good side" with their higher ups. And now that many use AI to generate longer emails, those same higher ups got used to it and started to perceive short, straight-to-the-point emails as "rude". So even more people are looking into using AI to generate longer emails as they don't want to seem rude. At that rate it's not long until those that rely on AI to write "better" (== longer) emails get promoted over some hard working person who simply doesn't care to write long emails.
Even though AI didn't do anything, it somehow still "trained" people to start using it and even rely on it, and it even indirectly rewards people who use it for completely meaningless and seemingly unrelated tasks. And in a few years, whatever comes out of this will be used to train the next generations of AI, creating even more of a feedback loop that people will be completely unaware of until it eventually crashes onto itself. Because that loop can't be observed in the AI itself, it has to be observed in the people.4 -
Silly mistakes while coding, fuck!!
I wrote a loop:
for(i=0; s[i]!='0'; ++i){
//Code
}
and thinking what's going wrong🤔
.
.
.
After sometime I realized my '\' wasn't pressed 😢😶
And after that:
SILLY ME 😁😁 is only thought in mind....5 -
So I inherited this buggy application my company developed to process state rosters for health care. The daily process fails often and I haven’t been able to figure out why. Then I notice one little thing... it’s essentially using SQL injection as a method of updating records from a file that we receive from outside... there’s no checking for validity of the statements or making sure they’re safe to execute. Just a for in loop and calling a sp to execute the query text under elevated permissions.
-
Going back to a php project after writing loads of typescript on a node stack, I suddenly miss the instantanious feedback loop on file save via `nodemon` for basic scripts and `mocha --watch --reporter min` for tests.
Using phpunit, I currently have to rerun the test manually whenever I feel like. Which now feels so annoying. Cause I didn't know besser.
Now I was searching for something similar in php and I find answers[1] pointing me to use either set up some npm hooks or set up gulp task or to use pywatch. phpstorm also is supposed to support file watchers and run test on every save, yet setting them up feels clunky.
[1] http://stackoverflow.com/questions/...1 -
When you take over some shitty unindented, fucked up variable naming, using a god damn loop for every fucking thing ass dev's fucking project
-
Implementing a for loop in js because I need to skip some elements in a map as I transform. I'm feeling dirty
* cries in functional *4 -
I'm now caught in an infinite loop on this project. The tests all pass but the identical code on an identical Live environment won't work. The API vendor is saying it's our code's fault and they won't support us. The developer is ignoring my pleas for assistance because the client won't pay for more of his time as they consider this warranty work even though we warned them that this was a one-of-a-kind custom job with a risk of failure.1
-
I worked 2012-2016 for a big telco company in my country and there was this HTTPS webpage with an iframe rendering any url you passed over the ?url query param plus a header with the company's logo.
I was on a meeting with some friends in charge of social media and they found it for a user report.
Unbelievable 🤷🏻♂️ I remember I tried the page's url itself and it rendered a loop of the header with the company's logo 😂 -
Why is vectorization library faster than hand-written for loops ? I mean, somewhere down the line, the matrices/vectors must be multiplied (or any other operation) and thus be one-by-one (for loop??) calculated and stored.
Why is it then faster to use these libraries than just manually writing for loops all over the place ?
I guess some low level magic (OpenBLAS ?) goes on there but I just don't see it..
P.S. [Would have posted it on stack overflow but I'd be ripped apart so I'm pioneering new ways]8 -
(defn rant []
(go
(let [feature-pool (atom [:ui-fixes])]
(loop []
(<! wait-for-release-week)
(->>
shit-load-of-features
(reset! feature-pool)
develop-features
ask-for-feature-status
deploy-in-last-minute
find-a-bug-and-rollback release
(recur))))
(rant)13 -
When you spend ages making a really nice for loop for handling multiple classes similar functionality, only to have it all messed up by one overloaded method1
-
Curious to see if anyone else is in this situation: I somehow have become the “infrastructure upgrade guy”. I’m in this constant loop of retrofitting our applications to work with the latest Windows Version or Java Middleware. Or, I’m stuck porting apps from one middleware to another. I guess I got good at this, and now I’m stuck in this constant loop of being the “go to” for all system upgrades/ports, which seem to just be in this endless cycle. It gets me a lot of recognition, but the work is miserable. Anyone else experience something like this, and if so, how did you get out?2
-
I've got Linux 3DS working now, but I have a size limit of 60MB for my zImage. Is there a way to mount a file via loop as, say, the root directory, so the image in RAM is unloaded and it executes from SD/NAND? If not, anything similar?
-
Searching syntax of for loop every time I use it for a language I have been using for the last 5 years is normal.
-
Had to do the FizzBuzz test in PHP. Proceeded to creat a range(1, 100) before the for loop instead of using the loops own index #. Worst part is I realized what I had done in the parking lot after I left. They asked me multiple times how I could optimize the code too lol.
-
A contains() function for a class to check if there was something in a list. I did not know about the if a in list_b python feature, so I resorted in a loop and a bunch of if/elses.
Efficiency = 01 -
aaargggggghh, some fucker thought its clever to allocate memory in a tight loop..and do a switch/case in it as well. the size and branch taken was known beforehand -.-
preallocating and thinking about the code for a second is really hard for some ppls brains it seems.. -
Resharper - it makes writing .net code so much more easier and shows you how to rewrite loop.
Everything else VS code - right now it's the new hot thing for me to write ruby, python and JavaScript.1 -
Was rushed to write a crappy massmailing for super urgent newsletter, had to be finished in 20 minutes. Last 5 minutes i had to rewrite half of it. Told them its rushed, testet and crappy.
Mailed the stuff anyway. Every Email got the same dynamic string in subject.
Looked at code, was setting the subject 2 lines above the loop.
Sorry guys, dont rush me next time2 -
This SocketIO method emits a message to all users who have joined the same room (conversation ID).
This works if it's a 1-to-1 chat or a group chat with infinite users in the group.
The thing that bothers me is this enhanced for loop. It loops through ALL currently connected users.
- If theres 10 users, sure no big deal
- if theres 1000 users, it has to loop 1000 times
- for N users it loops N times
What if N = 10000? God what if it's 100,000 or 1,000,000.
Imagine having to loop that many times every time you want to send just 1 message.
OR wait i just realized. This shit grabs ALL users -- but within the room ID. Right? Am i trippin balls here
Im now confused (excuse my confusion i coded till 3am last night and im still fried). Is my logic flawed? Have i written this piece of code with good performance or not?38 -
At what point can you say you are experienced in x language?
I am consistently looking up function definitions and ... how to... for languages I worked with for years.
I'm not talking like 'how do I loop through data from a database' but something like 'which param goes where for this function'
Curious
Friend is wondering if he is a copy/paste dev... :/6 -
I'm learning Rust as a case study for my own programming language. It's funny how many approaches exist to the humble loop.
- In classic procedural languages, a loop's job is to repeat actions, and as such it provides a multitude of tools to control this repetition.
- In all languages with iterators, a for-in loop is a construct that does something with every element of a collection. In languages with both iterators and generator functions, this can even be used to define a sequence in terms of another.
- In Rust, a loop is an expression that obtains its value through repeated execution. It can also be used like a classic loop, of course, but this is the interesting part.
- My little language is a functional language, so "loop" is the Y combinator. To loop means to define the value of an expression in terms of itself. It's the only looping construct, gets special treatment from the type checker and it's also used in recursive type definitions. -
That moment you find out that python is very sloppy when it comes to scopes. It seems that variables declared in loops are callable in function scopes. So this code actually does not give any errors:
for i in range(6):
print i
print(“out of loop scope”, i)
Now I’m just like: WTF! That can cause some serious errors when you’re not aware of this thing. I don’t know any other language that has this property...4 -
Have you tried to look up documentation for some module and find another module that better does it? and this loop continues...
-
In my school, We started learning computer science (Java and programming stuff, to be more specific) last year in 11th standard (I was 16 at that time), starting to learn programming and stuff like this are common in India at that age (Yes, I live in India). I m the only student in my class or in my school who knows about programming and things related to that, yes of course I know, I made my own game when I was around 12 y.o.
In school our teacher started teaching us everything from the most beginning, It was really boring and exciting at the same time for me, it was exciting because I always wanted to tell my teacher and friends about my game and other programming kinds of stuff I knew, and it was boring bcoz I had to learn those things again which I already knew.
It was obvious that I was getting good marks in the subject without even reading my book for once, and it really amazed my friends, classmates and even my teacher.
Now, since my friends have learned CS for 1 year, some of them thinks its nice and are fascinated by the world of programming and developers, and some of them think it's boring and they just need to pass the subject for good marks and nothing else.
It feels funny and bad at the same time when some of my friends come to me and ask what does a for-loop (any loop) even does... And the rest of them thinks a for-loop is just used for printing tables of numbers.
well, that's the story of my school.
The thing that will never change is that I love programming and I will never stop programming...
Thanks for stopping by Ranters,
Happy programming!4 -
I kinda miss the do while loop. It seems it fell out of style, compared to a for each or a while. I always feel a bit guilty when IntelliJ tries to autocomplete the do while loop and you just want a variable that starts with do.2
-
How’s school going?
Well I’m in discrete mathematics and summations honestly suck, but if you put it in a for loop it’s so easy6 -
when you used to functional programming, every time you see a for loop, you can not resiste but to refactorit.
-
Disclaimer: the project I'm about to mention contains the first lines of Go I have ever written.
Still, I'm quite proud of how quickly I got it working considering it's also my first time working with GTK.
This project that I've been working on the past few days is finally done. But it's %50 percent spaghetti, so refactoring time. I decided to have a look at my cyclomatic complexity numbers, and my biggest function (not main()) had it at 7.
As it was quite large, I split it up into to parts: the preparation and the actual timer loop. As I appear to need to use a goroutine, by the time I'm done passing channels and all hell to handle them, my loop function now has a score of 9 for cyclomatic complexity.
So fix one bug, leaves two in its place?
But I still need to better learn Go, anyone have a good (relatively painless, informative, quick-ish) course they can recommend? I've been thinking of trying out codecademy's one...6 -
Putting my draw_char routine in a for loop breaks everything... Doesn't when I just sequentially call it... Only when called from a for loop...
-
I'm still a beginner for programming, I got the basics (for JavaScript) down but I don't really know how or where to use it, like loops(for, do while), return, and stuff like that.
Going through the books and online exercises they just make you do the basics like loop a number 10 times to print out 0-9 or something like that. And the return keyword I usually forget about because I've never been told how I can actually use it for something.
I want to learn how I can use all of these and when I can use them, is there any books, videos, or courses I can look into? I'm sorry, this is probably a Sinbad question but I am just trying to get as much help as I can2 -
I had network problems.. and you know.. no shit.. the problem solve thing which might actually be just a for loop solved it.2
-
Just wondering on some agile best practices. Do you guys estimate efforts for defects? My PO is totally against it and says we deliver 5 to 7 pointers user stories + fix all the defects from previous sprint and current sprint, which I feel is over burdening the Dev team + in hurry to complete current sprint stories delivering poor quality work, which in turn become defects in the next sprint 😨 caught in this loop for a while now 😫4
-
I've got a question about PHP arrays as I try to update my coding skills.
The problem I'm trying to solve is converting one vendor's CSV format to another vendor's format for a daily processing job.
I have a multi-row CSV file (number of rows changes daily but fields (15) do not). My PHP converts it to an array with fgetcsv so I can then copy its rows and data to a different blank target array with the same number of rows as the source array, but a different field order and number of fields (55) than the source array.
From here I will apply certain conditional business rules to copy data, field-by-field, from the source array fields to the target array fields, then output the target array to a CSV.
I'm stuck trying to figure out how to create (initialize) that target array so that it exists when I loop through the source array and copy values over to the target array.
Can anyone nudge me in the right direction on how to dynamically (loop?) create that multi-dimensional target array of n rows and 55 columns? I looked at http://w3schools.com/php/... for guidance but can't figure out how to structure the loop to make just one array of n rows and 55 columns, and not "n" arrays of n rows and 55 columns.5 -
I’ve abandoned the classic for loop from my tool belt for quite a long time now. The vast majority of the code is functional.
But today I’ve encountered a problem where I’m considering to use the imperative for loop again because I can’t come up with a good functional approach.
Maybe you guys have an idea.
I have a list of items and I want to make a new list which is like the original list, but it has extra items in between of some other items.
The tricky part is that there is a condition that needs to be checked for each pair of items to determine if the new item should be inserted in between. Otherwise nothing should be inserted.61 -
So I have an array of length 20 which stores a 64 bit decimal number by digits. The starting address is let's say array64. When I am trying to build up my number in ECX:EBX, I am using EDX as the iterator to access the individual elements of the array (I am loading them into AL)
.LOOP:
....
MOV AL, [array64+EDX]
INC EDX
....
JMP .LOOP
The problem is: somehow EDX cannot get higher than 10, so the program just stops and waits for input, when I try to work with a 12 digit number...
This module is outside the main function, and I thought about some Far Pointer problems, but all of my ideas just failed...
What is wrong here?1 -
So I start up the Windows Upgrade Assistant to upgrade my Windows 10 to the anniversary edition and it shows me that I'm running version 10240 and I can upgrade to the latest version 14xxx.
So I hit upgrade now, wait for 10 minutes for the update to be downloaded and another 10 minutes for the update to be installed. Then it does the customary reboot after update.
So now I assume that I'm running the anniversary edition of Windows 10 but it shows that I'm still running 10240.
WTF was the upgrade assistant doing in those 20 odd minutes. And now it does it in an infinite loop. Is Microsoft trying to explain me what an Infinite loop looks like practically.2 -
I have just learnt that you can label for statements and break them in an inside loop
Wakanda crazy crap is this?
fyi here is an example:```js
outerLoop:for(let i = 0; i<5; i++){
for(let j=0; j<5; j++){
console.log(i*j);
if(i*j === 8) { break outerLoop;}
}
}
```
Why do we even set a label with a colon, why?6 -
There's nothing quite like an app force closing for no apparent reason, and no error log info.
Just spent an hour figuring out that one of the device I test on doesn't like linking GLSL shader programs if it contains a loop even know every other devices I've tested on are totally fine with it. 😑 -
So here I am, in a summer course for IMM introduced in JavaScript. I knew I wasn't going to be a fan of the insane junk it does. I just didn't expect to see it IMMEDIETLY.
var size = 1;
#ps5.js draw loop
size += 1;
print(size);1 -
I started to learn coding at school using RM Basic. I made a script with an infinite loop using goto that flashed the screen different colours and said error on it. I left it running. Found out later the it guy took the computer away for "repair"...
-
I just discover a new way to achieve infinite loop today: https://github.com/necolas/...
I can't wait for 2019 and react-native-web-mobilr1 -
Please look at this code, I wanna know why the $ and {} was added to the alert method to pop up the key and value of user.
what is their functionality there?
let user = {
name: "John",
age: 30
};
// loop over keys-and-values
for (let [key, value] of Object.entries(user)) {
alert(`${key}:${value}`); // name:John, then age:30
}4 -
Spent most of the day at work debugging a script which imports client data from their old system into our system. Someone made a change to a for loop which was looping through a period length by days, doing whatever it needed to do for each day. Unfortunately they changed the increment value from 1 day to 86400 days... probably thinking they were dealing with seconds not days. A day well spent.1
-
So In Malaysian app named MySejatera (fyi, mysejahtera is a covid tracking app) has been comprommised! hahahha someone run a while loop GET Request (yes they use GET request for sending otp, wtf) of the script to send OTP to random user found in the database , hahahahaha
https://astroawani.com/berita-malay...3 -
Hello there, long time no see.
Back in the day I asked you for a book that goes deep in the C programming language, now I'm asking the same but for Nodejs, especially a book that explains the event loop down to the line of code.
There are some articles on the internet but they are all copy/paste of one another and don't even scratch the surface of what the event loop does2 -
A v dumb C language question....
Consider this code snippet:
{
while( getchar() != EOF )
printf("a");
while( getchar() != EOF )
printf("b");
}
Is there some way to get inside the second loop? After I input some text, ctrl+D sends in the text stream and loop 1 executes, then the control waits at the test for loop 1 again, pressing ctrl+D again triggers EOF, but it ends up skipping all loops after24 -
Growing list of asks to a team member that are unheeded:
1) Check in your code frequently
2) Stop the completion emails for your program
3) Stop using your personal UserID/Password to send said email
4) Create classes that do one thing
5) Reuse your database connections
6) Use DataTables and write to the database once and not a bunch of variables and write at the end of your crazy loop-if-else structures. -
So it's been a long semester and I was writing my final project earlier today. I wrote a for loop which removed objects from the list it was iterating through. And my linter let me. Why do I even use you, pylint? I could have saved hours of debugging if you gave me a message that I was doing a stupid thing5
-
Had a new assignment(in liberty basic) in my computer studies course:
Ask user for the name of their favourite cartoon character. Then have the name move across the terminal screen with a once second delay.
So I spent about 30 minutes trying to find some sort of delay function in liberty basic. Finally I stopped using a for loop and instead move that code into a subroutine and tried to use the timer to run it every second.
Didn’t work.
So I finally gave in and asked the teacher. He explains for loops to me(after thoroughly investigating my keyboard(which is the same as his) for the cap locks key) and then use a incrementing for loop to 500000 as the delay. Next he told me that it felt like a second and he left.
Later he checked up on me making sure I understood. -
A friend is working on a game for his graduation project and he asked me for help fixing a rather tricky bug.
After a good hour and a half I admitted defeat and wrapped his entire game loop in a try-catch. It works flawlessly.4 -
Just spent 30 minutes trying to work out how to do my dev terminals rendering in it's main for loop...
Only now just realised I should probably use 2 seperate for loops and rendering layers for the background and text... Well done dickhead -
Of course a good, long playlist of my personal jams with a beer next to me :)
But reasons to actually get to work:
1. If it's an interesting task and everything goes according to plan, I get a positive feedback loop of motivation.
2. Deadlines.
3. Personal projects are always easier for me to begin with and stay focused on.
Personal projects are also dangerous for me because I keep going back to them until I don't have any motivation to go back to my work projects... Kinda like a double edged sword I guess -
What are my odds that V8 will recognize my efforts and convert my for loop to use SIMD? It literally just adds the elements of a Float32Array to another, it's the single best chance for compiler optimizations to shine.4
-
How do u get out of this constant loop of mental anguish u get stuck in? What do u do when it's just too much for u and ure just too much for everyone else?12
-
Can anyone help me in jquery?
I'm doing a loop of trigger which are 13 in count, but every trigger event contains ajax call and what my problem is that it doesn't wait for ajax response and keep hitting trigger until last trigger fires.
so I'm having my ajax response only on last one.
What can I do for this?9 -
This is the sequel to my previous rant, if you don't know about it, go check my profile.
So, for some reason, when I opened YouTube Vanced, I am trapped into a loop of loading animation. And I thought "Hmm... Maybe my Internet sucks, let's try again.".
Then I switched my Internet on and off, go back to YouTube Vanced, the same loading animation loop.
Then I do switching the Internet for about 30 minutes, go back to YouTube Vanced, no progression.
Then I thought "What about YouTube?", I open Youtube, and you know what, YouTube loads it PERFECTLY. The loading animation takes longer than usual, but at the end, it still loads my recommendation and anything!
I thought "Wait, do they have an update?", then I go to Vanced Manager, and no, there is no new update for both Vanced and Vanced microG. There is a new update for Vanced Manager, though.
I decided to report a bug, but then I realized that the problem I am facing is too ambiguous for the developer to fix, so I decided not to do it.
So yeah, now I am sticking with YouTube, since I cannot find a solution better than it, and if you ask me, YouTube Vanced is still trapped in the loading animation loop.3 -
Three days ago:
Found my eOS had crashed. Got on my dad's spare Dell Latitude (by God, the keyboard is awesome) and downloaded an image file for Ubuntu.
Fast Forward to today morning :
Apparently, my dad never did down either of his laptops, or even lock. The Latitude had a update but it then started reverting it. It went into a loop.
My dad: what did you do?! It was working perfectly before, you must have crashed it.
What the fuck dad... Thankfully, he got it up and running later.3 -
Reading the source of a message queue system I'm planning on extending.
I don't see myself as a rockstar programmer or anything but the construction of arrays from hash tables, sorting those arrays and then a nested for loop to find matches really irks me. Luckily not on the critical message processing path but the stats collection thread. There are mutexes in play though that would probably delay processing a little bit when stats are collected. -
I was running a for loop about primary number finder then i forgot my laptop at home.
3 days later i fired my home and i'm a homeless now.1 -
I almost managed to build a ReactJS based CMS, but I still need to check online if my for loop will actually display four elements.
-
I really don't get how every, single, mobile developer, position practically requires you to be a top developer on the Google PlayStore. Because if you're not you're "too junior".
It's like none of these companies understand that just because I don't already know your tech in and out and don't have 1mill+ downloads on my apps doesn't mean I can't rise to the challenge.
Been on the hunt for 2 years now, and have been put through the interview loop more than I can count with me never getting past the first round interview.4 -
I been out of the Java loop for a while and now I read about all this licensing and version horseshit... What the fuck? Are they purposely killing their own product? This is exactly what python, node, go, etc need to achieve absolute dominance.4
-
Who else is frustrated/burnout at building products that never gets into production?
When I work for a company I always tend to do everything with good practices, spend a lot of time thinking on the best ways to build x feature, and then the company falls into the infinite loop of adding stupid features, and then I've been working for 2 years and 0 paid customers. Funny that we've Sentry, GA, Hotjar sitting there doing nothing.
I'm honestly hating the startup environment rn. Good thing is that I've learnt a lot and salary is good. But also I lost all motivation.
Any recommendations for a tired dev?7 -
Instagram "personal brand revolving code" checklist:
1. Quirky Hello World captions
2. Always has a mug of coffee
3. Code in background (usually HTML) with a pop open terminal showing the file directory to show that they know how to use the command line.
4. quirky pseudocode (usually a while loop) on there shirt.
5. Starting aimlessly on a laptop in places that don't make sense to work.
Seriously, Instagram is the worst place to have your personal brand for stuff like this. -
there it goes again
rip my college access, i'm in an infinite loop of this and can't break out
i have to wait for the server to deauth me on its end, should take 48 hours or so2 -
tabs spaces oses languages what about using I instead of counter or index as a variable for for loop2
-
I just want to be able to concentrate on writing code for at least 3 hours without power failures,
my brain is stuck in a debugging loop and my PC is off
this country is fucked up, the herdsmen might as well come for my head -
Be me.
Writing a java class for uni work, that'll eventually run on android.
I get kicks from making functions work using as few steps as possible, using minimal code.
Explain to someone how I'm doing it.
I learn that loops and the rest of it generate more code and take longer than unwrapping the loop and writing every case manually.
Shit ffs I spend hours making my code more concise :(
Then, I'm told the recursive method I'm using for checking for a win is too complicated, that I shouldn't start looking for a win from the last counter I placed, but should scan the WHOLE board for a win in every angle.
Eat my food, open my beer, pet my dog, trundle off back to work. -
First time using ACF pro for WordPress and client told me he wants to put markers on a single map. I then made a repeater field that requires the use to enter longitude and latitude and then loop through it to display all the markers. I'm stupid enough to not see the Google Maps field for ACF pro.
I should read more often. -
MySejahtera is not a good appliaction at all! They just use Sqlite or Shared Preferences in the app for keeping the data local. (Just local?) As soon as you clear cache or data, The user no longer exist! Like wtf ?
So I decompile the app and review the source code, the code is not even properly obfuscated(That's why I can read it). There's a part of the code on a for loop went
```
for (int i = 3; i < array.length(); i++)
{
for (int j = 2; i > array.length() *2; j ++ )
{
onScan();
}
}
```
Which is unacceptable!
First , why nested for loops?
Second, instead of declare 'array.length()' multiple times why not declared it global for once?
No wonder the initial state of the app is buggy as hell.8 -
I wonder if anyone else realizes how stupid it is to loop years around for fear of arbitrary artifical consequences designed to just keep people as land bound surfs.
seriously.
everyone travels
everyone fucks
or wants to.
and people fall down sometimes
doesn't mean you have to invent a system that drags them back through years of history to get that 60k job all over again !!!
also next year means take the calendar year and add one assholes !8 -
Legacy code in java :
boolean recursiveMethod(args){
Int i= 0;
Boolean doublon = false;
For(--whatever the loop--){
If(condition1 && condition2){
If(i++ > 0){
doublon=true;
Return doublon;
}
}
}
[...]
}5 -
If anyone is good with dart (or) other single threaded programming languages, i have this small doubt about the inner workings of the event loop and such and i would like an explanation if possible.
If you're too lazy to goto the link:
1. I have a future returned from a http request.
2. a future.then is declared that prints the http result.
3. A separate while(true) loop is declared that runs forever that just prints natural numbers.
4. the while loop also has an await future.delay that waits for 1ms before continuing with the next iteration
My question :
1. There's only one thread so how does the http download code run WHILE my main loop is still executing.
2. my future.then event is not processed unless i await a future.delay separately for 1ms. returning control to the event loop ? i don't get it how does adding an event help it process a prior event? It's FIFO ?
gist :https://gist.github.com/TheAnimatri...
discussion:
https://groups.google.com/a/...5 -
To most non-dev people, being hit with error after error when fixing one small problem out of a much bigger collection of problems would probably be infuriating.
To me, it's a huge loop of:
for(var failsAtLine = 1; failsAtLine < lines.length; failsAtLine++;) {
changeSomething();
runTest();
readErrors();
cry();
comtemplateMeaningOfLife();
}
openChampagne();
Would help if deployer.org had better documentation and bigger support community. -
I've noticed that on the web view of devRant, the notification counter updates in real time.
So I opened up the Inspect Element and checked for any polling related code (Socket.io) or something.
What I found was that this endpoint is called on a loop -> https://devrant.com/api/devrant/...
And the response format contains ->
{
"success": true,
"rants": [],
"settings": {
"notif_state": -1,
"notif_token": ""
},
"set": "64d68f5a7acd4",
"wrw": 376,
"dpp": 0,
"num_notifs": 0,
"unread": {
"total": 0
}
}
I assume `num_notifs` is the notification counter.
So, my question is is this practice good for implementing real time notifications?3 -
Yesterday I spent hours searching for obscure references on where some function evaluates because my loop didn't work. After lunch I realized I used the same variable name twice, changed that, everything worked....2
-
I was put into pair programming for writing code in BASIC in my 5th grade. I did all the exercises while my pair simply watched. It was simply natural to me, and a bug in code helped me to print my name in a infinite loop. Amazed with what computers can do, and my story with computer and software development started there.
-
worst mistake was probably introducing an infinite loop in the category tree for e-commerce site...
in the vein of true agile and considering MVPs and what not we had not yet automated everything. the client would send category updates as a spreadsheet and i had a script to generate the sql and jam it into the site. having run the script several times in the past I thought I'd just throw the update into production and call it a weekend...
it wasn't long before I started fielding calls that the site was unstable. no page would load and the server kept crashing under trivial load. well an entire frantic weekend later I discovered the category load hit an edge case I hadn't considered and I had introduced an infinite loop in the navigation of the site.
i'd like to say I learned my lesson and never just threw changes into production again, but what can I say - I like living on the edge. I did however learn that loop detection can be a valuable thibg -
When i try to make a infinity loop code like this:
for(int i=5:i<=3;i++)
{
Console.WriteLine(i);
}
and i forgot to save the project.
"OMFG!!!! WHY THE FK R U DO THIS! :'("8 -
Trying to add the loop function in my programming language, and for some reason it doesn't work, more specifically, it runs once and then stop, or it runs once and then trapped in a loop. So tired of this.2
-
Not finding what I want via google so I'll ask here: What's the deal with opengles android shaders freezing my phone's screen?
Is it normal unavoidable behaviour for a shader with an infinite loop to fuck up the visual output irreversibly (until phone restart)? -
What's the best tool to convert vid to HTML5 (Mp4 + WebM + Ogv) and keep good ratio between Size & Quality ?
I have a 1min lenght vid in FullHD. This is a demo reel that loop in fullscreen at the first website launch.
I tried Miro converter, Freemake and can't reduce files under 15Mb without obtain poor vid quality. It's seems too heavy for a website.
Do you have any tips ? A tool to convert vids, an online service to upload the vid and use it instead of using HTML5 video tag.
Thanks20 -
I am wondering how phone operator company can make such thing go on production for live users? Seems like dev has used three times for loop when balance is checked 😐
-
The time I can get a while loop to not crash the tab/application when I'm testing it for the first time will be the happiest moment of my life.1
-
Pff today I start 400 threads in python initialized in a for loop, one thread per record, each record initialize a heavy process, Memory Limit Exceeded, I'm frustrated with this shit!
How to run 400 records doing a heavy task preventing the CPU to close the task executed by timeout limit exceeded, or how to run multiple threads to end before reach timeout limit each task without exceeding the memory limit.
☠💩🐱💻9 -
Anybody know how I could make an RxJS observable without RxJS?
I'm working on a library and I need it to be small (So including RxJS isn't really viable), run in the browser (IDK if Browserify will work for RxJS), and be fast. I need a way for a given element to 'listen' (or in RxJS terms, 'subscribe') to a value and update its text content whenever the value changes.
My current implementation is just a interval loop that checks if the previous value is the same as the current one, and if it isn't, it modifies the DOM.6 -
So my win10 PC with everything I have on it just got trapped in a boot loop, because I tried to start a VM.
No backup, no rescue DVD, noone here that could help me but myself.
Well I guess that is what I deserve for trying to try out a Linux system.
Luckily my project deadline is 3h away, so I have still time to fix this mess and start working.
Wish me luck guys.4 -
Just something I've been thinking on for a while:
How could programming be done if we couldn't use ordinary if-statements (but functional set operations such as map, filter, with an if- in the lambda function etc. is alright).
Could it work? Also would it be possible to reduce the amount of while loops by using functions for most of the "loop situations" as well?4 -
How could one write a parser for BNF without causing and infinite loop in the following case:
Something ::= AnotherThing|Something
?6 -
1. New Job/ New project
2. Learns new language/framework
3. Works for a month or so
4. Priorities change
5. endlessly loop from 1 to 4
What do you mean one-page-resume?1 -
A while ago when I was making some EF extension functions. I was trying to make a bulk update function that used a parallel for-loop and I wanted it to accept funcs as a parameter.
Took me a while to figure out that a func and an expression are 2 different things, but when I did, oh boy did a fun world open up. -
How do I go into tokenizing strings of text from a LaTeX file into a Go structure for further processing? I feel like splitting hair trying for loop over an io.Reader and using regexp to find where a sentence ends; there must be a better way...2
-
What's the correct way to do an iterator in a for loop?
Some teachers tells me that every iterator be named like line and row and other says i and j are the convention and you should name your iterator like that.8 -
I don't really like the way how JavaScript does a foreach loop. Either you have to use the "for in" loop, or you have to use the "Array.prototype.forEach" function which opens a new scope.2
-
When underscore.js is embedded so hard in your muscle memory that you use return to continue a for loop because you're used to _.each()
-
so.
i had a stupid idea that'd let me do a project i had planned and abandoned a while back after getting experience with the new project.
problem: detect and manage empty space in a massive file, allow adding data to those empty spaces from files, and fill in a table in a designated empty space with where dynamically-loaded things are. In Python.
I tried JUST detecting empty space, and Python would break out of loops for no reason at all just at random. "run bottom to top through this file until a non-00h byte is found" would either break out of the loop way earlier than should be possible (8 or 9 bytes into a 32KB empty file) or run way into non-zerofill areas before breaking the loop.
Am I just retarded? Is this more Python conditional fuckery? i'm so lost that it's just on hold for now (and i think i lost that script too) -
Ever regretted leaving a job after quitting it for a while, only to remember all the shit you had to go through to them think that it was an amazing decision to leave.
Imagine this loop happening every few months. It's amazing how stupid your brain can be eh.
Share your stories of a nightmare job but now you are living a life with living. -
Writing the general memory allocator for my hobby os. It's kludgy, but it works.
I add a single for-loop that executes well after that.
The frame allocator can't initialize.
fml -
Disclaimer: I am a beginner and I used node just because my employer asked me to.
I needed to create 1400 random users for a platform and I needed to get all the usernames and passwords in a json file and my idea was to just add the object to other collection with all the creditals(passwords are hashed in the db so I couldnt just loop them). For some reason it wouldn't work (i am really bad with async functions) and I just threw the table and copy pasted it from the error screen.
this_shit = {[name1,pass1],[name2,pass2]...}
throw this_shit;
Worked like a charm ^_^ -
!rant but want to know this
how does facebook parse the json like
for(;;);{"key":"value"}
that for loop prevents anyone to read json but how does facebook get away with it? -
Annoying monday - nearly no code but useless things like trying to use a Windows keyboard on some old MacOS X
On the other hand: for the first time I wrote a one line for loop in bash that worked - without googling!1 -
!Rant
I think I am going overboard with Java streams and my fellow programmers will hate me. I have not written a loop for... a month? My code is starting to be extremely semantically dense. -
hello i'm trying to do a loop to all of our users account and see if they have already a partner or pair but the problem is after 2 user, the loop just stops and won't loop to all user accounts that's available. Please don't leave me hanging or leaving comments with no solution just like stack overflow.
<?php
$sqlo = mysqli_query($conn, "SELECT `username` FROM users");
$i=1;
$counter = array();
while ($h=mysqli_fetch_assoc($sqlo)) {
$counter[$i] = $h['username'];
$i++;
}
for($i = 1; $i <= Fixed_count($counter); $i++){
$b = $counter[$i];
$query1 = mysqli_query($conn2, "select * from `$b` where username='$newuser'");
$query2 = mysqli_query($conn2, "select * from `$b` where `status`='yes'");
$user1 = array();
$user2 = array();
while($result = mysqli_fetch_array($query1)){
$user1['username'] = $result['username'];
$user1['status'] = $result['status'];
/*more user info*/
while($result2 = mysqli_fetch_array($query2)){
$user2['username'] = $result2['username'];
$user2['status'] = $result2['status'];
/*more user info*/
if($temp_counter < 4){
if($user1['username'] != $user2['username'] && $user1['status'] == "yes" && $user2['status'] == "yes"){
if(/*more condition*/){
/*if condition's are met execute process*/
echo "Success!";
continue 2;
}
}else{
continue 2;
}
}
}
}
}
echo "Loop stopped at user: ".$i;
?>7