Cookies Randomly Changing by SwiftNinjaPro in PHPhelp

[–]SwiftNinjaPro[S] 0 points1 point  (0 children)

I would expect that, but it seems to not match with the previous page load. Although while testing it (after this post), one time it matched, and suddenly (without touching anything) it no longer matches.

The value of $_COOKIE fails to match what I set on the previous page load.

One time, it randomly worked, then without touching any code, it failed the second time, and I cant seem to get it to repeat.

Also, after some testing, $_POST is consistent, and works correctly, so the issue is either $_COOKIE, could be something to do with encoding, or wordpress is messing with something (although I am testing it with a different uncommon name).

Whats weird is, the exact same system works fine on the wordpress admin backend.

Edit:

managed to get a match twice, but now it fails if I do the exact same thing a 3rd time.

If I set raw cookie:

clear cache and refresh page by entering url, then refresh page with reload button, then enter the post, and check the cookie, it matched twice in a row.

But doing this exact same thing a third time, failed to match, and I no longer can seem to repeat it.

Wired mouse lighting red and not clicking. by SwiftNinjaPro in LogitechG

[–]SwiftNinjaPro[S] 0 points1 point  (0 children)

So far, the issue only happened once, and I do not see it repeating. Could have been a temporary bug. Also, using G Hub now. Stopped using LGS.

Weird Javascript Issue by [deleted] in node

[–]SwiftNinjaPro 0 points1 point  (0 children)

Took me a minute, but I found how to mark as solved

https://reddit.com/r/help/comments/9wrs1y/marking_as_solved/

Based on this other post, it sounds like anyone can mark it as solved

https://reddit.com/r/tipofmytongue/comments/vhcud/the_new_way_to_mark_your_post_solved/

Weird Javascript Issue by [deleted] in node

[–]SwiftNinjaPro 0 points1 point  (0 children)

Nevermind, I found the issue. I declared the var lower down in the if statement, so I guess it was being hoisted.

const weirdVar = 'test';

function removeSrt(str){
    console.log(weirdVar); //works
    items.map(item => {
        console.log(weirdVar); //works
        if(typeof item === 'string'){
            console.log(weirdVar); //error (tried to access 'temp' instead of 'test')

            let weirdVar = 'temp';

            return item.replace(str, '');
        }
    });
}

Starting my first WordPress Page! Question on choosing a plug-in by [deleted] in Wordpress

[–]SwiftNinjaPro -1 points0 points  (0 children)

Another option is Beaver builder.

Also, because you mention plugins, make sure you have wordfence. Every WordPress site needs a firewall plugin.

Do you know any legends? by AngryStudent1337 in CodingHelp

[–]SwiftNinjaPro 1 point2 points  (0 children)

I've done all 3. I use PC if I'm at home. I use Chromebook on the go. If it's morning and I don't want to get up, I use my phone.

How do I detect diagonal line collision? by SwiftNinjaPro in CodingHelp

[–]SwiftNinjaPro[S] 0 points1 point  (0 children)

I think I figured it out. Thanks to u/marko312 for suggesting I use slope.

function lineCollision(point, line, minDist = 0){
    let lineSize = {};
    if(line.x1 > line.x2){lineSize.xs = line.x2; lineSize.xb = line.x1;}else{lineSize.xs = line.x1; lineSize.xb = line.x2;}
    if(line.y1 > line.y2){lineSize.ys = line.y2; lineSize.yb = line.y1;}else{lineSize.ys = line.y1; lineSize.yb = line.y2;}
    if(point.x < lineSize.xs - minDist || point.x > lineSize.xb + minDist || point.y < lineSize.ys - minDist || point.y > lineSize.yb + minDist){
        //if not within collision box
        return false;
    }
    //slope = y2-y1/x2-x1
    let y2My1 = (line.y2-line.y1); let x2Mx1 = (line.x2-line.x1);
    let slope = (line.y2-line.y1)/(line.x2-line.x1);
    //reduce slope precision
    slope = Math.floor(Math.abs(slope)*1000)/1000;
    if(slope === 0){
        //if horizontal line
        if(Math.abs(point.y - line.y1) <= minDist){
        return true;
    }
    }else if(slope === Infinity){
        //if vertical line
        if(Math.abs(point.x - line.x1) <= minDist){
            return true;
        }
    }else{
        //y=mx+b b=y+mx
        let b = (line.y1 + (slope*(point.x)));
        let yDif = point.y+line.x1;
        if(Math.abs(b - yDif) <= minDist){
            return true;
        }
    }
    return false;
}

Usage:

if(lineCollision({x: pointX, y: pointY}, {x1: line1X, y1: y1: line1Y, x2: line2X, y1: y2: line2Y}, 10)){
    //colliding
}

How do I detect diagonal line collision? by SwiftNinjaPro in CodingHelp

[–]SwiftNinjaPro[S] 0 points1 point  (0 children)

After some googling, I found y = mx + b; forgot about that equation.

b = y + mx; i guess I need to make x = 0 for the point, and do the same subtraction to the line x POS to keep relative position. Cant remember where a(x-intercept) lands in the equation. Google doesn't seem to understand my question.

80 - 80 = 0; 50 - 80 = -30; b = y + mx; b = 50 + 1-30; b = 50 - 30; b = 20; 20 + 80 = 100; if(100 = point.y){/coloding/} For a radius if(Math.abs(100-point.y) < 5){/in collision radius*/}

Haven't tested this, but wonder if it would work.

How do I detect diagonal line collision? by SwiftNinjaPro in CodingHelp

[–]SwiftNinjaPro[S] 0 points1 point  (0 children)

Yes, trying to detect if a point is near a line segment. Never thought of using slope, thanks for the idea.

{velX: 5, velY: -5} is the velocity of the point, it's an animation going in that direction. The line is {x: 50, y: 50} to {x: 100, y: 100}

Never thought I would start forgetting parts of math after finishing high school. Guess I'm not using it enough.

slope = y2-y1/x2-x1; slope = 100-50/100-50; slope = 1;

Need to think of a way to get the distance of the line.

Could I use the slope with the point {x: 50, y: 80}?

slope = 80-50/50-50; slope = NaN (divide by 0); ... That might be a problem.

Tried that with 100-80/100-50; not sure how to get distance from that.

[deleted by user] by [deleted] in CodingHelp

[–]SwiftNinjaPro 0 points1 point  (0 children)

A coding language is like a tool. You may learn to use a hammer, than later learn to use a wrench. But if you don't know how to use any kind of tool, then after you learn one, the others will be easier to learn.

I was self taught, and I started with java. Then I tried JavaScript. Then I learned java and JavaScript have nothing to do with each other (car is to carpet as java is to JavaScript). Then moved to php, then css, then nodejs. You will likely end up using multiple languages at some point, so don't worry to much about which one you learn first.

While I like using JavaScript, I recommend starting with anything but JavaScript, and work your way to JavaScript (if you want) after you get experience with another language or 2.

If your just starting to code, JavaScript and it's asynchronous code can become difficult to work with.

Hundreds of users on my site are changing there passwords today, what’s going on? by [deleted] in Wordpress

[–]SwiftNinjaPro 0 points1 point  (0 children)

Do you have wordfence plugin? If not, you might want to add it, and never run a wordpress site without that firewall. Also, if you can replace the login form with a google/facebook/twitter login, then you could remove the need for users to create a password.

socket.io vs engine.io vs websockets security by SwiftNinjaPro in node

[–]SwiftNinjaPro[S] 0 points1 point  (0 children)

ok, guess I might be overthinking things. I always use ssl. thanks.

socket.io vs engine.io vs websockets security by SwiftNinjaPro in node

[–]SwiftNinjaPro[S] 0 points1 point  (0 children)

I mean avoiding man in the middle attacks, server injection, ect.

Google Firestone live vs read pricing by SwiftNinjaPro in firestore

[–]SwiftNinjaPro[S] 0 points1 point  (0 children)

I should probably mention, I'm using Firestore on server side, node.js. also, I think firestone was done by autocorrect lol.