« first day (3863 days earlier)      last day (1068 days later) » 

1:28 PM
I'm kind of impressed, that - with that level of knowledge - someone was able to set up an electron app at all (or modify it). Also shocked... makes you wonder how many apps out there are from people who don't know programming basics, which in general also implies they don't know anything about security either.
 
1:38 PM
@Loktar sounds great :) Happy you're doing well - congrats on the new job and the graduation probably feeling very proud. Son is great, just a lot of work.
 
1:49 PM
@Loktar also in the future you're welcome to ping me on FB (I go by my name) or via email (benjamingr@gmail) if that's more convenient.
 
2:00 PM
@BenjaminGruenbaum Will do in the future (would be more convenient for sure
 
2:11 PM
This chat is very nostalgic though ^^
 
2:43 PM
Any Angular expert here?
I just need a small tip
 
no expert
 
I have an angular app that uses the "ngx-translate" to switch between different languages.
Now, the client has hired a team for SEO.
I've included the angular universal for server-side rendering.
The meta tags are written down using the default language that is selected.
The question is, how the search engine can detect multiple languages in the app?
If I update the meta tags when the user switches the language, will that work?
 
if meta tags are the only thing dieciding what language gets displayed, i'm not sure the crawlers will pick up on it
usually it's done using the url
/en-US/some/path/etc
 
Runtime language change isn't supported?
 
i mean
runtime language change isn't relevant to crawlers
 
2:49 PM
So there should be multiple versions of the app?
 
not necessarily
/en-US/ in the path can be easily used in your backend to set the meta tag your client-app is expecting, all going to the same index
 
If I had a brain, I would be dangerous I swear
I completely forgot about the DataTable render function so I was able to format the Date displayed in the DataTable in my column definitions like so
{
                    "data": "Date",
                    render: function(data, type, row){
                if(type === "sort" || type === "type"){
                    return data;
                }
                return moment(data).format("MM/DD/YYYY");
            }
                },
 
@KevinB I understand what you are saying. Currently, when user selects the "arabic" language, the entire front-end is switched to Arabic language instantly
Without a change in the URL
Let's say if the user is on:
https://example.com/property/details
And they change the language, the language is switched without the change in the URL.
 
what i'm saying is example.com/en-US/ can serve the same index.html as example.com/
the language/locale can be included anywhere in the url, doesn't have to be the beginning
put it at the end if that's more convenient for your router
 
Okay, so if the user changes the language, I need to redirect them to the URL having the selected language in it
Right?
OR
if user is on the /en-US/ and they switch to other language, I just change the language on runtime and don't bother updating the meta tags?
 
2:57 PM
ideally you'd change the url, so that if the user bookmarks the page they get the right language when they use the bookmark
updating the url doesn't necessarily require redirecting
 
Browsers send an Accept header you can look at - though with Arabic it might be a bit tricky because it's a relatively challenging language because it's RTL, cursive and fonts are tricky.
Though ignoring the types of accept headers Arabic has and just asking the user and having a /eg-AR/ would probably be easier.
 
Hey @BenjaminGruenbaum o/
 
Hey
Got pinged by Loktar ^^
 
i wonder if he got any new guns lately
 
heh
IDK I have to say a lot of people here are regretting not getting guns but I'm pretty happy they don't have them rn
 
3:09 PM
i'd rather be able to buy a 3080
 
Hello guys, does anybody know a nice way/library that would help me with updating the redux states with nested related models from database? For example, if there's a post

{"id": 1, text: "hello", user: {id: 1, name: "Martin"}}

and I get an update from websocket which says "user id 1 changed its name from Martin to Martin2" I would get this updated in all levels of the state without need to manually find the specific places where is the user included?
I mean, if there's a comment somewhere in the state, I have to manually update the object, which gets pretty hard as the time passes by.

for example, if post has comments:

{"id": 1, "text": "hello", user: {id: 1, name: "Martin"}, comments: [{"id": 1, user: {id: 1, name:"Martin"}]}
I want to do something like updateEntity("user", {id: 1, name": "Martin2"}); and not worry if I remember all the places where user is as a relationship
Something like Doctrine uses for its entity state management
 
3:31 PM
@Martin. theoritically redux will change the state in relevant places when the store is instructed of the change.
 
@FélixGagnon-Grenier We do that manually by finding and then updating it
 
dayum, must be quite a store if you have to search for it :P
... but more seriously, the whole idea of redux it to maintain the state automatically when changing a central store.
if one has to go in various places to hook stuff to make sure the changes are actually propagated, there's a problem that needs to be addressed about how components are built
 
If I request the API for posts, which need data about user, also comments and also info about the user in a comment, I get all that in one request to save some traffic & latency ofc
If I have a set of entities that are real-time-updatable, let's say none ([]), and then I add "user" to the entities I push to the client, I just want to be able to push the change to all the places
 
@Martin. Is "places" here different clients or all possible places that are displaying something related to the user in one single client?
 
3:47 PM
possible places that are display something related
imagine
 
@Martin. 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.
 
if (update.model === "User") {
    dispatch(setComments(store.getState().comments.map(comment => {
        return {...comment, user: update.data};
    })));
}
Or, let's say, I have chat.stackoverflow.com, present users are in sidebar as

presentUser { presentSince: ...., user: {id: 1, name: "Martin"}}

also every post/message make is a

message { id: 1, text: "hello guys", user: {id: 1, name: "Martin"}}
 
this chat handles it by not doing it till the page is reloaded
 
That's not my point :-)
 
(not mine either)
 
3:53 PM
Suddenly I change a name and I get a message from websocket:

[{"model": "User", "data" {id: 1, "name": "Martin2"}}]
 
my point is, you have a lot of data, your options are rebuild all of it or iterative over all of it
both are problematic
the best solution may very well be to let it be
 
That's why I want to find a package instead of reinventing the wheel. I refuse to accept the fact nobody would solve this already :P
 
why would there be a package to iterate over a collection
just... iterate over it
 
Because I don't believe it's the only and best way to do so
 
there is no other way
you can't just say "Change all these things" without looping
 
3:56 PM
Of course
but i have to manually loop through it :)
 
so does the package
 
that's not guaranteed
 
if you get a package to do it, you're getting something that's going to do way more than just iterating over it and doing it would do
because it has to be built to function with any set of data, not just yours
 
there could be a middleware-reducer which would store the relationships for example
I mean, a solution could be managing the state in some normalized way, which would for example extract the users into another state, such as

relations: {users: [{"id": "name":"Martin"}]}
 
that would be ideal
but that's more a case of reorganizing how your state is structured
not some additional package
 
3:57 PM
Apollo Client does something like that
 
@KevinB harder than a gun lol
 
way harder here
here you don't even need a background check
 
@Martin. immer makes it much nicer
Or just MobX lol
 
5:00 PM
github.com/paularmstrong/normalizr hmm got it probably :-)
 
5:12 PM
sometimes the question of why something works is more confusing than why something doesn't work
 
5:51 PM
This seems really inefficient, anyone have a suggestion to optimize more? Usually I wouldn't care, but the arrays in this program could hold lots of data so optimizations might matter.
Uint8Array.from(
      arrays.reduce(
        (final: Array<number>, buffer) => [...final, ...new Uint8Array(buffer)],
        [],
      ),
    ).buffer,
Basically i need to flatten an Array of ArrayBuffers to one ArrayBuffer
 
const length = arrays.reduce((p, c) => p + c.length, 0);
const target = new Uint8Array(length);
for(let offset = 0, i = 0; i < arrays.length; i++) {
  target.set(arrays[i], offset);
  offset += arrays[i].length;
}
 
thank you
 
seems i need to do the following because ArrayBuffer's aren't array'ey enough
  for (let offset = 0, i = 0; i < arrays.length; i++) {
    target.set(new Uint8Array(arrays[i]), offset);
 
Node has: Buffer.concat(arrays.map(x => new Uint8Array(x))
 
6:02 PM
Unfortunately, need to support browser.
 
6:12 PM
Is it possible to create a discretized range slider with non uniform step values using the input type='range' element?
I think I can :)
 
"discretized"?
 
> set interval in react repeating itself
that title tho
 
7:05 PM
Hey
 
7:18 PM
Hi
 
o/
 
I have the following code to add an event listener which changes the class of the the element in the list on mousemove
let list_items, list_item;
list_items = document.getElementsByClassName("list_item");
for (list_item of list_items) {
    list_item.addEventListener("mousemove", function () {
        document.getElementsByClassName("selected_item")[0].classList.remove("selected_item");
        this.classList.add("selected_item");
    })
}
I am using React and this is not working if I reload the page
 
with react, you typically don't interact with the dom directly
you can add this event in the view
 
If I put the same thing in a script tag it works fine.
@KevinB i am new to this
can you please explain
 
What code is creating the list?
and, what is this classname for?
 
7:30 PM
the list is already there in the HTML
and the classname is to change the background color
 
so this list isn't rendered by react?
 
not as of now
though I have change that later
 
then that code in a script separate or outside of your react app should work fine
as long as it comes later in the dom than that list
 
It is working the first time I change something and save the file
problem is when I reload
it is not working
 
that doesn't make sense
 
7:43 PM
But that's what is happening
BTW how to render script tag from react
I am unable to do it
 
you don't
 
You mean we can't render script tags from react?
 
wtf why would you do that?!
 
I only want that for that particular page
and not others
 
on the page with the html list, add a <script> tag directly below it
when you move the list to react, the code should be deleted
if at any point the code doesn't run and affect the list, then you weren't clear with how this page is being built/rendered or where the list is in your code
 
7:55 PM
@ThiefMaster thats a bit rude
 
😃
 
it just sounds like a very strange thing to do.. embedding script tags via react code
 
i agree, but i think you could explain why
 
it's not necessarily that you can't, it's that there's 0 value in doing so. react renders a view, and when the state changes the view gets updated. it can't update already executed script, so the script would simply be re-inserted and re-executed in full, if it doesn't instead just get omitted by react because of how bad an idea it is.
 
:)
 
8:06 PM
it would get instantly executed as well, giving you no real value in doing it that way rather than just running code directly in react.
eval('alert("foo")') for example, is silly, because you could just alert("foo")
 
8:25 PM
Does anyone know if I can use a renderer function in my column init of my DataTable to apply a tooltip to a datacell?
 
8:38 PM
Hey guys,
I'm coding js for a couple of years (non professional I'm a Kotlin dev). for a playground project I want to access now a database with async await with the module mysql2/promise. However always when I try to access the database with that import I get the error `await is only valid in async functions and the top level bodies of modules`. that await statment is on the main level of that file. I just can guess that this means that the "root level" of the file is not the top level of the module. Can someone explain this?
By the way here is my minimal code which causes that error:
const mysql = require('mysql2/promise')
const con = await mysql.createConnection({...})
 
9:03 PM
basically... async/await is shorthand for promises
you can't await something, in a context that won't in the end return a promise
I wonder if the top level await idea ever became a reality
 
@rekire wrap it in an async main function and then call main()
 
so thee solution is to warp that code in a method and call .then() on it?
 
effectively, though the .then is optional
 
@KevinB I thought it was accepted for use in modules or something
 
async function start() {
    const con = await mysql.createConnection({...})
    // con is undefined here
}
start()
 
9:09 PM
@rekire 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.
 
if i'm not mistaken, mysql.createConnection doesn't return a promise
 
@JamesBot ah you are a bot lol anyway done
 
there's nothing to await there
 
ok now I get con.execute is not a function or its return value is not iterable checking type of con...
it seems that con is a Promise
 
what node module is mysql
 
9:12 PM
const mysql = require('mysql2/promise')
 
ah, that's important info
 
sure :-) I tried to mention that in my second message
 
con shouldn't be a promise there, if you're awaiting it
my earlier messages were under the assumption of using the other module
 
no problem, I'm happy about any help
async function start() {
const con = await mysql.createConnection({...})
console.log(con)
let [rows, fields] = con.execute("SELECT * FROM users WHERE username = ?", ["username"])
console.log(rows)
}
The log output is now `PromiseConnection {...}` and
let [rows, fields] = con.execute("SELECT * FROM users WHERE username = ?", [username])
TypeError: undefined is not a function
(formatting is hard)
 
interesting
 
9:20 PM
its a typo in the sql it should be "user" not "users". the table does not exists :/
now it works fine just the script does not exit
 
PromiseConnection instances most definitely have execute methods
lol
 
const mysql = require('mysql2/promise')

async function start() {
  const con = await mysql.createConnection({...})
  let [rows, fields] = await con.execute("SELECT * FROM user WHERE username = ?", ["username"])
  console.log(rows)
}
start()
why does that not exit? do I need to call con.close()?
 
that i don't know
i would assume close is needed
 
it seems so
with that code the script exits
so thank you for pointing my in the right direction I needed that
 
10:22 PM
 

« first day (3863 days earlier)      last day (1068 days later) »