« first day (2826 days earlier)      last day (2347 days later) » 

22:10
i have this method on a react component and its crashing.
  makeD3 = () => {

    const ref = this.refs.node
    console.log('ref')
    console.log(ref)

    // const refFirst = this.refs.node[0]
    // console.log('refFirst')
    // console.log(refFirst)

    const r = select("body")
    console.log(r)

    const r2 = r.select(ref)

    console.log(r2)
  };
why do you post such large snippets of code narrow down the problem
i logged out ref and its a valid dom node. so the d3 select function is error'ing out with Uncaught DOMException: Failed to execute 'querySelector' on 'Element': '[object HTMLDivElement]' is not a valid selector.
its like 10 lines.
ref is a dom node, right?
22:11
a dom node is not a valid selector.
that's 9 lines too many
@Rick
so you don't know whats wrong?
well thats how i've traditionally seen react/d3 integration work
they select the ref they get
@Rick since you have ~n^3 combinations to begin with I don't think you can reduce it by much
...
22:16
@ShrekOverflow so it can't be done iteratively in linear time?
@Rick i doubt it
but i haven't given much time to it
atleast in JS you are gonna have to build the string
ya I tried building the string closest I got was maybe n^2 but it was ugly as melted icecream
you could create a tree
A tree what would a primitive version of that look like?
In computer science, a trie, also called digital tree and sometimes radix tree or prefix tree (as they can be searched by prefixes), is a kind of search treeā€”an ordered tree data structure that is used to store a dynamic set or associative array where the keys are usually strings. Unlike a binary search tree, no node in the tree stores the key associated with that node; instead, its position in the tree defines the key with which it is associated. All the descendants of a node have a common prefix of the string associated with that node, and the root is associated with the empty string. Keys tend...
22:20
so each node in the tree would represent what?
a letter
but i don't think that'll work either
and also you'd end up with teh same complexity
This would probably qualify for a map-reduce :D
['a
a tree structure would be good where a decision will yield another avenue of possibilities. Here the possibilities are an arrow in time moving to the right of the array. like a train laying down tracks along the interval of its length
maybe I'm just thinking about the problem in the wrong way. If there was a way to merge tow undefined but matching length arrays without walking them it would most certainly be possible
> merge tow undefined but matching length arrays without walking them
how would that even work ?
that was my first thought too but then I immediately discarded it
let a = [], array.length =5 let b = [], array.length=5; b.fill(5) b = a
since the index match, they would just to occupy an instance
javascript does not iterate over undefined values in an array
could do some gnarly things with that, where the unknowns could be values that are known in a different space
22:44
Just discovered array.reduce() is slow as crap (heartbroken)
I would be a huge benefit to be able to grab/assign values without being able to iterate over them.
if you say reduce is slow, you probably do not know the benefits of reduce
Uhm...
Actually, more that I did a jsperf and sadly discovered its slow as crap
For a particular use-case, obviously
Much faster to forEach and assign to an object than to reduce the object
But I love the syntax of reduce
But, I hate how slow it is in my app. Narrowed a performance problem down to it. Replacing with forEach made a huge improvement.
why are u using reduce when forEach will suffice?
> But I love the syntax of reduce
That's a fascinating question... why do we write in javascript when binary will suffice
22:50
real programmers...
I think that you are using reduce in a manner inconsistent with its design
Waaait a sec, yes I'm an idiot. The slowness wasn't the use of reduce(), but the fact I was returning {...acc}
Which is definitely not inconsistent with reduce's design, but not reduce's fault either
I'm talking about this (clean but slow):

return array.reduce((map, item) => ({
...map,
[`${item[key]}`]: item
}), {});

Vs this (faster):

return array.reduce((map, item) => {
map[`${item[key]}`] = item;
return map;
}, {});
@Aaron 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
a blanket statement like, reduce "its slow as crap" because of your jsperf test does not inspire much confidence
I wasn't looking to ;)
How do you format code... code fencing doesn't seem to work
22:59
so you came here to talk smack
put it in its own message and ctrl-k
Huh, couldn't get it to work...
@Rick chill
@Aaron 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
formatted message
23:01
return array.reduce((map, item) => ({
...map,
[`${item[key]}`]: item
}), {});
@Aaron Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
you're not doing ctrl-k man
it'll indent your message
there you go
I am, its indented...
Oh the other message had a line not indented...
That's formatted? No syntax highlighting or anything?
no lol
this is glorified IRC
Ha ok, that's cool I guess
Yeah
23:03
is that how you are using reduce
I am going to let @forresthopkinsa help you out with this one :)
@forresthopkinsa you live in the grand canyon?
yes. I live inside the canyon
the internet isn't great but it's livable
anyway thanks for reminding me that I need to update that
So what do you guys do for fun? stare at boulders.
throw rocks at tourists
23:13
you could say that you guy have a rocking good climb
you could
get it, because people who live in the grand canyon have lots of rocks and boulders to climb
why does Arizona have a star on its flag when it's not the lone star state? Why did you guy steal the Texas star
it's a copper star
'cause there's a lot of copper here
23:23
The only part of Arizona worth keeping is Flagstaff. We should give the rest away to mexico
flagstaff is v depressing
Arizona is very depressing
eh
you get used to the heat, the weather is nice
only possible natural disasters here are droughts and flash floods
phoenix has pretty much everything, but it's a city that grows horizontally instead of vertically, so it's not crazy expensive to live there or impossible to find a parking spot or anything
That might be the brain damage talking. You can't leave the house during the day without the risk of skin cancer or heat stroke.
flagstaff is cold and bleak and people can hardly stand living there for extended periods of time
lol you're not wrong. You don't spend time outside during the summer, that's for sure
Not until monsoon season starts anyway, and then it's just the most beautiful weather
something you'll notice is that everyone in Arizona basically worships the rain
23:31
you mean when it's super humid and hot. I don't think you have lived outside of Arizona. Arizona is hell on earth it's where stupid poor young people go to buy big houses cheap.
because it's in hell
rain has a depressing effect in a lot of places but AZ is the polar opposite. On a rainy day, people go outside to stand in the rain. People get up from their desks to go stand at the windows and watch the rain together
nah it's almost never humid and hot in phoenix
also -- Phoenix isn't the fifth largest city in the U.S. because land is cheap (it's reasonably inexpensive but there are definitely cheaper places)
it's huge because big tech LOVES the stable weather and lack of disasters
dude the air is thin, Phoenix is a 1000 feet above sea level.
> the air is thin
lol ok
1000' is relatively low
I mean, I don't know by what reference 1000' is a high altitude except maybe like san diego or something
Arizona is terrible. it's nothing like San Diego. I don't mean to bash on your home state but... I doubt very much that any part of Arizona is habitable with the exception of maybe Flagstaff.
welp I don't know what to tell you man, the statistics disagree
23:57
The statistics also say Arizona also has one of the highest suicide rates in the country.

« first day (2826 days earlier)      last day (2347 days later) »