« first day (3387 days earlier)      last day (1544 days later) » 

user8729657
1:17 AM
Does strcpy() exist in js?
 
2:18 AM
@OvieTrix No, why would you need it?
 
 
1 hour later…
3:25 AM
hi guys
How can I update an object with another object and remove rows from the 2nd object that doesn't have any matching keys with the first object
example: obj1 = { a: 'test1', b: 'test1', c: 'test1' }
obj2 = { b: 'test2', c: 'test2', d: 'test2' }

How can I update obj1 with the value on obj2 without adding the extra key which is d, I only wanted to have the value of b and c in obj2 to be in obj1
 
4:09 AM
Hi All
function sampleCode1(first, second) {
    console.log(first + second);
};

function sampleCode2(third, fourth) {
    console.log(third + fourth);
};


module.exports = {sampleCode1 : sampleCode1, sampleCode2: sampleCode2};
below is my sample code where im having multiple functions and i want to export them all
the above code works fine, but what i want to do is, i dont want to individually pass an object, rather i want to export the entire content in the file
this is in javascript
i know in typescript i can create a class and wrap things up in the class and then export the class
but how do i do that in javascript.
 
 
1 hour later…
5:32 AM
ok so i know i'm being stupid and missing something really simple
but...
<!DOCTYPE html>
<html>
    <head>
        <meta charset='utf-8'>
        <title>Example</title>
    </head>
    <body>
        <script>
            <svg width='250' height='250'>
                <rect x='50' y='50' width='20' height='20'></rect>
            </svg>
        </script>
    </body>
</html>
is giving me "SyntaxError: expected expression, got '<'"
for line 9 (the line that begins <svg ...)
this must just be me being tired or something dumb, because this usually is a pretty straight forward error
but i don't know wtf it's talking about :l
 
USM
5:51 AM
Boring day
 
6:11 AM
can anyone help me with this
0
Q: UnhandledPromiseRejectionWarning: function not found while exporting a typescript file

Sam SamI have created a ts file in a node api and exporting that. Below is the code of myClass.ts file class myClass{ firstFunction(firstParam, secondParam) { return firstParam + secondParam }; } module.exports.myClass = myClass; there is one js file which is index.js Below is th...

 
6:29 AM
Hi
i have lot of js css files include in multiple html files.I wana to add version
when I change then any files
Like this
my_script.js?versoin1001
my_style.css?version1001

Manualy process is very difficult. is any way to add version automaticaly when change the files.

Because My big issue is that when i change the file every time clear the cache then files loaded.
We do need to cache clear new fiels loaded automaticaly without cache.

so i need versioning
Files will be load automatically wihtout cache clear
 
7:16 AM
?
 
@AmagicalFishy you don't put html elements in <script> tags but JavaScript statememts.
<svg is HTML. Move it outside the <script> tag
 
@KarelG ?
 
@RaheelAslam there have been numerous articles on this topic. It depends of the server framework you use. Look for "http filtering" and look for .js or .css to automatically add versions to it
 
@KarelG my all files in js and css not any php.
 
IIS has a most convenient approach I've encountered so far. It is only some config settings
@RaheelAslam you still need to serve it to end users. That's done with a server.
 
7:30 AM
hmm can be done in .httacess can you guide on that?
from server only change file will be update version or all ?
 
googling htaccess auto-versioning should give you useful results.
like this one
965
Q: How to force the browser to reload cached CSS/JS files?

KipI have noticed that some browsers (in particular, Firefox and Opera) are very zealous in using cached copies of .css and .js files, even between browser sessions. This leads to a problem when you update one of these files but the user's browser keeps on using the cached copy. The question is: wh...

I just have a global version identifier and use in code ?version=#{VERSION}
 
7:46 AM
@KarelG but all files with .html extension not php
 
7:56 AM
I´m receiving a HTTP request from an SAP CPI service, but I´m unable to indentifiy how exactly the request is build. It should be send via body, but req.body is always undefined. I already tried different bodyParser options (text/json), but with no success. The console.log(req); is NOT empty, but the body that should be send seems not to be there. What options do I have (from the receiving site) to determine how i can read the body?
also i cannot find any information on the internet that fits to my issue
 
8:15 AM
@elsololobo the headers should contain information of what's the request could be
 
8:31 AM
thanks for the advice. Content-type in headers is empty, "transfer-encoding": "chunked", "user-agent": "AHC/1.0", "accept": "*/*". Apart from that there seems nothing to be that could help
 
no content length?
you have to contact the company/person behind that service if those headers are not informative. Sure, you can use wireshark or trace the request but that's an additional work.
they should be informative with their requests
 
no content-length
guess you have never worked with any SAP service :) It´s always the same ... thanks for your help, i will create a ticket
 
8:55 AM
@elsololobo does not matter, if you send a request, use appropriate headers. Those devs are just lazy and is using default values
I had even ticketed a mailing service to put appropriate headers. They have a choice: spend 10 minutes to correct it or don't expect to use the services my company is offering. I have a strict policy for external partners.
they were complaining that their requests got rejected
 
i wish i had much influence like you in mine. We always have such problems with SAP in different area´s, but it´s just accepted and SAP get more consulting money...
 
if(condition){}
does JS internally use eval for the condition ?
to test for true
 
9:11 AM
what do you mean with "use eval"
but I think that the answer you are looking for is "boolean coercion". JavaScript has a "truthy" and "falsy" concept. Each object can be truthy or falsy.
you only have to remember this table here Those values in the table are false when being in if (condition). All other values are true.
 
for exporting a file / module and importing it using require any specific module needs to be installed in node?
it is in relevance to the question that i post
0
Q: UnhandledPromiseRejectionWarning: function not found while exporting a typescript file

Sam SamI have created a ts file in a node api and exporting that. Below is the code of myClass.ts file class myClass{ firstFunction(firstParam, secondParam) { return firstParam + secondParam }; } module.exports.myClass = myClass; there is one js file which is index.js Below is th...

 
@PremRamman No, modern JS engines don't use eval internally, and no amount of chat can do justice to their complexity. In other words, how they works internally is well beyond what many can understand or imagine, without actually learning it.
 
Are you talking about module.exports and require, or import/export?
 
@BenFortune
myClass = {

    firstFunction(firstParam, secondParam) {
        return firstParam + secondParam
    };
}

module.exports = myClass;
the file name is also myClass.ts
im using this in another file called index.js
 
you have returned a class instance as export?
 
9:18 AM
Everything Is Object! Prototype Inheritance Rules!
 
best to step back and do some research on what modules are and how you can import/export these
 
const myClass = require("./myPath");

myFunction(){
myClass.firstFunction("ff","ss")
}
 
> modern JS engines don't use eval internally
*cough*
it does
/walks-away
 
:48416618 i have tried doing that as well like below

module.exports = new myClass();
 
@KarelG Let's just keep it understandable...
 
9:20 AM
also i have tried
module.exports.myClass = myClass;
 
> I'm just going to try a bunch of stuff until it works instead of learning the basics
yeet
 
class myClass{
    constructor() { }

    firstFunction(firstParam, secondParam) {
        return firstParam + secondParam
    };
}

module.exports = myClass;
this also i tried.
 
everything return the below exception
**UnhandledPromiseRejectionWarning: TypeError: myClass.firstFunction is not a function**
but when i do it like this, it works
let myClass = {

    firstFunction(firstParam, secondParam) {
        return firstParam + secondParam
    };
}

module.exports = myClass;
the above code works
 
but sheepy, you missed my comment about boolean coercion after that. I MADE IT SIMPLE
 
9:22 AM
That's just an object with a method, not a typical class
 
Well, if it works, good. Just be aware that we usually call that an object, rather than a class.
 
Yes indeed, that y the question, do i need to install some module to make this work, or there is some issue with the code?
i majorly get this exception
UnhandledPromiseRejectionWarning: TypeError: myClass.firstFunction is not a function
 
Just to re-learn how js class works, do some exercises, and you should be good.
 
9:59 AM
my issue fixed
i reRan the babel
n its working now.
 
 
1 hour later…
11:13 AM
i have one little question about the type annotation in typescript
i have already insrtalled
@types/node
but still when i create parameters in my function with types like below
myFunction(first:any, second: string, third: number) {
}
im getting this exception
SyntaxError: Unexpected token ':'
at Module._compile (internal/modules/cjs/loader.js:891:18)
 
11:59 AM
Sounds like you're trying to run typescript with node, it needs to be transpiled with tsc or another bundler
 
12:18 PM
Hey I need some help with velocity emulation
I have this little if statement which determines when you hold down right, it will speed up right (but I also added a feature that if your holding right while its traveling left, it will continue left (for reasons)
is there a way to copy this effect to the opposite velocity (the left arrow key)
this is the main statement:
 if (Math.sign(vx) == -1) {
  vx += -5;
 } else {
  vx += 5;
 }
that is the Right movement statement (upgraded)
Old left statement:
function bounceLeft() {
 vx -= 1;
}
 
use a physics lib XD
 
The only reasons I make it so holding right also allows left movement, is because if you hold right, it just glitches the ball into a corner, it looks disgusting
No JBis, its a physics engine I built myself in canvas
Doesnt look half bad either: codepen.io/SkylerSpark/pen/jOOZBgL
Control with arrow keys btw
Perhaps I should just removed the left key movement (since right key now controls ALL forms of velocity (except y dimension), it wouldnt make sense to have a left mirrored movement function :P
 
You are prob going to need some physics equations
So whats the issue? Right now the right and left keys increase the velocity on the x only. You may want to add a bit of velocity on the y also. Makes it more of a kick instead of a push.
 
Kick? why would I want a kick... You can use the Up arrow to jump
Hmm Ill try it out and see how it looks
 
@TaylorS I would think you just inverse the direction.
 
12:27 PM
yeah I just inverted the direction, and now there are only 2 controls, up and right, right controls velocity x, up controls velocity y
 
But great job on basic bouncing and gravity. Physics engines are very complicated and being able to replicate that aspect is pretty neat!
 
and I HAD to invert the y velocity to make the "bouncing" work correctly, because what happens is the ball reverses (multiplies by -1) its y velocity when it hits the roof or floor
making it "bounce"
while the gravity and factor variables slow it down
factor is like friction
 
also watch out when someone hits the down arrow. it goes a bit crazy.
 
Yeah I fixed that, turns out when I made this this months ago, I made a stupid function that adds 500 velocity to everything
.-.
Me being me I guess
Making a ball in a cube is easy in canvas, the tricky part is adding "objects" that it can bounce off of inside the canvas
which of course I still havent figured out
:P
 
For that you need to make collision detection which is a pain in the ass
 
12:34 PM
Thats one of the few times I would say: just use a library
like matter.js or something
 
I'm not sure how you would mix your code with a library.
 
I wouldnt
my little basic "fake physics" emulation isnt even really compatible with anything, it was just me trying to play around with things
luckily, if you keep an array of the X and Y of all your shapes, a basic Square on Square physics test wouldnt be difficult
think about it, detect if x1/y1 through x2/y2 of square one is anywhere inside of the x1/y1 through x2/y2 of square two
then push it out
the complex part is Arcs/Circles/Triangles/Rotations, all the jazz
 
that's physics :P
 
I havent taken any physics classes (except basic 6-9th grade science
:P
Hmm, I could always be cringey and make a square by square physics engine, like a 2d Minecraft physics engine where the player HAS to move exactly 1 square forward or backwards
that would be boring though
otherwise I dont know how to make anything else
only text-physics and simple ball in a canvas physics... thats it :P
 
well it doesn't have to obey the laws of physics, it just has to look like it does
 
12:48 PM
codepen.io/SkylerSpark/pen/zYxbvJW I just figured out how to make 3D transformed objects... and seeing a 3D iframe is kinda satisfying
Well if it only looks like it does, then it does
So in a way, it obeys it anyways :D
Because, in canvas, or just in web, theres a backend and a frontend, that frontend is like our real world, the backend being the unsightable energies
 
that said, the quickest way to produce something that behaves like the laws of physics is to look at some formulas
 
fyi those "physics engine" are just simulating the physics. Those aren't accurate. There is no one. The most accurate one I've encountered is KSP
but it is still not representative enough
 
Blender's physics is pretty damn accurate from what I have seen.
 
1:06 PM
@Sheepy Thanks thats what my understanding is also, just wanted to confirm as one of my colleague was debating over this
 
 
1 hour later…
2:14 PM
@zadders Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it. For posting large code blocks, use a paste site like like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
1 message moved to Trash can
 
oops
idk how to format code here
Hey guys, So I have the following PUT Method with the json body so:
fetch(BASE_API_URL,{
method:'PUT',
headers:{
'Accept':'application/json',
'Content-Type':'application/json'
},
body:JSON.stringify({

Id: event.target.Id.value,
firstName: event.target.firstName.value,
lastName: event.target.lastName.value,
Email: event.target.Email.value,
mobileNumber: event.target.mobileNumber.value,
dateOfBirth: event.target.dateOfBirth.value,
lastModified: event.target.lastModified.value,
})
})
I was wondering how I could make lastModified get the current Date instead of targetting the value of lastModified. I want to it to automatically detect the current date
 
new Date() ?
 
for some reason that didn't work at first, but it's working now all the sudden :D
probably my code didn't recompile properly
 
I have a table with more rows than can be displayed in the window at once, and it's set inside a scrollable div. How can I set the height of the div to be the same size as what the window will currently allow, given that there is also a header and footer on the page? I don't want the page itself stretched to the point where it needs its own scroll bar.
 
2:58 PM
yo guys, I'm using a bootstrap type="date" form control
                                <Form.Control name="dateOfBirth" required type="date" defaultValue = {this.props.dateofbirth} placeholder="Date of Birth e.g. 05-02-97" />
is there a way I can make the form have a preloaded date?
because I have a date stored in the database, but when it loads the date picker, it always has a dd-mm-yy format set
like it resets to the initial input
which means I have to re-put the date in every time I re-edit a user
 
is there no way to set its value?
 
I mean, I've put the defaultValue which did that for every other type of field
but for some reason its not doing it with the type="date"
 
so make defaultValue be the current value or lacking that, this.props.dateofbirth
assuming there's not like a value field or something
 
thats what it is, {this.props.dateofbirth} carries a DateTime format of the date
so it should be currently set
 
3:23 PM
hmm, ok.. I wouldn't have assumed "defaultValue" to hold a format
 
 
1 hour later…
4:24 PM
if the code implementing your input is taking control of defaultValue, you'll have to find a way to overcome or prevent that.
 
 
1 hour later…
5:32 PM
 
6:17 PM
Wait
 
@Nadelvorhang Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
I miss clicked
 
7:00 PM
Welcome
 
7:52 PM
I've been using Vue for a while now but I STILL can't figure out how to use .vue files. I can sort of get transpiling to work in a fresh, empty project. But if I try to set it up in a big, preexisting project it just fails.
 
8:16 PM
?
 
user8729657
8:49 PM
This guy is the luckiest guy ever. nytimes.com/2020/01/23/us/…
 
right, because being treated that way is lucky
 
user8729657
Happens everyday day, but he's lucky to be compensated for it.
 
9:25 PM
should be a lesson to all the people who refuse to comply with the cops
this guy got wronged and did everything he's supposed and got compensated
if he had started yelling or something it could have ended up much worse
 
10:12 PM
wow, someone should have let him know that it's illegal to deposit money into a savings account if you're black
could've saved him the trouble
 
user8729657
10:42 PM
lol
 
user8729657
@forresthopkinsa, you remind me of Eminem the rapper :)
2
 
that's my secret cap
I am Eminem the rapper
 
11:03 PM
Anyone ever make game assets in photoshop?
 
11:16 PM
Probably
 
any suggestions? its taking forever
 
I didn't mean me, but I'm sure someone has
apologies for being unhelpful lol
why are you using photoshop for that
that sounds like a job for Illustrator
 
its supposed to be pixel "art"
pretty sure thats easier in ps
Meh. I'm giving up on phaser and moving to a GUI tool.
 
11:34 PM
pixel art? ehh you probably shouldn't be using either of these programs for that
 
what program would you suggest?
 
find something that's made for your application
I don't know the answer but I know that PS and AI are both the wrong tools for that job
 
alright
 

« first day (3387 days earlier)      last day (1544 days later) »