« first day (3547 days earlier)      last day (1384 days later) » 

12:53 AM
does anyone have any idea about the typescript/webpack issue from above? Been working on it for a while and I am at a loss
 
1:12 AM
@Lapys my best guess, look here: github.com/nodejs/node/tree/master/deps/v8/src
down in "Using the "include" and "exclude" properties" is that the answer?
 
1:58 AM
@ASPtech Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. You have 25 seconds to edit and format your message properly before it will be removed. 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
 
    let vtv = Number(this.getField("VehicleTradeValue").valueAsString);

    function adjustVTV(val, separator = ',', every = 3){
      let vtv = +val.replace(/,/g, ''), n;
      if(vtv < 5999){
        vtv *= 2;
      }
      else if(vtv < 9000){
        vtv *= 1.75;
      }
      else if(vtv < 11000){
        vtv *= 1.5;
      }
      else if(vtv < 12000){
        vtv *= 1.4;
      }
      else if(vtv < 13000){
        vtv *= 1.35;
      }
      else if(vtv < 14000){
        vtv *= 1.3;
      }
 
@ASPtech Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. You have 25 seconds to edit and format your message properly before it will be removed. 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
 
2:50 AM
@ASPtech If you mean ExtendScript, it is a relatively old JS version and does not support new featuers like let.
@Lapys It depends on the engine. The later was advised for some versions of old V8, because per-allocating it would result in a sparse array as you fill in it, contrast with a uniform array when you push-as-you-go. But it's old information (don't know how it goes now) and is an implementation detail that will absolutely change with time.
 
 
2 hours later…
4:47 AM
@Lapys There is usually no real need to use new Array under normal circumstances. In fact, I'd advise never using the constructor. The most relevant thing for you is that new Array(50) doesn't mean much. It's an empty array with 50 open slots but slots for what? Strings? Numbers? Booleans? You won't get a pre-allocated array for your data type. In some cases you do get a large chunk of memory for the array in that case but it's still meaningless overall.
If you need to create an array and fill it with stuff use the built-in array methods - they are likely to be better optimised by the engine. arr.map(x => x+1) or arr.filter(x => x.startsWith("hello") ) etc. If you want to create an entirely new array, then Array.from({length: 50}, () =>Math.random() * 10) for example.
|| mdn Array.from
 
5:06 AM
Note: unless you need the random number, the random calls are likely to be much more costy than the array allocation.
Also: why pre-allocating array in V8 makes them sparse ("holey" in v8 speak):
https://v8.dev/blog/elements-kinds
But, unless it has an impact on a hot code you are optimising, please do whatever make sense to the code, not whatever is faster this moment.
Because JS have too many implementation details like these to count. Not suprising when you have three, four families of wide spread implementions.
 
6:02 AM
Quick question: Can you think about how to check if a number is a positive integer in JavaScript. I know how I'd do it myself, so this isn't something I want a suggestion is, just spend a moment thinking about the task.
...Good, now that you've thought about it I wonder how many of you decided on "I'll use a library that only checks for positive integers and has 2 dependencies in order to work. Bonus fact - check the dependencies - one is deprecated. Bonus fact 2 - the other one isn't...but its build is failing. Remember the only thing the library does is check if a number is a positive integer
As for my solution: Number.isInteger(x) && x >= 0. Unless you want strictly positive, I guess.
 
 
1 hour later…
7:07 AM
Hey anyone here?
I want to push array of objects into array and get back array of objects again and not array with a key that has array of objects as values.
 
||> arr1 = [{id:1}, {id:2}]; arr2 = [{id: 3}, {id:4}]; arr1.push(...arr2); arr1
 
@VLAZ [{"id":1},{"id":2},{"id":3},{"id":4}] Logged: `` Took: 0ms
 
||> arr1 = [{id:1}, {id:2}]; arr2 = [{id: 3}, {id:4}]; arr3 = arr1.concat(arr2); arr3
 
@VLAZ [{"id":1},{"id":2},{"id":3},{"id":4}] Logged: `` Took: 1ms
 
@thodwris ^
 
7:12 AM
That's great! Thank you!
 
 
1 hour later…
8:28 AM
@Simone Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. You have 25 seconds to edit and format your message properly before it will be removed. 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
@Simone 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.
1 message moved to Trash can
@Simone Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. You have 25 seconds to edit and format your message properly before it will be removed. 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
 
9:28 AM
@VLAZ for purity, you have to check if it's below max safe integer as well
also - imho - if you need a lib for that simple question, you don't deserve to be a developer
 
@KarelG That's if it matters. Sometimes it doesn't and you're happy with any integer, even unsafe ones. And honestly, most of the time you'd be restricting the min and max anyway because you may want a number between 1 and 100, for example.
 
i have a tools for that intValueIsWithin(val, minIncl, maxIncl)
 
 
2 hours later…
11:04 AM
Hi All
im trying to write a lookup query in mongodb
i have three table
TableA
TableB
TableC
below is my sample schema which replicates the actual collection
TableA {
 "_id" : ObjectId("5ef088da38c2d23cdc0ad609"),
"name":"TableA",
"TableB_Id":ObjectId("5ef5cf36a4be440012d263d6")
}

TableB {
 "_id" : ObjectId("5ef088da38c2d23cdc0ad422"),
"netWeight":"10.00",
"TableC_Id":ObjectId("4ef2cd36a4be440012d224a9")
}

TableC{
"_id":ObjectId("5efd90016fe2690012081512"),
"creationName":"First Creation"
}
TableA will have TableB Id
TableB will have TableC Id
as kinda foreignKeys im looking to do left join keeping TableA as the parent collection
 
yes i have written the lookup query for TableA and TableB
but not finiding anything of how i can do a lookup between TableB and TableC in the same query
db.getCollection('TableA').aggregate(
  [{
        $lookup:{
            from: 'TableB',
            localField:'TableB_Id',
            foreignField:'_id',
            as :'Creations'
        }
   }])
this is what i mean, and it works as expected. But now i have a ObjectId in TableB which refers to TableC and i should show up that data as well.
just wanted to know is this approach possible?
 
11:22 AM
sorry my mongo knowledge is limited perhaps another could help
 
12:20 PM
I'm running into so many problems with jest and typescript - so many open questions at stackoverflow right now :(
 
12:32 PM
What's the use of a Subject in Rxjs when you don't create an Observable from it, but just subscribe to the subject?
 
@KarelG this helps in query the second collection with a condition. Don't think it would help in doing the same for getting from the third collection
 
12:45 PM
it's applying the same logic :>
 
12:55 PM
@KarelG yes, but i have an array of Id's for the reference of the third table
below is my actual question if someone can just guide me with some approach
0
Q: Lookup on Multiple tables in MongoDb

Sam SamBelow is my MongoDb collection data. db={ "User_Promo_Map": [ { "_id": ObjectId("5e93fea52f804ab99b12e7c0"), "amount": "25", "promoId": ObjectId("5e93fea52f804ab99b12e7c0") } ], "Promo": [ { "_id": ObjectId("5e93fea52f804ab99b12e7c0"), "disrotion": "...

 
 
1 hour later…
2:20 PM
intriguing, there is a link on reddit that leads me to journaltimes.com and I get a 451, "Unavailable due to legal reasons" followed with GPDR lala
 
@KarelG 451 - the error with which the server burns.
 
I do like the right use of the status code though
 
> Acknowledgements

Thanks to Terence Eden, who observed that the existing status code
403 was not really suitable for this situation, and suggested the
creation of a new status code.

Thanks also to Ray Bradbury.
 
you don't say?
 
It's not like people haven't made their own status codes before. I think I remember hearing of 451 but it wasn't standardised yet.
 
 
1 hour later…
3:53 PM
@DavidKamer nope, tried every combo but couldnt get it: Here's more information
I have a monorepo setup with lerna. I have a /server /frontend and /common package. The /common package doesn't have a tsconfig because it only contains common types and doesn't need to be compiled. Importing like this creates the error:
import {ParticipantRole} from "@bitlink/common/enum/ParticipantRole";
../common/enum/ParticipantRole.ts 1:7
Module parse failed: Unexpected token (1:7)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See webpack.js.org/concepts#loaders
> export enum ParticipantRole {
|     HOST, // one host per room
|     MANAGER, // can do everything a host can do except create/remove other managers
I seems to only be an issue when importing into /frontend as /server has no problems
Anyone got any ideas?
 
4:20 PM
3
Q: Create React App + Typescript In monorepo code sharing

BrandonMI currently have a monorepo where I have two (+) packages using yarn workspaces: root /packages /common /web ... root/package.json ... "workspaces": { "packages": [ "packages/*" ], "nohoist": [ "**" ], }, web is a plain create-react-app with the ...

 
Do we not have a good duplicate target for cases like this, where const x = 1; f(); function f(x){ console.log(x); } overshadows x because no argument was passed? If not, I’ll write an answer (and edit the question into shape).
 
@user4642212 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.
 
@user4642212 On second thought… this question is too messy for a canonical with its asynchronous Node libraries and misplaced function call that was supposed to be put inside a callback.
 
@user4642212 Uh, we do have a bunch of questions on that. They are annoying to find, though, so I usually link to "what's the scope of variables in JavaScript"
 
5:06 PM
sigh
I don't get it. Why doesn't it just work
 
because it's not a bethesda product
 
its not working how i want it to work but its working now
i have to build the common package everytime i change it
 
6:03 PM
Hi, I m trying https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications
 
@VisheshMangla 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.
 
from developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/… but it's giving ` Firefox can’t establish a connection to the server at wss://www.example.com/socketserver `.
wow your rules are quite crisp and straight to the point. I really liked the presentation unlike the Python channel here.
 
uh
www.example.com was just an example
 
do you mean I need to setup the backend socket too?
 
yep
 
6:08 PM
Yes - socket is two-way. You have to connect to something.
 
that will take another one hour but ok thanks for the help
but I haven't seen website with wss//
 
wss is the websocket protocol
 
I m a django/python user . Can you suggest some guide?
 
search django/python websocket
 
ok
wow, thanks for the node script
 
6:11 PM
It should be very easy to set up. It's usually just 1. include WebSocket library 2. initialise it (like setting the port to listen to) 3. run the server. 4. connect to the socket.
So, if you set the server to listen on port 12345 you have to connect to wss://localhost:12345
const http = require('http');
const static = require('node-static');
const file = new static.Server('./');
const server = http.createServer((req, res) => {
  req.addListener('end', () => file.serve(req, res)).resume();
});
const port = 3210;
server.listen(port, () => console.log(`Server running at localhost:${port}`));
This is the implementation in JavaScript for a server. Taken from here
 
thanks for the link @VLAZ
 
Full disclosure, I searched for "set up websocket backend javascript". Looked at the first couple of links and this seemed straight forward enough. There might be better resources there but this one should be OK.
 
I just need a start so that I can get a rough sketch of this working , then django channels will be good to go.
 
6:37 PM
it's 2020, why is it such a pain in the ass to transfer pictures to people in full quality
 
Lol, @JBis
We have more of a need to transfer pictures in general than retaining their full quality
 
i'm gonna create a website for this
 
Usually, being able to send the full quality comes at a the cost of subscribing or paying some arbitrary price
 
really simple, and probably been done before
 
You sure the thousands of people who will use the full quality image-sharing service won't slow down whatever server you're using?
 
6:44 PM
if thousands of people use it then i'll monetize it, until then it'll be for me and my fam
 
I mean, there is a reason why file compression is a thing when it comes to the web
 
what is that reason
 
@JBis Then you'll become one of those services you have to pay for or subscribe to
@KevinB The less data there is to send/ receive over a network the "faster" resources are transferred over networks
 
show me a paid service designed specifically for photo sharing
 
photobucket
 
6:46 PM
theres file sharing services but they aren't great
 
@KevinB Minifying script files and compressing media files
@JBis Lol
 
ok fair enough
 
Google Photos, maybe?
 
well i have a server and it wont cost me anything besides my time so i'm gonna role my own
Google Photos compresses im pretty sure
 
Google Drive, then?
 
6:48 PM
most photo services remove meta data too
GDrive compresses and its built for files not photos
and you need an account
 
compresses?
i don't think it does, at least not the source file. obviously it makes thumbnails
 
Fair enough. GDrive doesn't compress source but its built for files not photos
and its designed as a storage service not a sharing service
 
photos are files
 
@JBis Welp, if anything it's a good idea to roll your own solutions and see if that works out for you
 
But they are special files
 
6:50 PM
You sound like a young YouTube: "Share videos on the internet with your friends & families"
@JBis, what about imgur?
 
imgur def compressses and removes metadata
 
Pinterest?
 
more of a social media and they compress
everyone compresses except file sharing platforms like GDrive
but they aren't made for photo sharing
 
Aww... Alright
Now that I think about, all the 4K images I've downloaded have come from "private"-owned websites
 
7:32 PM
Removing metadata from images is pretty much standard nowadays. Used to be...not standard. Lots of data leaked due to it, since taking a picture with your phone timestamps it, embeds the geolocation, probably also your name and other information...
 
 
2 hours later…
9:42 PM
hi
 
@AnotherOne 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.
 

« first day (3547 days earlier)      last day (1384 days later) »