News for hackers. Stuff that matters.

wa1987

Re:A Formal Theory of Spaghetti Code on Saturday March 12, 2022 @03:52PM (#30654772)
State charts / FSM's work wonders in these situations.
Re:Advice on JSX Conditionals on Wednesday March 09, 2022 @01:47PM (#30618447)
For these situations I often use IFFEs with if-statements and early returns inside.
Re:Code optimizations when using async/await on Tuesday January 04, 2022 @10:25AM (#29795718)
What's the pros/cons vs Promise.all([...])?
Re:Racket 8.1 on Friday May 07, 2021 @06:49AM (#27074488)
There's Clojure too.
Re:Starting a TypeScript Project in 2021 on Wednesday April 21, 2021 @10:12AM (#26889945)
> Please stop spreading this misnomer.

That's a fairly… direct way of putting it :-)

Anyway:

1. What are the key differences in terms of usage and use cases?

2. Why isn't Deno a 'wholesale' replacement for Node?

3. In which respect are the vastly differently inner workings relevant in regards to usage of both products?

Re:I Am Bezos on Monday February 22, 2021 @04:47AM (#26222572)
"Money earned"
Re:What color was “Apple Beige”? on Wednesday January 27, 2021 @10:02AM (#25929001)
One of your best bets might be the vintage keyboard community:

- https://www.modelfkeyboards.com/

- https://deskthority.net/

- https://geekhack.org/

Re:Run More Stuff in Docker on Saturday December 26, 2020 @09:08PM (#25548211)
There’s no need to in my situation. 99% of the files are dependencies installed through Composer (PHP) while building the Dockerfile. The few directories I need to work on directly are bind mounts and don’t have much impact on overall runtime performance.
Re:Run More Stuff in Docker on Saturday December 26, 2020 @06:56PM (#25547485)
> On a Mac, there is a major performance hit whenever you do disk IO in a bind mount (i.e. voluming a directory of the host system into the container). Working without bind mounts is extremely limiting. [..] If you’re using Docker on a Mac and you’ve never tried it on Linux, you owe it to yourself to try it on Linux.

Or use named volumes. I'm running a dockerized WordPress dev environment on my MacBook with average TTFB's of 40 ms.

Re:A Modern JavaScript Tutorial on Monday December 07, 2020 @02:04PM (#25335787)
> - for in loop - for of loop

It's 2020 and you still use loops? ;-)

source: https://github.com/buildo/eslint-plugin-no-loops

Re:A Modern JavaScript Tutorial on Monday December 07, 2020 @01:57PM (#25335692)
Agreed. I find myself using a pretty small subset of the language which definitely doesn't include the class keyword. Doubt I'll ever find it useful.
Re:A Modern JavaScript Tutorial on Monday December 07, 2020 @01:44PM (#25335492)
Often times operations are order-independent. Specifying those as sequential `await`-s does not make a lot of sense in those situations. I guess less fine grained control is desirable under such circumstances :-)

There's also other useful utilities such as Promise.all(), Promise.any() and Promise.race().

Re:A Modern JavaScript Tutorial on Monday December 07, 2020 @01:34PM (#25335375)
Re:macOS unable to open any non-Apple application on Thursday November 12, 2020 @06:07PM (#25076499)
> Well, how interesting that Apple's software is going to be bypassing Little Snitch, making it harder to discover and fix this sort of issue.

Source?

https://every-layout.dev/ is downright amazing for learning how to write robust layouts
Re:Thinking About Recursion on Sunday October 11, 2020 @09:38AM (#24745685)
Recursion never really clicked and felt intimidating until I read "How to Design Programs":

https://htdp.org/2020-8-1/Book/part_two.html

By far the greatest educational piece I've come across on this subject matter.

Re:Applying “make invalid states unrepresentable” on Monday October 05, 2020 @05:03AM (#24685874)
Related video on this subject: https://www.youtube.com/watch?v=IcgmSRJHu_8
> I usually modify HTML forms so that they won’t work and fix them with javascript. This gives me almost zero spam.

Interesting. One would assume that most spammers use automated browsers with JavaScript enabled.

Re:An Honest Review of Gatsby on Saturday October 03, 2020 @02:43PM (#24673871)
> If a static site generator put my images in the wrong place and required a gigantic JSON file to be loaded by the client for no reason I would not think twice to get rid of it.

Incorrect DOM-output is likely caused by common mistakes (e.g. conditional rendering based on `typeof window !== 'undefined'`) which screw up rehydration. Dealt with it in the past and seen a lot of developers struggle with it. This article describes it well:

https://joshwcomeau.com/react/the-perils-of-rehydration/

Gigantic page-data.json files are caused by querying more data than necessary to render a given template/component. Let's say you define a component named `EmployeeCard` that renders a name and photo given an `employeeId`. Now you need to query all employees and render the right one using `.find()`. All this data (including base64 thumbnails) ends up in page-data.json, even if you need to render a only single employee.

This is solved by querying only the relevant employee(s) in the template and provide the data (name + photo) directly to the `EmployeeCard` component as props.

I've developed quite a few websites using Gatsby (mostly backed by various GraphQL API's such as WPGraphQL and Strapi) and while there's lots to learn, it's been an enjoyable experience so far.

Re:Why is OOP still so widely spread? on Thursday September 03, 2020 @04:29AM (#24361935)
Maybe he's referring to closures.
For sure! Whipped up a quick pen:

https://codepen.io/willem-aart/pen/oNxwRXY?editors=1100

This is impossible to achieve with CSS Grid.

One might alternatively approach this 'cluster layout' using inline-block elements. However, these elements would then be separated by space characters and the width of the space would be added to any applied margins. These issues could possibly be resolved by resorting to hacks such as setting font-size: 0 on the parent. Not pretty.

On the other hand, when using flexbox, space characters between flex childs are ignored which makes it a good fit for this kind of layout.

Grid is not a superset of Flexbox. The former always controls the layout in two dimensions (rows & columns). The latter controls one axis and calculates the layout of elements per flex line.

Some layouts are impossible with Grid but a perfect fit for Flexbox and vice versa.

Re:Show HN: XState Game on Tuesday August 25, 2020 @04:29PM (#24275743)
Very impressive! Nice job. Love XState.
How does this differ from WPGraphQL? (https://www.wpgraphql.com/)
Re:Pantone 448 C on Thursday January 23, 2020 @06:52PM (#22133719)
White.
Re:Codem Ipsum: Lorem Ipsum but for Code on Friday November 15, 2019 @08:07AM (#21544427)
Re:Strategies for Long Projects on Monday September 30, 2019 @03:30AM (#21112590)
Could be. "Long" is a subjective concept.
Re:Think in Math, Write in Code on Thursday July 18, 2019 @11:55AM (#20471110)
The question was about expressing I/O as a mathematical concept (on paper), not about talking to compilers.
Re:Think in Math, Write in Code on Thursday July 18, 2019 @11:16AM (#20470685)
Agreed. I'd much prefer something along these lines as opposed to using an overly long name:

`

/* product of luminance and dot product of surface normal and light direction divided by scattering constant */

const prod = ...

`

Re:Think in Math, Write in Code on Thursday July 18, 2019 @11:07AM (#20470584)
On a similar note, this looks interesting as well (not affiliated): https://observablehq.com/

Older »