« first day (3261 days earlier)      last day (1670 days later) » 
04:00 - 19:0019:00 - 23:00

4:15 AM
just noticed this familiar forum template like forums.expo.io anyone knows if there is a open source code for it ?
 
@AhmedYounes 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.
 
4:32 AM
hi
there was some css library for resetting the default style, what is name of that any idea?
 
 
1 hour later…
5:38 AM
@NullPoiиteя reset css?
 
5:57 AM
Hey ppl
 
o/
 
I was asking myself is it good practice to name a file not capitalized if its not a class (I'm thinking of Vue components)

Generally, isn't it good practice to avoid upper/lower case due to linux ?
 
all lowercase, separated with dashes. And if using sequential number, use zerofill. If using dates, start with it and in iso8601
 
6:16 AM
🙆‍♂️
 
 
1 hour later…
7:41 AM
An other one
Is the null usefull ?
async request(url, method, body, clean=false, token=null) {
Isnt my parameters null by default ?
And will I have to put this last parameters each time or is it optionnal without the default ?
 
Why does a function that returns an object with a method is not doing his work? For example:
function do() {
    return $("#myElement").html("Hello world");
}
 
@Baldráni undefined actually.
that what you did is default parameters, making it non-undefined
 
If I call do() it will not print Hello World
 
@SilverSurfer is this jQuery ?
 
7:45 AM
You do not create an element by using $("#myElement")
 
@SilverSurfer it returns the jquery object used
 
You can console.log this if you want to see
 
but fyi I hope that the above function is an example
because do is a reserved name
 
@KarelG So does this make my token required ?
 
7:47 AM
"required" as in ... ?
i can just call async(); You have to verify the arguments in the body.
 
Like If I use the function without this parameters while it works ?
I'm trying this in a sandbox right now
 
yes. You can do request().then() or request('url') or ect
 
Okay this is perfect
function test(test, yolo)
{
 console.log(`${test}, ${yolo || 'coucou'}`)
 }
test('salut') //salut, coucou
 
// call request()
url = undefined
method = undefined
body=undefined
clean=false
token=null

// call request('url', 'get')
url = 'url'
method = 'get'
body=undefined
clean=false
token=null
but it is best to separate request into getRequest and postRequest. Mixing both in one function with validation is a messy thing
 
Huum
Possibly
I'll have to clean this out anyway :)
 
7:54 AM
My problem is the next, I have a few functions that returns the ajax promise, I want handle them once they are completed, but inside them, on success method, they do things, like print the returned data like $(el).html(data). But since they are in "return" they do not print/do the code inside. Im trying to handle them, and in the other hand execute the code inside them. A very basic example:
function ajax1() {
    return $.ajax({
        //...
        success: function(data) {
            $(el).html(data);
        },
    });
};

function ajax2() {
    return $.ajax({
        //...
        success: function(data) {
            $(el2).html(data);
        },
    });
};

Promise.all([ajax1, ajax2]).then(values => {
    console.log("Ajax ended")
}, reason => {
    console.log("Ajax failed: " + reason);
});
The promise handle is working, the problem is the ajax doesnt execute the code inside success like $(el2).html(data) or whatever
How to proceed with this?
 
it should execute. debug it
oh I see it now
hue hue made a typo (too fast typing) and discovered www.goog.com does exist
 
8:09 AM
@KarelG haha
Nice try !
Stop the autopromotion
😬
Fun google didnt bought it 3 millions already
 
Hey guys, I need a bit of help with some syntax related issue.
say I have a function inside another function, how can I interrupt the executing of the outside one by returning etc?
function x() {
    function y(shouldInterrupt) {
        if (shouldInterrupt) // return from x()
        else  return 0;
    }
}
I've tried using a try/catch statement around the internal function and throwing an error inside of it, then catch the error and use that as the return value
but that only works if I call the function from within the try/catch block
and I don't
 
8:29 AM
Hi everyone! Hope someone can help me out
I'm trying to make an exec function async with no success
`const removeApplet = async (lockKey, result) => {
result.stdout = "";
result.stderr = "";
result.error = "";
console.log("GOING TO REMOVE..");
async function wrapper(lockKey, result) {
exec(`java -jar gp.jar --delete D27600008501 --key ${lockKey}`, function(
error,
stdout,
stderr
) {
console.log(result);
stdout
? (result.stdout = stdout)
: stderr
? (result.stderr = stderr)
: (result.error = error);
console.log("STDOUT: ", stdout, "\nSTDERR: ", stderr, "\nERROR: ", error);
return result;

/*if (stdout !== null) {
 
I apology for the length, problem is
 
hey, can you do us all a favour and link to a pastebin, github gist etc?
 
I apology again, I'm not really accustomed with this, just a second
 
no problem
 
8:34 AM
@BenFortune I'm having a look at what you just sent me , thank you
 
okay, first thing I noticed is that you're overwriting result.stdout, result.stdin and result.stderr. why?
 
cause in the code flow those properties were written by other functions
and I need to reset them to empty string when entering the current func
 
you are aware they won't be streams anymore?
okay, somewhat simplified, here's a version of a process spawner that returns a promise.
 
1 message moved to Trash can
@JacobSchneider Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. For posting large code blocks, use a paste site like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
 
8:41 AM
@Jac
@JacobSchneider I tried a similar approach but without using process.on
does the problem resides there?
 
what did you do instead?
 
same as you but without using the process.on function
 
the process.on('exit', () => {}) is an event handler. it will resolve the promise when the process ends.
 
Ok I'll be giving it a try, thank you!
 
I hope that helps.
 
9:08 AM
solved
there's a custom function for this which is sync and wait for the child process to end
 
Yes, there is, but I wouldn't recommend using it
What are you building? if you're building a webserver, then I woulnd't recommend it as it will stop the whole thread until the other process exists, somewhat defeating the purpose of a process
 
given the flow of my app I need this kind of Behaviour
but thank you for the advice
 
ah I see, well, as long as it works, right?
 
ugh don't use sync
You're risking hanging your entire server, depending on where it's run
 
10:06 AM
what is life
 
baby don't hurt me
 
11:03 AM
Morning guys
sigh math homework rn
I hate literal Equations
 
11:24 AM
Actually, I forgot, were doing Linear standard form equations
either way, super easy, but annoyying to do lol
anyone know if theres a simpler method for sleeping inside a function except for promises:
function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}
I dont want to use async functions and await methods every single time I want to wait a couple seconds
 
what
why wouldn't you just use setTimout on it's own?
 
Well actually I just stopped using that, Im now using this function instead:
function sleepD(s) {
 var n = new Date().getTime();
 while (new Date().getTime() < n + s) {}
}
Because the promise freezes the entire function
 
...
and that doesn't ?
🤨
 
When I used the promises and the sleepD in the same function, the promise was used first, it waited 2 seconds, then skipped the Sleepd and activated everything in the function
sleepD was put in the first slot instead, and it worked, it waited 2 seconds between each log
 
because you don't use the promises correctly?
 
11:39 AM
I used an async function with await
just like I was told
 
I have more serious work to do atm.
 
Its alright, I dont mind
Im just an amateur trying to do things for fun
Until I get into college, I most likely wont have a job in webDev
Actually, forget what I said before, it seems just using sleep more than once in the same function always causes this problem
but I CAN use more than one sleep if I use sleepD and the promise in the same function
only 2 though, more than that causes the same problem... Unsure why though.
Ok, Nevermind I solved it, Thanks for uhm... The help.
:P
 
12:02 PM
Any idea how to control the zoom speed?
Seems a bit fast
 
debounce the listener and add a css transition
 
hmm that is a good idea indeed
The thing is that im implementing this stuff in canvas. Images are displayed at different depth levels (scaled) and the user zooms in those layers.
The bigger distance, the faster the slide. In canvas we dont have transitions, so that is a problem.
 
Anyone know if its possible to shorthand this function? I want to know if its possible to run Async Await without Specifically Calling it, sortof like how Jquery does it.
function sleep(s) {
 return new Promise(r => setTimeout(r, s));
}
 
> if its possible to run Async Await without Specifically Calling it, sortof like how Jquery does it.
what?
 
As of right now, you have to write async function foo() { await sleep(200); }
Im asking if theres a function that works in the same way
without using async
 
12:06 PM
if you want promises, it's promises all the way down
also, explicitly waiting in js like that is hella bad
learn async flow
 
12:18 PM
Or learn Nsync flow, and join a retro 90s band
 
BSB4me
 
12:33 PM
I guess
 
12:49 PM
@connexo ohh I wish you were in chats
that question is a train wreck
 
which question?
 
translate is not a reserved word. this answer is completely false. — rlemon 15 mins ago
everyone piled on the "ohh it's reserved. move on"
no, it's not reserved.
we have documentation about reserved words.
my comment looks more concerned than it should
but that answer was marked correct by OP
now undone
 
1:08 PM
> translate is also a predefined function by JS. Here is the link. – Code_Ninja 1 min ago
lol
 
did you just copy a comment
 
You know what ben
I didn't ask for your criticisms
 
You should know better
 
*criticism singular
sheesh
 
Stop pushing me away!
God this place is so toxic
 
1:09 PM
> tosic
 
holy shit I'm making a meta post
 
do you have a source for chrome and FF embedding / using p5.js? This seems unlikely to me, and google does not seem to provide any insight on it. — rlemon 37 secs ago
I'm hammering my X to doubt button
 
wut
that answer is silly
 
the entire question is a train wreck
solid friday morning material
 
1:25 PM
hey is there a "Not Equal" Operator for >=
Like !>=?
Obviously that doesnt work
 
!==
and if you want the opposite of >= you want <
 
and if its <=
 
then you want >
 
<= is the opposite of > and < is the opposite of >=
 
1:28 PM
)()( is the opposite of ()()
 
┏(・o・)┛is the opposite of ┗ ( ・o・) ┓
 
@hsyn.ozkara 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.
 
@Neil Uh, <= is "Less than or Equal to" :L
> is Greater Than
">"
Its NOT opposite, because <= checks for a number equal OR less than, but > only checks for numbers greater than
 
...
it is the opposite
if it isn't less than or equal, it's greater than
 
1:33 PM
on this sliding scale. it's the opposite side.
opposite doesn't always mean "exactly identical but reversed"
 
Oh.. he means ELSE
in normal math though, that isnt the perfect opposite
In an If statement, yes
 
...
 
it would be opposite
 
don't talk nonsense
rlemon is correct
 
the opposite of <= is >= ;-;
 
1:34 PM
no
 
no
 
bruh why are you guys ruining my math knowledge lol
 
in logic, the opposite of a thing is shown with a negate: !
 
and before it comes up, boolean logic is math
checkmate
 
well I mean by opposite I mean they're mutually exclusive binary cases
 
1:36 PM
if C is an ordered collection, then A <= C / 2 is the first part and the opposite of that is that !(A <= C/2) which means that there is a B where B = !(A <= C/2) and so B > C/2
 
logic is the root of math, not the other way around
math is in a sense, an extension of logic
you can use 1 and 0 in the place of true and false and you can achieve the same thing
 
I see
 
If anyone knows how to improve this code: jsfiddle.net/1y7vr50s
zooming at the start is crazy long. Rlemon, debouncing doesnt improve it : (
The idea was good though. The problem still remains, that as the distance increases the zoom gets faster. The initial zoom especially. You hardly see the red circle when zooming in.
 
you want that jump in there?
it goes small, than super big, than small again, than big
 
Dont see that jump. We just have 3 different circles at different scales.
But yes. Basically im simulating depth.
 
1:45 PM
if you push it all the way to the right, it gets stuck
at least it does for me
 
Ya thats ok. Expected behaviour is that it ends with the green circle.
 
is the slider emulating something?
or do users actually have a slider control?
 
Idea is that you can zoom from Start circle to End circle. As distance between A and B increases, so that the speed when you zoom.
they actually have a slider control
 
seems like a logarithmic thing
 
Interesting
 
1:55 PM
@JBis I don't know why you bothered to point out all of the flaws. The entire point of posting it was because it was so flawed. So thanks, captain obvious.
 
I was bored
sorry
 
so is the reason why haven't seen news of area 51 raiders upholding the heads of aliens because they found nothing, because they didn't raid, or because they're all dead?
 
2:13 PM
Hi! Do some of you have experience with React and Typescript? I have many problems with a simple context consumer.

    import LanguageContext from './LanguageContext'

    export default (props: LinkProps) => (
      <LanguageContext.Consumer>
        {context => {
          const path =
            context.locale === context.baseLocale
              ? props.to
              : `${context.locale}${props.to}`
          return <Link {...props} to={path} />
        }}
      </LanguageContextConsumer>
 
<LanguageContext.Consumer>
</LanguageContextConsumer>
 
IT's a typo from my last tests, sorry
It fix nothing
 
2:53 PM
Wake up
 
no
 
I have a range of dates and random rates from the database. Need to be able to show that on a calendar. Anybody know of a JS library that allows you to do that?
 
it's not that bad
I wrote my own calandar control a few months back
 
That sounds really awful when you have appointments that span multiple rows.
It's not a problem I've thought I've wanted to devote time to solving
 
3:00 PM
it really wasn't that bad. it's tedious, but not logically hard.
what I spend more time on is big data visualisation
:(
 
d3?
 
no, more like how to show 45 columns and 2000 rows in a meaningful way
 
Oh, yikes, and in a performant way.
 
sure I can make it readable. but not meaningful
 
Do you virtualize in some way?
oh wait, nevermind
 
3:30 PM
I was able to get the calendar going.
Thank you sir.
 
3:57 PM
One of the users who contributed to this is why this room is so dead: stackoverflow.blog/2019/09/20/…
 
hey i have a question
this code is working great here
but when i tried on my machine or on fiddle i get the same error
 
what error?
 
(index):224 Uncaught ReferenceError: msf_btn_next is not defined
    at HTMLInputElement.onclick ((index):224)
it's kinda odd
 
probably load order
 
but why it works on codepen then ?
 
4:02 PM
because it has a different load order
 
ohh
so maybe if i defined the onclick function first it would work ?
 
in jsfiddle it's because you have it wrapped in onload
the takeaway here is to not use inline event handling
 
@rlemon so defining function outside the onload event ?
 
hey guys can someone help me with a regex
 
in jsfiddle load options you can define 'onload' which wraps your code with window.onload = ....
and functions defined in there won't be available in the global scope
 
4:11 PM
I have a piece of code that looks like
contract NAME_OF_THE_CONTRACT {...`
how do I extract just the contract name with a regex
so I would have a string that says NAME_OF_THE_CONTRACT
 
Oh !!
document.addEventListener('DOMContentLoaded' , function () {}
i have this in my code as well
 
yea that's the issue
well, that mixed with inline listeners
step 1 ) remove the inline listeners.
step 2 ) move your script file to the end of your body and don't wait
step 1 is optional
but you should do it
 
@rlemon thanks alot i will give that a try
but just to be sure inline listeners would be "onclick="msf_btn_back()" right ?
 
yes
it is preferred to bind those handlers in JS
 
ok great , thanks alot , i will use JS insitead
yup !
 
4:16 PM
good stuff. lemmy know if you have any more issues
 
i will , thanks alot :)
 
np
 
@KevinB not sure tho. I doubt it.
 
4:43 PM
@rlemon it was abslutly because of the inline listener , my js was defined at the bottom , anyway i couldn't bypass the inline listener nether by defining the function before the onload function nor inside so i've just got rid of it all together and used JS as u told me and it worked as a charm :) :) thanks alot !!
 
glad to help, and happy you found something that worked (and just so happens to be more sensible)
o/
 
yup its much easier this way , appreciated man thanks o/
 
hi guys
this array returns me error "Array to string conversion";

$result=array_diff($teste,$linha);

how i can fix this? can you help on it^?
 
why are you asking a php specific question here?
ask the php room
 
ya i try, the return was like "will try to review over weekend ..."
 
4:52 PM
like, we don't mind getting off topic questions. but that question belongs in the php room.
 
i know, and sorry for this, but... i'm stuck
 
this isn't the php room
 
@Cereal glad to know
 
should I repeat that? :P
 
a) the php room isn't even inactive. it's quite a rocking place. just wait like an hour.
b) I found the result of your issue by googling the method and the error. you need to try much harder
5
A: array_diff Array to string conversion in error

Fabian Schmenglerarray_diff can only compare strings or values that can be casted to (string). But the elements of $aktifler and $gelenler are arrays by themselves, that's why you get this notice (also, converting an array to string always results in the string "Array", so all arrays will be treated as equal). S...

seriously..
 
4:58 PM
mhm something is broken at my end: let's say I am flooding my server with X requests. And each single request turns in a single record. Now I have R = # of records where R > X.
bah
 
that sounds fun
 
I am already overtime for multiple hours
 
how much greater?
 
a measly 12 too much ( 15067 requests, got 15079 records)
 
Are you using a browser to do it? could something be resending a request due to a previous one taking too long?
 
5:00 PM
there is probably a lock missing
@KevinB locust.io
 
 
1 hour later…
6:08 PM
 
6:22 PM
guys, on a large canvas,say 50K px, browser freaks out, how do I make sure it doesn't. I ma navigating canvas (game) with hold and drag cursor function.. thanks, thoughts?
 
Don't make a canvas that large. THat's horrible. You need to implement a camera system instead
 
so, keep the canvas windowInner width and then do Camera system?
 
Yes
 
thanks, i will try. I hope "camera system" is a well known concept for canvas based games
 
it is an extremely well known concept in games and graphics
 
6:25 PM
Does anyone here understand Karma testing?
 
@JustinThomas 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 gave the rules a read.)
 
how do I specify more than one filter in the interface for filters?
export interface Filter {
  title: string;
  id: number;
}

export interface FilterCategories {
  filters: Filter;
}
this is TS
I want to be able to pass say.. 15 Filter's
 
Array<Filter>?
 
I think it is Filter[]
I started wanting to do C# also
 
6:36 PM
i've never seen Filter[] setup, but i use the Array<Filter> setup for those cases
Looks like it's valid tho
 
Typescript arrays
https://visualstudiomagazine.com/articles/2016/01/01/exploiting-typescript-arrays.aspx
 
hmmm might be able to use Array<Filter> gonna see if it barks
nice it works too
end up with something like this:

export interface FilterOption {
  title: string;
  value: number;
  checked: boolean;
}

export interface FilterCategory {
  title: string;
  id: number;
  options: Array<FilterOption>;
  hasAllOption: boolean;
}

export interface FilterCategories {
  title: string;
  filters: Array<FilterCategory>;
}
 
6:54 PM
I'm not suggesting one is better than the other, i just never used the other. :shrug: be consistant
 
04:00 - 19:0019:00 - 23:00

« first day (3261 days earlier)      last day (1670 days later) »