« first day (3051 days earlier)      last day (2122 days later) » 

00:43
ew
01:17
morn
01:43
double ew
 
2 hours later…
03:28
Hey guys if I have a string like 1M3G5G how do I split by either M or G (e.g. result ['1M', '3G', '5G']
split with regexp
trying to write a regex but doesnt work I was expecting /[MG]/ would do it
are you calling split or match?
you will lose the separator
if you use split
03:29
split
I want to write a regex to separate them by either M or G but I am struggling
just use match
if you want to split you need to use a lookbehind
!!>'1M3G5G'.match(/.[MG]/g)
@david ["1M","3G","5G"]
or the slightly more crazy looking
!!>'1M3G5G'.split(/(?<=[MG])/)
@david "SyntaxError: invalid regexp group"
03:35
thanks
I'm learning jQuery, and I'm confused why the h2 element doesn't get a background color of blue on hover, even though I binded the element to an onHover event: ```$('h2').bind('hover',function(){
$(this).toggleClass('blue');
});```
'hover' is what css calls it, you probably want mouseover
or mouseenter/mouseleave
Aw nice!
03:45
i think that's what it's called, check the jquery docs
Didn't know that
cool thanks
@david I have this array [ '1M3G5G', '2G3M4G', '5M' ] what would be the best way to split as I mentioned it before without having to flatten it
1 message moved to Trash can
@greatTeacherOnizuka Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
I have this array [ '1M3G5G', '2G3M4G', '5M' ]   what would be the best way to split as I mentioned it before without having to flatten it
[ [ '1M', '3G', '5G' ], [ '2G', '3M', '4G' ], [ '5M' ] ]
arr.map(
    el => {
        anotherArr.push(el.match(/.[MG]/g))
    }
)
so you want to keep it nested?
03:52
no I want to have it flat
but I would like to avoid multiple iterations
where are you running this?
there is flatMap
node
.flat() doesnt work
then you should be fine as long as your node version is recent
no it doesnt work its node 10
just supported from 11 on, I get a runtime error
ah, unfortunate
you could just do a reduce
03:56
return arr.reduce((a, b) => {
    return a.concat(b);
}, []);
like this?
that would flatten sure
I want the user to paste a url in the box, press the button, and the blue egg to be replaced by the given picture. But when I enter a url and press "Set Image", the old image just gets replaced by a gray picture.
you could also just do it all as one
!!>['1M3G5G', '2G3M4G', '5M'].reduce((a, s) => [...a, ...s.match(/.[MG]/g)], [])
@david ["1M","3G","5G","2G","3M","4G","5M"]
03:57
$('background').ready(function(){
	$('.colorChange').bind('click',function(){
    $newImage = $('input').val();
		$('.image').css('background-image',"url('newImage')");
  });
});
I checked Chrome's console, but all it says for the div's background image is newImage, which is the variable I set to the user's input's value
you're not using the variable though, you're just using the name, it's inside a string
you need to do $('.image').css('background-image',"url('"+$newImage+"')");
Ohhhh my god
What a silly mistake
I should've concatenated it; Thanks
04:28
var beginOperator = e.container.find("[data-role=dropdownlist]:eq(0)").data("kendoDropDownList");
if (beginOperator != undefined) {
is it right way to check undefined
or just this would work if(beginOperator)
 
1 hour later…
05:53
Hey guys, I'm making a HEAD request through the HTTP.request function, but when I return res.headers I only get some headers
not all of them
but postman is returning 6 headers, I only get 2
 
1 hour later…
07:09
anyone here good at math?
go on
I mean I have taken through calculus
if that is what you mean
anything above that I won't be any help
sorry
07:27
pfft I should think about buying a new laptop
takes literary 15 minutes before I have fully booted my work environment.
No 128 gb ssd is already used by windows partition and thus the hdd speed is killing me :(
07:41
Yeah I've got a pretty good machince, it's a bit costly, AUD 1200, but it's good
In June this laptop turns "3", costed me almost an arm and a leg too.
Oh dear, a 3yo laptop? that can't be good. My previous laptop came with Windows 8.1 and it's starting to fall apart
Sadly 3 years ago large capacity ssds weren't affordable for laptops, so I chose a small ssd + large hdd.
Yeah I get it
so you boot off SSD and use HD for storage?
I have a $200 laptop off ebay
threw in a decent SSD
works fine
07:44
Used to, but like I said after getting into programming as a job I dual booted linux: and then the 128 gb was too small for it.
Too house both windows and linux that is.
But it's especially the flow server that takes about 5 minutes to "boot".
I inherited a 3yo laptop from a friend because "it was dead". turns out she just got a virus. wiped it, flashed Fedora and use it as a file host, HTTP/S server and DNS Updating software
Apart from the housing & narrow view angle I'm really satisfied with this laptop, it's the first I haven't had problems with thermo throttling while gaming.
It's always great when the computer works, hey
128GB is not a decent SSD
minimium 512GB
it was 3 years ago
07:49
Might just buy a new ssd, looking into it now they're not that expensive (90 euros for a 500 gb, 160 for 1 tb).
160 EUR for 1 tb????? They cost fucktons here!
Is it just me or is the total bytes written (before warranty is void) quite low always? Considering modern OS uses the ssd as extended RAM - 60 TB before warranty is void.
actually I can relate, I have a 500GB SSD and it's almost full
can someone help me with Node?
I'm making a HTTP request and am only getting back 2 headers from a response that should get back 8
Postman, written in Node shows all of them, so why doesn't my script?
Download.get_lib(url).request({
				method: 'GET',
				headers: {
					'Range': 'bytes=0-1'
				},
				path: q.pathname,
				host: q.hostname,
				port: (q.protocol === "http:") ? 80 : 443
			}, res => {
				res.on("data", (chunk) => {
					res.destroy();
					resolve(res.statusCode);
				});
			}).end();
bad formatting, sorry
What library do you use?
None
just node HTTP
07:58
But if you get 8 with postman and only see 2 within your script I think the problem is in your script.
const q = url_lib.parse(url);
url_lib?
Yea that's a node standard module
Wait you're using node to fetch data from another server?
Sorry, that's an alias for the url package
yeah
08:04
Well no experience there, but what headers do you get? And which are missing?
I need the content-length header and I get
Date →Fri, 22 Feb 2019 07:58:30 GMT
Server →Apache
Last-Modified →Fri, 17 Jun 2016 17:47:59 GMT
Accept-Ranges →bytes
Content-Length →31491130
Keep-Alive →timeout=5, max=100
Connection →Keep-Alive
Content-Type →video/mp4
that's in postman
content-type: "video/mp4"
last-modified: "Fri, 17 Jun 2016 17:47:59 GMT"
that's what I'm getting
Hmm only reason I can think of is that node automatically hides/eats certain headers but can't help you further.
it doesn't even appear in the headers_raw object of the response, so I doubt it
08:22
Internet's not much help
 
3 hours later…
10:55
are you using res.header in console view?
usually to view a particular header's value you can use get()
something like res.headers.get('Content-Length');
1 message moved to Trash can
@sriya 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
11:17
uhhh why can't I use apply with the add function from sets? To add an array to a set?
ttt = new Set();
ttt.add.apply(ttt, [1,2]);
ttt.size // === 1 ???
ttt.has(2) // === false ???
If you guys want to have a laugh before the mods delete all the comments: stackoverflow.com/questions/54825242/…
@paul23 Because Set.prototype.add only accepts one parameter...
If you called ttt.add(1, 2) would you expect it to work?
11:40
Oh, I thought apply would also do work to enable "chaining" (set.add(x).add(y) does work)
There is no function that basically says "chain function X with params from array Y"
12:05
really wish sets & maps didn't feel so much like an oversight "added just to quell outcry" and had better, native(!) support.
Actually some of my operations are taking quite some time due to the lack of these operations, and having to copy them constantly back and forth to arrays.
Things like union & intersection of sets, filter/map for sets/maps. I know from experience that these function can be fast if implemented natively, even on large datasets, however they are right now dragging me down as I reimplement the behaviour in arrays, naively.
12:32
Is it part of the promise definition that a promise starts executing as soon as possible? Or can a promise library make their own promise implementation that only executes after you await for them.
 
1 hour later…
13:50
@paul23 Promises do not "execute". They only resolve or reject.
I've seen libs that have no side effects tho until you have resolved it tho. dunno how they did it, but I can't imagine it's that hard.
Unless resolve() throws an error or something, you could easily run something after it.
I can't even remember now. I was confused about why things were not working in (I think) knex.js
Luggage pointed out that I had to .then or await it for the query(?) to actually be run
it was a while ago tho
Oh... weird
yea it was knex
14:05
Hello guys, I have an ionic specific question

I'm trying to figure out how to create custom Native plugins in ionic. I can't seem to find anything to do so (write Java plugin and then include it into an ionic project).

If i read the wiki page it says "the original version was released in 2013 and built on top of AngularJS and Apache Cordova. The more recent releases, known as Ionic 3 or simply "Ionic", are built on Angular."
Can i assume that ionic does not support custom code? I want to be able to implement "advanced low-level-ish" features such as root detection
14:40
What was that sparking on the first stage yesterday? Camera just lasted longer than usual? Closer tho the engine?
Also anyone know why they half-clapped, gasped, then full clapped? Did it almost fall?
14:53
@rlemon Waterline (also an ORM) also seems to do this - at least that's how I understand for things to work.
you can do things like:
query = Model.find(where); //"where" part of sql query
await timeOutPromise(10000); // waiting some time
query = query.select(['data']) //select makes it only selects certain columns
await query; //it "gets" the data now.
However I wonder if this actually does follow the specifications of promises.
 
1 hour later…
16:14
Hello. Hoping someone here can help me with the moment api. Anyway I can know that why the constructor failed? (Code below)
const moment = require('moment-timezone');

let year = 2012, month = 12, day = 25;

let obj = { year, month, day };

let dt = moment.tz(obj, "Etc/UTC");

console.log(dt.isValid());
This reports false. Live code => repl.it/repls/WeightyIrresponsiblePhase
that's not what I'm getting
posted on February 22, 2019 by CommitStrip

16:33
Ok I think I know my quesiton
When I run the following code from a node scratch file all the headers are there but when I run from App.js the headers are not there.
Why is this and how can I fix?
!!magic
(∩ ͡° ͜ʖ ͡°)⊃━☆゚. * ・ 。 ᵀᴴᴱ ᴳᴬᴹᴱ
new Promise(resolve => {
			var options = {method: 'HEAD', host: 'stackoverflow.com', port: 443, path: '/'};
			var req = https.get(options, function (res) {
					console.log("in the request");
					//console.log(res);
					//resolve(res.headers['content-length']);
					console.log(JSON.stringify(res.headers));
					res.on("data",res => {
						console.log(JSON.stringify(res));
					})
				}
			);
			req.end();
		});
!!stat
@KevinB You (https://stackoverflow.com/users/400654/kevin-b) have 85717 reputation, earned 2 rep today, asked 7 questions, gave 2311 answers, for a q:a ratio of 7:2311.
avg. rep/post: 36.97. Badges: 11g 138s 160b
16:37
From App.js: {"cache-control":"private","content-type":"text/html; charset=utf-8"}
From Scratch: `{ 'content-length': '143',
'content-type': 'text/html; charset=utf-8',
location: 'https://stackoverflow.com/',
'x-request-guid': '81d276aa-586e-414f-9634-189363274565',
'content-security-policy': 'upgrade-insecure-requests',
'accept-ranges': 'bytes',
date: 'Fri, 22 Feb 2019 16:37:25 GMT',
via: '1.1 varnish',
connection: 'close',
'x-served-by': 'cache-lga21921-LGA',
'x-cache': 'MISS',
'x-cache-hits': '0',
'x-timer': 'S1550853445.097303,VS0,VE9',
vary: 'Fastly-SSL',
'x-dns-prefetch-control': 'off',
As you can see there is a big difference. So why is this?
is that node.js vs browser?
because that would make sense.
wait... those are response headers
are both hitting the same endpoint?
your request code won't change what the endpoint sends if you're hitting the same endpoint with the same information.
there's something vastly different between your two tests
@KevinB I am not sure. I have very little experience with node in general. App.js example is run from a react app. In the Chrome Network Debug window I see the correct request with all the headers however the http headers aren't printed to console.
what is https in your case
if one of these are being sent from the client, and the other the server, you're using two different sending mechanisms that follow different rules.
Scratch: `const https = require('https');`
App.js: `import * as https from "https";`
Right, but https is a node module, how are you using it on the client?
you must have a polyfill or something
16:43
@KevinB that maybe the case. Idk how to tell.
@KevinB App.js is server right?
What looks weird to me is you're using https.get to send a HEAD request
HEAD !== GET
so i wonder if one of the two is actually sending a GET, while the other is sending HEAD
sorry debugging
both are .request not .get
was trying to see if it would make a different but it didnt
https.request
Is one running on the client and not the server?
(that's still unclear, don't recall you answering that)
I hate bounties.
16:47
@KevinB How do I know? App.js is server right?
Heres what's happening
i mean... i don't know how to answer that, lol, you just do
you're code is either running in the browser or on the server
it shouldn't be hard to determine which is which
That is App.js
@KevinB Maybe that is client. Since it has the div crap.
But in any event its the same module so why is it reacting differently
The server (stackoverflow) sent a response based on who or what was requesting it
16:54
sure
that or you're hitting a different endpoint
but that doesn't seem to be the case
But stackoverflow isn't changing. I am requesting the same thing in both cases.
@KevinB But will it work with the syntax of css doodle? because angular throws template errors becaues of { } brackets etc
And Chrome Network debugger proves that I am indeed requesting the intended page and getting the correct response headers
It appears either there is some weird glitch with the https module or I am doing something wrong.
@BenBeri no idea
i don't angular
the article seems to talk about that though.
Could also create a wrapper of sorts for it, similar to this react port: github.com/css-doodle/css-doodle/issues/35
react has the same problem when it comes to the brackets etc
They just treated it like a string.
17:13
@rlemon you are probably looking at a different code...however, I think I got what the problem was...
17:26
I'm looking at the only code your provided.
slight change - month is 11
when it is 12 you get a false output
okay, but it's still what you posted and said logs false.
1 hour ago, by deostroll
This reports false. Live code => https://repl.it/repls/WeightyIrresponsiblePhase
so I'm not looking at 'different code' I'm looking at the code you provided as a runnable example.
17:49
moment expects a zero-indexed month
TIL ^ :)
Now there is a function defined as follows:
decimal(1/3, 2) = .33
decimal(1.5, 0) = 2
decimal(2.5, 0) = 2
The description for the function is: decimal(n, scale) - return n with given scale
I can't wrap my head around what the last two examples...
18:43
It's the length of the mantissa
Oh
Looks wrong to me
They follow the round to even rule
19:26
🚽
19:37
0
Q: How to prevent nested promises?

SpaceDogCSI'm creating an ionic project where I have to do many promises some of then MAY have anothers promises like this example this.Promise1() .then((data) => { if(logicTest){ return this.Promise2() .then((data) => { // ... })...

user10976548
Hi.
@Vakore 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.
user10976548
Was that a self-generated message?
user10976548
It was, wasn't it?
indeed
!!slidepoop
19:42
Mar 13 '13 at 1:40, by rlemon
(Random Fact, when rlemon was 13 he pooped on a slide. he isn't proud of it, but he felt it was time to confess. I'm sorry slide.)
user10976548
Ok.
20:04
Is there a library out there that can turn an async function into a worker?
20:14
wat
y
in most cases, an async function already does it's work outside of the single thread... it would gain little benefit from being in a separate thread
21:06
@DenysSéguret excellent answer
@SterlingArcher thanks. I've spent years trying to tell people JS wasn't as fast as the rumor told them and that V8 was one of the big revolutionq in software but I'm still amazed from time to time
To be fair, the majority of JS Devs never get into the weeds of the actual engine browsers are running
(me for example)
In most cases you think JS is slow but you actually deal with a fat DOM
I'm dealing with that right now actually
21:26
@KevinB Ok. When I run it from main.js it works.
(I get all the headers)
YES I FIGURED IT OUT
SORTA
(it works but I dont understand why)
const https = window.require('https');
instead of import * as https from "https";
@KevinB That's not true.
I can think of a CPU heavy function that I'd like to move to a worker thread, and model it as a Promise so that I don't have to deal with the thread creation directly in my code.
21:43
sounds like you're describing a synchronous action
It would be if I left it on this thread yes.
But as soon as I remove it from the main thread, it becomes asynchronous, even if it isn't IO or uses the event loop.
Right
i think we're saying the same thing.
you're describing the case where it would make sense to convert a synchronous task to an async one using threads... i'm saying if it isn't a synchronous task (as in it's either inherently asynchronous or you made it asynchronous using workers/whatever) auto converting it to workers wouldn't improve performance. it's already on another thread and therefore not impacting the performance of your javascript
i guess an exception would be if the logic you're trying to move isn't truly asynchronous... it's just a lot of synchronous code split up among a dozen or more callbacks sitting in the queue
21:58
Hi guys! Anyone use AND design in react? I have one error, may be someone can help me where's the problem
@VitaliyMckay 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.
@VitaliyMckay Ask your question. Someone will help if they can.
OK. I've create react app and use redux here. In main index.js file I have <Provider> and inside Provider is <App>. In App.js I choose with Router which page to show up. I've installed ANT design inside of one pages and import there Button component. After I tried to use this component I have an error inside main index.js: "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

Check the render method of `Button`."

And also in says that arror is in <App /> component where I'm choosing chich page to show up.
I did all as in ANT docs, but it's not working
 
1 hour later…
23:18
@KevinB I mean a JS web worker... I want to put an existing async function into a web worker, like await result = runInWorker(existingAsyncFunction)(...args). I know I could refactor the async function into a web worker but for ease of use it'd be great if I could just wrap the async function with a util...
i can think of quite a few problems with that
Yeah?
I mean sure, not any async function can be moved to a worker...
to move that function to a worker, it would need to take that function, as a string, and run a worker using it. It would also need to have access to any variables that said function is closing around
Right
which... is quite complicated
23:22
Well, lets say the function must be a pure function
i don't know what a pure function is
it does not access any external state
(n) => n * 1000
stupid example, but as an example, that function
righ
I just want to do something like this:
const result = await runInWorker((n) => n * 100)(2) // Promise that resolves to 200
If that's not possible, OK then
That's not an async function though
23:25
Yeah, it's not, clearly that was a misleading statement
a cpu intensive function
would that be more along the lines of what you're thinking?
sure
await runInWorker(cpuintensivefunction, someparam, etc);
but, also, the result is an async function, ie runInWorker(callback) returns an async function (a function that returns a promise and runs the callback inside a worker)
If it's a nontrivial function, you're probably better off running directly in the worker anyway
23:27
It's not a trivial function ;)
That's the point
It is locking the UI
Making it async does nothing because the function still runs in the UI thread
I want to put the work in a worker
I could refactor the function into a formal worker
Then do
Haha...
Ok. so.
take the function, put it in it's own module
and..
run it as a worker
lol
Yeah, but then I also have to setup postMessage communication
It would be nice.... if I could just do runInWorker(callback) ;)
that could be what your runInWorker method does
23:30
Haha are you trolling me
nah, not at all
like, you can have a runInWorker method that accepts the name of a module to run the worker with
pass it params
Ok... so does a runInWorker type of helper library exist out there? That's my question :)
Yep
and have it return a promise that resolves when the worker sends a particular end message
That sounds like what I want
If such a library already existed I would like that
Otherwise, yeah, that's the path I'm headed down
i'm not aware of one, and don't see one in a quick search, but i also haven't done much work with workers
23:33
yeah me either... this one is pretty close: github.com/andywer/threads.js/tree/master
i doubt you'll find one doing what you're asking
Why
because promises only resolve once
a worker can respond with multiple messages, be sent messages multiple times, etc
Yeah, it's limited compared to what workers can do, but surely a really common use case is just off-loading an expensive function?
kinda like a child process
23:39
Yep

« first day (3051 days earlier)      last day (2122 days later) »