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 - "setinterval"
-
Write a small js function using setInterval to fire a request every second ... then copy paste the code 450 times (literally, not an exaggeration) into a massive file to create a load test script.
This load test script also had no means to gather metrics or test response times or anything useful. It was literally a “did the server crash” test.9 -
a litte piece of javascript pinging the server every minute to prevent user being logged out
$(document).ready(function() {
setInterval(ping, 60000);
});6 -
Try this line of javascript in a browser:
<pre id=p><script>n=setInterval("for(n+=7,i=k,P='p.\\n';i-=1/k;P+=P[i%2?(i%2*j-j+n/k^j)&1:2])j=k/i;p.innerHTML=P",k=64)</script>8 -
I just found this bit of code in our product :P
setInterval(function () {
$("body").find("div, td").replaceText("oldProductName", "newProductName" );
}, 50);10 -
var i = 0;
setInterval(function(){
document.getElementById("el").style.width = i + "px";
i+=10;
},100);
And, children, this is how we were used to create animations years ago7 -
Ah, the internal struggle.
Half an hour of debugging to find out why my code wasn't being called multiple times inside setInterval().
Only to realised that I was using setTimeout() instead of setInterval().
This is what depression and tiredness does to people. -
setInterval(() => {throw new Error("April fools!"}, 100);
Time to make the front end team hate me.4 -
var dayInMyLife = function(data) {
var checkDevRant = setInterval(function() { openDevRant(); }, Math.random()*10000),
workday = (data.day.toLowerCase() == 'saturday' || data.day.toLowerCase() == 'sunday' || data.holiday == true) ? false : true;
if (workday) {
var schedule = {
'wakeup': '06:45',
'travelToWork': {
'time': '07:10',
'method': 'walking'
},
'lunch': '11.00',
'travelToHome': {
'time': '15:30',
'method': 'walking'
}
};
while (atWork) {
keepZeroInbox();
beAmongDinosaurs();
if (checkForProjects()) {
doProject();
};
while (noisyCoworkers) {
useNoiseCancellationHeadset();
};
};
spendPreciousFreeTimeWithFamily();
enterSleepMode();
}
}
var today = dayInMyLife({'day': 'monday', 'holiday': false});1 -
Code for Matrix Rain Using HTML
<!DOCTYPE html>
<html>
<head>
<title>Matrix Rain</title>
<style>
* {margin: 0; padding: 0;}
body {background: black;}
canvas {display: block;}
</style>
</head>
<body>
<canvas id="c"></canvas>
</body>
<script>
var c = document.getElementById("c");
var ctx = c.getContext("2d");
//making the canvas full screen
c.height = window.innerHeight;
c.width = window.innerWidth;
//english characters
var english = "1001010101110101010101010010101000101011101111010101010110101010101010101110000101";
//converting the string into an array of single characters
english = english.split("");
var font_size = 15;
var columns = c.width/font_size; //number of columns for the rain
//an array of drops - one per column
var drops = [];
//x below is the x coordinate
//1 = y co-ordinate of the drop(same for every drop initially)
for(var x = 0; x < columns; x++)
drops[x] = 1;
//drawing the characters
function draw()
{
//Black BG for the canvas
//translucent BG to show trail
ctx.fillStyle = "rgba(0, 0, 0, 0.05)";
ctx.fillRect(0, 0, c.width, c.height);
ctx.fillStyle = "#0F0"; //green text
ctx.font = font_size + "px arial";
//looping over drops
for(var i = 0; i < drops.length; i++)
{
//a random chinese character to print
var text = english[Math.floor(Math.random()*english.length)];
//x = i*font_size, y = value of drops[i]*font_size
ctx.fillText(text, i*font_size, drops[i]*font_size);
//sending the drop back to the top randomly after it has crossed the screen
//adding a randomness to the reset to make the drops scattered on the Y axis
if(drops[i]*font_size > c.height && Math.random() > 0.975)
drops[i] = 0;
//incrementing Y coordinate
drops[i]++;
}
}
setInterval(draw, 33);
</script>
<body>
</html>1 -
So todays issue. Working with slideshow functionality with jQuery and setInterval() and things seem to be working as expected.
That is.. until you leave the page for awhile and come back and see a constant fading of images because the intervals appear to be "catching up" with themselves xD
Luckily, setTimeout() takes care of this issue nicely.1 -
Why are hooks so awful?
What justifies having everyone using React relearn how to do things when hooks do not bring any new features to React?
Why does getting setInterval to work with hooks require a ~3000 word blog post by a maintainer which constantly assures you this IS a step forward?
Is scrolling up and down a class component really so hard that this clusterfuck is worth it?
>:(6 -
Every once in a while I'm the stupid one at work. Was wondering why my Google Chart tooltips flickered on hover. Found some bug and a workaround on SO but it kept happening. Then I noticed the container div kept refreshing and I couldn't explain why. Until I commented all my code and by systematically enabling it line by line I noticed my dumb ass used setInterval instead of setTimeout. Well yes if you keep redrawing the chart it is going to flicker! *facepalm*
-
Could somebody please help me understand why the fucking hell does JS (I am talking about node.js, so backend) use 32bit integers in setTimeout and setInterval? I mean, I understand most of the choices regarding the language (I have chosen programming languages design and principles for my studies) and I am happily using it for almost 4 years. But I came across an occasion that I had to use big numbers in those functions and it took me a lot of time to figure out why the fuck my code was not working as it was supposed to.
If anyone has a good reason please elaborate. In the meantime I'll go punch some shit to calm down.10 -
So I was looking for some real-time dashboard app using vue, tried searching for it on google and found some article.
He lost me at setInterval.8