« first day (3634 days earlier)      last day (1297 days later) » 

12:16 AM
Hey guys... just curious... Whats the smallest dataurl gif thats parseable in javascript/html
the smallest I could manage to create was a 0x0 gif
data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAEAAQAAAgA7
And I removed a single binary character for size
which shortened it
and its still parseable somehow
although the browser thinks its 256x256
I know this isnt exactly JS related
but I dunno where else to ask
Oh.. and heres the one WITH the size header still in it...
data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAgAAABAAEAAAIAOw==
 
 
6 hours later…
mr5
6:08 AM
o/
can you guys help me to optimize this recursive code I have?
function getProfit(node) {
	if (node.children.length <= 0)
		return node.profit;

	var maxProfit = 0;
	for(var n of node.children) {
		var candidate = getProfit(n);
		maxProfit = Math.max(candidate, maxProfit);
	}

	return node.profit + maxProfit;
}
I think doing this iteratively would be the way to go but I'm not sure yet how to do it.
 
 
4 hours later…
10:29 AM
@mr5 are you sure this function will not call itself infinite times in a loop if node.children.length is not equal or less than zero? I would rewrite the entire thing I don't maybe that's just me
 
@orrburgel 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.
 
try this one it's only 42 characters :P
14 bytes (for Chrome):
data:image/gif;base64,R0lGODlhAQABAAAAACw=
For comparsion purposes, Your shortest dataurl was 66 characters.
 
mr5
10:53 AM
@orrburgel yeah it wouldn't. I'm in charge of its environment and it's constrained at very specific case only.
 
 
3 hours later…
1:40 PM
Anyone seeing a typerror in my code?
It works perfectly fine
jshint says its fine
and the code has no issues, but no matter what, theres always a TypeError
its so strange
 
 
2 hours later…
3:25 PM
Have a weird problem with my JS code, couldn't find a reason for it. When I load up the program with Node.js, it doesn't return anything. Not the stuff I wrote for logging, nor any errors. View my code here: stackoverflow.com/questions/64089766/…
 
@ShadeOfLight 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've spent almost 2 hours searching around on Google for similar problems or solutions, without any result (did find some other useful things though). My guess is, that getting some variable that is badly defined stops the process without throwing an error (is that even possible?).
 
 
1 hour later…
4:39 PM
 
 
1 hour later…
6:04 PM
@Rounin How are you doing with Deno?
 
6:33 PM
hi
reactjs list tag not working setList(['<li> how are you sir? </li>',...list,])
always forgetting, can someone help me?
 
@NIKHILCHANDRAROY what?
 
 
2 hours later…
8:18 PM
anyone here?
 
Just us python people
 
python peeps will do :D
I simply have a problem with cors, which I dont yet fully understand
 
Python people who don't know web dev ("close the gate!")
 
but I have trouble reproducing the situation in Postman
do, I am a bit lost
Mibael!
you sneaky snek
hmm... my problem is less troubling atm... but gonna be a problem in a week or so
 
mr5
9:22 PM
shoot @Wietlol
 
I have a website made in react and a back end web service
the web service, I have already hosted
but I want to build the react website on my local machine
so, I am doing request from origin localhost:8080 to the live server
I now allow all origins on the server, but eventually, I don't want to do that
and I cannot host the web server locally
 
mr5
so you want request from specific origin only?
 
not sure what I want
I suppose I want to keep the cors protection
but I do want to access my server from localhost
which are conflicting desires
 
mr5
I think the header supports some wildcard thing
 
perhaps someone in here has experience with it
I now return
.withHeaders(mapOf(
	"Access-Control-Allow-Origin" to "*",
	"Access-Control-Allow-Credentials" to "true",
))
 
mr5
9:27 PM
cors: 'localhost, live-server*'?
 
hmm... maybe
 
mr5
sorry just woke up
 
I should go to sleep :D
 
mr5
it's only 11pm there noob
 
and?
 
mr5
9:30 PM
wait till dawn
 
I mean... I prolly wont sleep for the upcoming 5 hours...
and then power nap
quick charger style
 
mr5
15 hours ago, by mr5
function getProfit(node) {
	if (node.children.length <= 0)
		return node.profit;

	var maxProfit = 0;
	for(var n of node.children) {
		var candidate = getProfit(n);
		maxProfit = Math.max(candidate, maxProfit);
	}

	return node.profit + maxProfit;
}
do u no da wey hir?
convert to iterative
 
ew, Javascript
I mean... this is totally not the Javascript room /s
 
mr5
this is ecma room
 
looks like an... n-ary recursion
not much you can do there
you need some form of a stack
and the function stack is probably the fastest then
 
mr5
9:35 PM
yeah was looking into it and it put me to sleep trying to think how to do that
 
why do you want it to be a non-recursive function?
 
mr5
SO/OOM with certain input
 
hmm...
you could make a stack (basically an array) of your relevant data
in your case, the node, index of the child or iterator, max profit
 
mr5
was looking into this but I think I need to convert this first into a proper recursive form to be able to follow along
 
that article probably only looks at singular recursion
where each iteration invokes one child call
you have an n-ary recursion, where you have many child calls
you cant tail recurse that
 
mr5
9:43 PM
hmm, I think adding more argument into the function would do
I did try some tweaks on the original function and ended up with this:
function getProfit(node, maxProfit = 0, i = node.children.length - 1) {

	if (i <= 0)
		return node.profit + maxProfit;

	if (node.children.length <= 0)
		return node.profit;

	return getProfit(node.children[i], maxProfit);
}
now, my problem with this is the i parameter.
if I would be able to convert this into a proper recursive form, that is, can be trimmed into tail recurse, I think I could follow along with the link I mentioned.
shoot, that's not even the same. I forgot the Math.max...
@Wietlol will this be two loops? one for pushing one for popping?
 
9:58 PM
do you have test data?
that should be it
(kotlin ofcourse :D )
 
mr5
@Wietlol wow! I'll have a look.
 
not sure what a nice equivalent of iterator is in js though
I can compile this code to JS, but im not sure that will make you any more happy
 
mr5
ugh, about the data... I think I need a nodejs first. I'm currently running this in Chrome browser.
 
I tested it with my mind, so it should work 100%
but still... "should"
 
mr5
the continue@outer could be break also right?
 
10:06 PM
just like you should still be doing a test yourself
doing a break will mean you are done with your current stack node
then, it will set the temp (result value) and pop the last node on the stack
you need to skip that as well
oh wait, it doesnt work 100%
if (temp != null)
{
	top.maxProfit = max(top.maxProfit, temp)
	temp = null
}
once temp is consumed, it should also be reset
 
not sure if it makes any difference though definitely makes difference
 
mr5
you should loop on it though for(i ... data) getProfit(i)
max profit should be 4
 
that is not a node though
 
mr5
maybe I can try this in AS
 
10:10 PM
should I put a node around it with 0 profit?
 
mr5
structure of my node:
var node = {
	i,j,
	buy,sell,profit,
	id:idGenerator++,
	children:[]
};
@Wietlol no
constraint is profit > 0
 
output 4
 
7
 
mr5
oi
that's correct
let's see
I'm trying to build it in AS
@Wietlol what JSON lib do you recommend in Kotlin?
 
10:20 PM
jackson
fasterxml
I have to put a 0 profit object around your array though
otherwise, it is not a node
and 0 profit node is sufficient
it would then be 0 + maxProfit
 
mr5
ah
my approach was to loop into it
like this: for(i ... data) where i : Node => getProfit(i)
 
ye... but then you still do recursion
although, you can use an index instead of the iterator
I suppose that is the easiest to implement in JS
dat moment when I thought Material UI had nice handling of layout... and then I see this heresy
 
mr5
10:37 PM
css on steroids
wait. is that Dart?
 
that is JS
 
mr5
ha
 
I need a proper split panel and quad panel
not this margin heresy
 
mr5
y u doing mobile now?
 
doing a website for Wietbot
with an internal sandbox
and a logging view
 
mr5
10:39 PM
oic
 
and a list of clients so I can turn the SO client on/off at will
without being in my private environment
also, will host documentation and shit
 
mr5
nice
is the codebase for wietbot generic enough?
I mean, can it be ported to other chat system as well?
how do you log in Kotlin?
println
 
println() is the default to std::out
in kotlin/js you also have console.log() on top of that
the first will do a console.log(it.toString())
so sometimes a console.log is more useful
but println is more... reliable
 
mr5
@Wietlol booya! tis working mate!
 
Wietbot runs almost entirely in AWS Lambda, which reads the std::out and ports it to AWS Cloudwatch, which I then read and move to sql
so in my applications, yes, I do println for logs
@mr5 yay
you translated it to js?
or does the kotlin version work?
 
mr5
10:46 PM
it's working in my AS :D
not yet translated
I've copy-pasted the getProfitNonRecursive and tweak a bit
hmm. what is your thought process when converting recursive into iterative?
 
for n-ary recursion
 
mr5
I still can't wrap my head around how did you do that
 
1, what is the stack data that you need?
2, when do you create a new level?
3, how do I merge a level closing (pop) with it's parent?
I suppose I could make a generic function for this
 
mr5
specific for n-ary right?
is it n-ary or m-ary? Google suggest m-ary
6
A: Is there any difference between an n-ary and an m-way tree?

Petar MinchevFrom Wikipedia: In graph theory, a k-ary tree is a rooted tree in which each node has no more than k children. It is also sometimes known as a k-way tree, an N-ary tree, or an M-ary tree. A binary tree is the special case where k=2. So the answer your question is: Yes, it is the same ...

izz the same thing
 
11:03 PM
the code is always the same afaik
 
mr5
11:41 PM
nodeStack.push({
	profit: item.profit,
	children: item.children
});
this code looks like I am exploiting children xD
 
parent.remove(child)
 
mr5
parent.kill(child)
unfortunately...
 
are you sure you are not infinitely recurring?
 
mr5
If I put breakpoints onto it, it is not doing OOM
 
how many nodes are in your data?
approximately?
in powers of ten
 
mr5
11:54 PM
10^5 I think?
exactly 259,976 nodes.
each have a reference children on the same tree
 
do you have a json of that?
 
mr5
JSON.stringify can't handle it
I have this function with complexity of O(n*n) crashing atm
maybe I should do this in C++
 

« first day (3634 days earlier)      last day (1297 days later) »