« first day (3112 days earlier)      last day (1840 days later) » 

12:00 AM
Use a payment gateway like PayPal to handle it all
 
12:36 AM
where do people host their websites? any good virtual hosters?
 
user8729657
@Suisse, Digital Ocean is pretty good
 
1:43 AM
I have this code
const si = require('systeminformation');

function getCPUInfo() {
return new Promise((resolve) => {
resolve();
console.log("Gathering CPU information...");
return si.cpu()
// .then(data => cpuInfo = data) - no need for this, the promise will resolve with "data"
.catch(err => console.log(err)); // note, doing this will mean on error, this function will return a RESOLVED (not rejected) value of `undefined`
})
.then(() => {
return si.cpuTemperature().catch(err => console.log(err));
});
}
// the resolved value
how do I make it so cpuTemperature is undefined
 
morn!
 
2:06 AM
Morning!
I'm stuck on an AngularJS 1.7.x application; trying to do something I haven't ever managed before (possibly because not possible) -- can you intercept isolated scope changes to a directive? Given scope: { x: '<' } is there a way to run an interceptor/filter on x so that you don't end up with the directive constructor initialized with invalid state?
 
2:38 AM
evening
can someone tell me what I'm doing wrong in my Promise here?
 
 
2 hours later…
4:23 AM
anyone up for a regex exp
 
@KamranHamid 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.
 
 
2 hours later…
6:21 AM
morning
@ShrekOverflow do you have a stop button? You are almost "overkilling" it :P
 
6:45 AM
shrek is love. shrek is life.
 
hi @neil
 
@objectiveME hey, how've you been?
 
@Neil I have been good. I wanted to pick your brains on react ide and python's asyncio
 
not familiar enough on either to be of much use I'm afraid :P
 
Fair enough.
What of evet loop
 
6:49 AM
I suppose asyncio would be the way to go for concurrency in python
 
Yes correct and its amazing
Its the closest thing to black magic
 
it looks like it's done smartly
not sure how they managed to get it to work though
how'd they make async/await work?
 
Indeed. The idea has been around since gevent,twisted and the idea of green threads
Every thing revolves around context switching which is done by the event loop. So when you asyn.sleep you suspend execution and another coroutine gets a chance to execute
This way you can get as many coroutines to execute concurrently
 
from the looks of it, they made it a keyword though
python doesn't have anything which supports that
(from what little I know of python)
 
async/await is what python has. They did away with annotation based @'s
I have been looking into this for the longest time and i find pythons implementation to be the most forward
 
6:58 AM
ah ok, so it is a keyword
 
yes
 
asyncio just builds on it
 
import asyncio
import random

q = asyncio.Queue()


async def producer(num):
while True:
await q.put(num + random.random())
await asyncio.sleep(random.random())

async def consumer(num):
while True:
value = await q.get()
print('Consumed', num, value)

loop = asyncio.get_event_loop()

for i in range(10000):
loop.create_task(producer(i))

for i in range(500):
loop.create_task(consumer(i))

loop.run_forever()
Yes, but in a way improved
 
7:15 AM
the equivalent in java would be a lot more verbose, that's for sure
 
haha, i agree. I heard async behaviour in java can be done using CompletableFuture but that has more disclaimers than the 26,911 words of European Union regulation on the sale of cabbage
 
well conceptually, it isn't much different than the Promise in javascript
you get a hook to the async task and you can resolve it at any time
there's something very elegant about that approach imho
java makes it overly verbose just the same, but at least javascript does it decently
 
True. Guido has been praising javascript's approach on twitter lately so that means even the big wigs have taken note.
 
7:33 AM
I don't think javascript is going away anytime soon
but not even python
python has its niche as well
 
I need help with naming custom events. The events are about tracking an element's position relative to viewport. So they follows as this: peek -> enter -> ? -> exit
Events correspond to these states: top -> whole -> bottom -> none
I need to differentiate between peek and enter, and ? and exit. I can't figure out what to name the state before exit.
 
 
1 hour later…
8:51 AM
@akinuri The image isn't loading, can you check please?
 
@BhargavShah 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.
 
9:20 AM
@BhargavShah Sorry, changed the file name (added another image). Here's the page: github.com/akinuri/in-view-tracker/tree/master/rsrc
I've decided to go with peek -> enter -> leaving -> left
 
@akinuri Leaving sounds good (y)
 
 
1 hour later…
10:31 AM
Hi! I am making a small API for my business landing page to collect emails. I want to protect the post endpoint so that it is not abused. How is it possible to make a post request via JavaScript so that the authentication password does not show up in the sources of a web page?
Does it make sense to read the username and password from a file in javascript? Would that come up in sources in the web-page?
 
10:56 AM
use a token
and use a database for password unless it is a small scale project. Even then, hash your passwords
 
can you link me up to a good resource on tokens? never done it. It is super small, need to literally collect the emails
thanks!
 
@isquared-KeepitReal the advantage of a token is that you can make more
You don't have to worry about people saving the tokens if they expire regularly
If you don't want them to login again, you can allow an expired token to get you a new token
Just don't make the mistake of letting the old token work multiple times because that can be abused
 
Nobody will be logging in. There is literally one field on the page that is an email field. I want to make a post request to my API service with authentication. But I do not want people to see pwd in the javascript sources.
 
11:12 AM
@isquared-KeepitReal you still need an authentication service
you want to login and you don't want to ask username or password from the user?
then it's trivial authentication
what kind of authentication is that? you're basically vouching for whoever is using your service
and vouching for whoever is using your service is the same as not having an authentication
 
11:28 AM
Is it possible to send arrays via axios? It simply refuses to send mine lol
 
@misidentified 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.
 
axios.get('/api/courses/search', {
    data: {
        l: levels,
        p: providers
    }
})
.then(function (response) {
    document.getElementById('browse-courses-area').innerHTML = response.data;
})
.catch(function (error) {
    console.log(error);
});
 
@neil
Sorry if I did not make it clear. Here is the set up:

There is a website. And there is a single field, which is an e-mail field. Anyone can go there and write their email. Javascript on that page will be making a POST request to an AWS Python service to store that email into the DB. But I do not want for anyone to go into sources and then be able to see where the request is made to and then them making requests to that endpoint programmatially. And messing up my db. To stop that, I thought I needed authentication.
 
To my knowledge, you'd need some sort of firewall server in place which forwards the call to your actual service
but I don't know if you can authenticate without leaving anything client-side
I mean either you authenticate because the request is coming from a specific domain or IP address
 
that's a good call
I can check for the domain
 
11:33 AM
or otherwise the firewall server provides the proper authentication to your actual service, so that even if it is "public", it isn't authenticated
and it also hides your real service
 
haven't built firewalls and I think it is an overkill
for a simple landing page
 
well you'd need to setup CORS for a cross-domain request anyway
just make it so that requests can only come from a specific domain
 
what do I need the CORS for? and where can I check how to do it?
ah, I see
then CORS is the domain authentication in itself. Can someone fake the domain from which they are making a request?
 
R K
I'm not sure what this guy means by declaring var $detailDiv here on the marked answer. Can someone please help. Thanks (stackoverflow.com/questions/1570127/…)
 
how can i call the function inside array of functions as parameter to function?
 
R K
11:39 AM
maybe store that inner function in a variable or something first
 
using apply
fun([
[1, 2, 2],
[1, 2],
[23, 4]
], [add, sub, mul])
add sub and mul are three functions
 
R K
@Neil are you there mate?
 
@RK that marked answer does not have any $detailDiv
 
R K
@KarelG - 4th line of code in the javascript code i.e., var $detailDiv = $('#detailsDiv'),
 
@Vinay you can simply call it. add(...)
 
11:45 AM
@RK $detailDiv is just a variable name
 
this is the marked answer stackoverflow.com/a/1721623/2412895
 
the fact that it starts with a $ would remind you that it is a jQuery object
but it's just a label in the end
 
but searched the page. As neil pointed out, it is a variable name
 
R K
@Neil but where is this variable being used in the javaScript code?
 
$.get(url, function(data) {
        $detailsDiv.replaceWith(data);
    });
 
11:46 AM
below, in the $.get
 
@RK directly beneath
 
R K
oops .. sorry @KarelG - that's not.
 
it's in an inner scope, which means it sees the outer scope and therefore $detailsDiv
 
R K
@Neil = one you pointing out is $detailsDiv not $detailDiv
 
@RK my guess is it's a typo
 
R K
11:48 AM
Right ... my guess too
 
How can I do this with an import?
const bcrypt = require('bcrypt');
 
R K
Thanks @Neil - you're always helpful bro. thanks
 
@RK np :)
 
12:37 PM
@KarelG ok thanks
 
well
If you understood me
function call(val, arrOfFunctions) {
  arrOfFunctions.forEach(fx => fx(...));
}

call(11, [add, del])
it is an simple example. but should be usable for you. @Vinay
 
@KarelG is it possible to do this using apply or call?
 
do you wanna apply the vals to all teh funcs? or just the ones where the indicies overlap?
function fun(a,b) {
  for( const [ i , v ] of b.entries() ) {
    v(a[i]);
  }
}
 
@Vinay yes. But you have to either provide thisArg with something or just pass null
like arrOfFunctions[0].apply(null, value)
that is kinda cumbersome than arrOfFunctions[0](value)
unless you have used this inside that function (ok I guess?)
 
I think it's worth asking why they want to call/apply?
to spread?
 
12:45 PM
yes
 
then use the spread operator
func(...vals);
 
yeah i can use spread but it's assignment for me to use assign or call
i will try as karelG said
*apply
 
/inbefore mixin' apply with spread
 
1:45 PM
I had a weird thing with my computer yesterday
for some reason the GPU just shut off :/
any clue why that would have happened?
 
you didn't pay your GPU bill so they cut off service.
 
@ShrekOverflow probably got too hot?
 
@Neil it wasn't even maxed out though
 
@ShrekOverflow I would say overheating or a disconnection
 
@MichaelHurley 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:50 PM
maxed out temperature or maxed out performance?
 
I'll start using afterburner though, the gpu fans stay off almost all the time
@Neil performance
i was on skype ._. with a game running in background
 
mine does that too
I don't trust the drivers to manage the fan settings because it gets way too hot that way
before starting up a demanding game, I bump it up to 75% or so
 
It's this thing ( I was originally planning a small case ) but got damn GBP 230 for a Vega 56 is insane price even with the blower style
I'll make the fans to atleast 20%
 
don't chance it
bump it up enough that you can be sure it won't get as hot
obviously not good when it shuts off on ya, but it's probably not doing your graphics card a great service either in a long-term sense
 
get a walk in fridge and a nice snow suit
game from there
 
1:55 PM
I understand that in space, temperature is a real issue for circuitry
here, the lowest temperature it'd probably ever get is -10°C, but in space, it can get far lower, and it actually impacts proper functioning of the circuits
they have to be heated before they'll work
 
@Neil I have 6 fans on the case
I am not chancing it 😃
 
but it overheated.. :P
 
the cpu sits at 36-40 at idle to 55-60
@Neil yeah I think the GPU fan didn't turn on
i'll bump up the gpu fan
 
oh, well that would explain it
 
it does thsi weird thing
where on the driver it doesn't ever turn on
until the gpu is beyond 60C
it stays around 16 rpm
😐
then goes to 3000 😐 (what it sounds like)
and cools the GPU down and spikes that way
 
2:04 PM
yeah again, I don't trust the drivers :P
 
morns
 
mine'll do that too
it has three modes: dead, dead, and OMGTHERESANAIRPLANEABOUTTOCRASHINTOTHESIDEOFOURHOUSE!
 
// Which is better to get two digit month?
new Intl.NumberFormat("de-DE", {minimumIntegerDigits:2}).format(new Date().getUTCMonth());
// Or:
String(new Date().getUTCMonth()).length < 2 ? "0" + new Date().getUTCMonth() : new Date().getUTCMonth()
// Or am I missing an easier way?
 
I prefer to put it somewhere inbetween dead and OMGTHERESANAIRPLANEABOUTTOCRASHINTOTHESIDEOFOURHOUSE
 
So, if you compare objects in JS, you will always get false. But can someone explain to me what is going on here?
a = {a:1}
b = a
b === a
// OUTPUT: true

b.d = 1
b === a
// OUTPUT: true
 
2:07 PM
 
[{"user_id": 586, "username": "jimmy"}]

							var allListingDataStr = pageData[i][objkeys[j]];
							if(typeof allListingDataStr == "number"){
								var resultantData = allListingDataStr.toString();
								tr.append("<td>" + resultantData + "</td>");
							} else {
								tr.append("<td>" + allListingDataStr + "</td>");
							}


 pageData[i][objkeys[j]] - this is being executed in a for loop and in middle of for loop I am checking the above condition...

whatsoever, I do... even if I change to .toString()... I am getting as undefined only... in fact, while getting the data, the ra
 
@Neil Great, thanks!
Oh, but that is a library. Download a whole library for just a single function? Is that worthy?
 
@EnderLook meh, maybe not.. but if I had to do even one additional thing with dates, I'd say it's worth it
 
Oh, I need month year and day!
 
@Neil lol, but there should still be a method to this madness
 
2:11 PM
!!> const [ year, month, day ] = new Date().toJSON().split(/-|T/g); console.log( year, month, day );
 
@rlemon "undefined" Logged: "2019","04","24"
 
@mega6382 you keep thinking that then. :)
 
:D
 
@mega6382 you're checking instances
 
@rlemon please, elaborate
 
2:14 PM
you set to be a reference of a, b and a are the same instance
 
@rlemon Oh, because JS is "reference by value" kind of language and not "reference by var"
So, it means that the value of "a" changes as well
 
yes
because they are not seperate objects. they are the same object being referenced in two vars.
you can get around that by cloning the object ofc.
 
@rlemon Thanks <3, makes sense. You, see I knew there was some method to this madness //cc @Neil
 
2:34 PM
@mega6382 There is "pass by reference", there is "pass by value", js does both, but "reference by value" is pretty new to me.
 
2:44 PM
@Sheepy I was calling "pass by value" "reference by value", my apologies.
 
user8729657
How do I learn about circuit boards and stuff like that? I want to make a smart watch for my self.
 
take an electrical engineering course.
you can probably find free ones online
probably easier and more fulfilling to start with some arduino projects tho
 
user8729657
@rlemon, my goal is to be able to voice commands from the watch to my server.
 
@mega6382 Ok.
 
@OvieAdese sure. still probably easier to start with some higher components
because building a smart watch, the biggest difficulty is going to be making it small
 
user8729657
2:50 PM
I'm going to learn this arduino stuff
 
arduino won't solve that issue, but it'll be a stepping stone to understanding what needs to be done
 
user8729657
thanks
 
@OvieAdese including or excluding the microprocessor?
most wearable stuff is extremely proprietrary boards so far
mostly because of the economies of scale
that said, I'd suggest starting with a computer -> mobile computer -> watch
a watch is ---- massively more complex
 
well yea.
so start with an arduino, get your feet wet
 
posted on April 24, 2019 by CommitStrip

 
user8729657
2:55 PM
I see
 
user8729657
I want to do it though so I will try
 
there are pre-fab'd micro boards that will probably fit the bill
but you'll have to go out lookin for them and do a fair bit of leg work to add power / screens / other paraphernalia
 
AKS
Hi All
 
Use the nail for scale ^ That is the SoC for the apple watch
 
2:56 PM
@AKS 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.
 
which has RAM, Processor, Storage etc in that tiny case
its much easier to deisgn it / poc with bigger prototypes
and most problems will be with ux / ui / usability
 
@OvieAdese If all you want to do is to issue voice command, a bluetooth mic that looks like a watch may be much easier to do.
 
why even need a watch?
 
AKS
I am struggling with a javascript code. 000719751186416140289 << 32 Due to large value it is not returning appropriate result rather it gives 16777216.
 
Just use a lavalier / lapelier
 
AKS
2:58 PM
no matter what the left operand is
 
@AKS how do you think numbers in computers work 😀 ?
 
@AKS Use native BigInt or a similar library.
 
!!> 000719751186416140289 > Number.MAX_SAFE_INTEGER
 
@rlemon true
 
2:59 PM
well that'll probably be an issue
 
user8729657
I just want to be able to integrate speech to text service that can send commands to a server, It being a watch just looks fashionable something like these services. azure.microsoft.com/en-ca/services/cognitive-services
 

« first day (3112 days earlier)      last day (1840 days later) »