57 karma · joined Jun 29, 2019 (7y ago) · 23 submissions
comment 1y ago · link · parent
document.querySelectorAll('.menu-wrapper')).forEach(menuWrapper => {
const button = menuWrapper.querySelector('.menu-opener');
const content = menuWrapper.querySelector('.menu-content');
if (!content || !button) {
return;
}
button.addEventListener(() => {
button.setAttribute('aria-expanded', 'true');
menu.showPopover();
});
content.addEventListener('toggle', e => {
// reset back to aria-expanded=false on close
if (e.newState == 'closed') {
button.setAttribute('aria-expanded', 'false');
}
});
});
The React example seems a little odd as well, if the "open" callback actually called "showPopover()" instead of only calling "setIsOpen" then the "useEffect" could be entirely redundant. The resulting code would be a lot clearer imo.comment 1y ago · link · parent
I remember a close friend getting frustrated administering a working memory test on me. She couldn't believe how far removed from the norm my working memory capacity was given everything else she knew about me.
7.
Internet Archive Service Availability(archive.org ↗)
5 points · by irjoe · 2y ago · discuss
comment 2y ago · link · parent
double = fn a -> add.(a, a) end
double.(4)
It starts to look a bit like a weird untyped OCaml / F# if you use pattern matching: f = fn
x, y when x > 0 -> x + y
x, y -> x * y
endcomment 3y ago · link · parent
I never wear a helmet when riding a bike and used to commute daily. I've never had an accident involving traffic and have come off my bike less than a handful of times commuting. It seems like the odds of me coming off my bike and hitting my head is very low.
I'm not averse to helmets I just don't think wearing one makes sense for my commute. I'd rather wear a woolen hat. I do wear a helmet when I go rock climbing and would probably wear one if I was commuting in London.
comment 5y ago · link · parent
I like to think that making software easier to write will just free up more capital to be spent on other software problems. I haven't seen many software projects where the client doesn't compromise features due to budget or time.
comment 5y ago · link · parent
I'm slightly disappointed that it's already something I do day to day. I had hoped that the power of the REPL wasn't overstated.
comment 5y ago · link · parent
I can't imagine writing a program in its entirety in a REPL.
comment 7y ago · link · parent
def transform_data([_|[]]) do: []
I just wanted an example of using guard clauses. It does depend on the actual code though, there's probably a more elixiry solution.comment 7y ago · link · parent
def transform_data(raw_data) when length(raw_data) == 1, do: []
def transform_data(raw_data) do
# actual function code goes here
end
That said, I wouldn't want to see the above snippet in my team's codebase :)comment 7y ago · link · parent
I also write a lot of JS and tend to use guard clauses fairly liberally. I find they make boundaries (x < 0) much clearer. My functions are also < 10 lines in most cases. For me it leads to less convoluted code but YMMV.