HNHacker News
TopNewBestAskShowJobs

bhl

1,498 karma · joined February 19, 2017

thinking about the world through unrealistic models · interested in the intersection of tech and everything else

https://github.com/BrianHung cv.brianhung.me

submissionscomments
bhl··on Ask HN: What novel tools are you using to write web sites/apps?
> add non-default variations (mostly different heights/widths than what it ships with).

Check out https://github.com/tailwindlabs/tailwindcss-jit. It got released 3 weeks ago, and supports variable variables in width and height now.

bhl··on Ask HN: What novel tools are you using to write web sites/apps?
> framework recreates css rules with class names

Pretty much, but that concept by itself is underrated. By having all of the CSS inline on your components, the developer doesn't have to click on a class name and find the css file associated with producing that class.

Tailwind is also a design system, so some non-obvious rules like box-shadows, colors, font-sizes are pre-picked. That means instead of remembering what font-size to use for a figure caption, "was it 0.85rem or 0.75rem", you can just use `text-xs`. Design constraint is good here because you get a consistent look throughout your app. It's kind of like having global css variables: by modifying your tailwind.config.js, you can change all `text-xs` to a different font-size now.

And then when you want to break out of that design system, "I need something smaller than a caption, say text-2xs", you can extend tailwind by defining your own atomic class names.

> benefit of using it vs something like bootstrap

Haven't used bootstrap since my first basic website years ago, but it seems like a vanilla js component + css library. Tailwind is primarily a css library, so you can use it with React and Vue as well. The way you install Tailwind is different too: Bootstrap you put into the head of your document and no build step is required; however, with a build step, you can remove unused css to get the minimal working spreadsheet.

bhl··on Ask HN: What novel tools are you using to write web sites/apps?
- tailwindcss

I moved a React side-project from CRA to Next.js for server-side rendering benefits, but the latter doesn't support directly importing css styles in jsx to avoid problems with the global scope.

The two options offered were CSS modules and CSS-in-JS. I didn't like either approaches having hashes in the classname when opening the website in devtools, and both seemed too locked into React/JSX.

Tailwind 1. doesn't have component framework lock-in 2. doesn't make me think of css classnames 3. atomic classnames are readable in dev tools 4. provides default colors and box shadows, etc.

In addition, they're starting to make a render-less component library (https://headlessui.dev/): that means you can customize how components look without having to understand how its javascript internals work, which I'd find a huge plus compared to other libraries like ant design or material-ui.

- vite + react

More beginner friendly than webpack in starting a new project, and faster developer experience: page reloads almost instantly when you're modifying a component.

bhl··on What I learnt after burning $10M as an entrepreneur
It's mentioned in the thread:

> I was a huge to-do list junkie, but back then all of the task apps were either single-player or weird desktop apps with syncing issues.

> I decided to build a shared to-do list app for teams.

Yeah, simple single-player to-do lists are great beginner projects to do to learn CRUD and a frontend framework. But enabling real-time multiplayer ups the ante because now you have to manage state and updates between multiple clients and a server.

bhl··on HN was down
I was trying to point out in my original comment that some people maybe pre-maturely optimizing for scale, and having tooling drive decision-making rather than problems at hand. And a good logical short circuit to that would be: "if Hacker News serves 6M requests per day, then using docker would be overkill for a small CRUD app".

That being said, if modern websites were rated by utility to user divided by complexity of tech stack, I must say Hacker News would be one of the top ranked sites compared to something similar like Reddit or Twitter which at times feels... like a juggling act on top of unicycle just to read some comments. :)

bhl··on Add a Dark Theme to a Ruby on Rails App
See https://developer.mozilla.org/en-US/docs/Web/CSS/:root#decla....

With :root, you can write css variables that can be accessed by any other element on the page (?).

So to implement a light and dark theme, you could have something like `@media (prefers-color-scheme: light){ :root { --bg-color: #FFF; }`, and then have the body element use that via `body { background: var(--bg-color); }`.

bhl··on HN was down
Can I ask a question that's half facetious half serious (0.5\s): does hackernews use docker or any containers in its backend? With 6M requests per day, if it didn't use containers, HN might be a good counter example against premature optimization (?).
bhl··on Local-First Software:You Own Your Data, in Spite of the Cloud (2019) [pdf]
Have you seen Kleppmann's automerge library? https://github.com/automerge/automerge
bhl··on Stop Using Icon Fonts
You can also have SVG sprite sheets if you use the `use` tag.
bhl··on Stop Using Icon Fonts
I'm not sure if this library is better. If you're making an XHR for each inline svg, then that's a lot of unnecessary network requests compared to a dynamically generated svg sprite-sheet at build time. The latter is definitely possible with a pre-defined sprite UI library like Material Design or Font Awesome mentioned in the blog post.
bhl··on CodeMirror 6
I had a similar experience starting out with ProseMirror; I wanted to make something similar to the editors in Dropbox Paper and Notion, and found an out-of-the-box rich text editor called tiptap built onto of it.

They already had nodes for images and embeds [1, 2] which made development easy (I would recommend checking out the source code; its about a hundred lines of code for each, and simple). But as I made more custom nodes, I learned pretty well the internals of tiptap and how it used ProseMirror. And over time, I've come to appreciate knowing its api.

So if there's any advice for people trying to get started with ProseMirror, I would say to look at libraries which built upon it as example code such as tiptap or the outline rich-markdown-editor [3].

[1] https://github.com/ueberdosis/tiptap/blob/main/packages/tipt...

[2] https://github.com/ueberdosis/tiptap/blob/main/examples/Comp...

[3] https://github.com/outline/rich-markdown-editor

bhl··on CodeMirror 6
OP should try out ProseMirror [1], which is the rich-text editor sibling of CodeMirror. And if you like ProseMirror's API, CodeMirror 6 is structured similar to it.

[1] https://prosemirror.net/

bhl··on Statement of SEC Regarding Recent Market Volatility
What do you mean by not helpful. From the wikipedia on LTCM,

- The contributions from the various institutions were as follows:

- $300 million: Bankers Trust, Barclays, Chase, Credit Suisse First Boston, Deutsche Bank, Goldman Sachs, Merrill Lynch, J.P.Morgan, Morgan Stanley, Salomon Smith Barney, UBS

- $125 million: Société Générale

- $100 million: Paribas and Lehman Brothers

- Bear Stearns and Crédit Agricole declined to participate.

https://en.wikipedia.org/wiki/Long-Term_Capital_Management#1...

bhl··on Discord bans r/WallStreetBets server, subreddit went private for a while
For numbers, r/wsb had around 2.3m yesterday morning (Wednesday 3 am) and now has 4.3m members, so that's a jump of 2 million new in less than a day.
bhl··on Ask HN: What are some non-realtime use cases of CRDT?
You can also use CRDTs for offline mode.

Say you wanted to build a rich text editor, which can't diff-and-merge as easily as with plain text. Instead of using git for version control, you can use CRDTs very similarly by fetching the remote state, merging with local state, and then pushing.

In that sense, you could build local first software with interoperable hosting platforms (like Github for git) [1].

See [2] as an another example but for a budgeting app.

[1] https://josephg.com/blog/crdts-are-the-future/ [2] https://actualbudget.com/blog/porting-local-app-web

bhl··on Elon Musk moves to Texas
I would think being a billionaire, there isn't significant difference in quality of life living in California vs. Texas either. The "I'm ok paying them what I owe" also overlooks the public spats on Twitter and with re-opening the Fremont factory which got shutdown because of covid.
bhl··on Show HN: This website is valid JSON
This is pretty close to how ProseMirror, a rich-text editor, manages its content state.

Example of a schema: https://github.com/ProseMirror/prosemirror-schema-basic/blob...

Example of a document converted to JSON: https://tiptap.dev/export

bhl··on Show HN: I created the easiest way to share and collaborate on links on the web
SeeLink is more similar to a Google stealth product, https://staykeen.com/. Did del.icio.us have collaborative boards?
bhl··on Notion.clone: open-source notes editor like in Notion
ProseMirror is more of a framework for building text editor libraries; Slate and Draft are drop-in, easier-to-integrate text editors.

In addition, ProseMirror is built with JavaScript, and would require writing custom code to adapt to Vue or React. Slate and Draft are both built with React, which has it pros and cons. For example, using React means on each key press it’s going to run it’s whole virtual dom diff algorithm resulting in a higher input latency [1]. ProseMirror is more performant in this case by not using React and managing its own editor state. But Slate and Draft, by using React, gets easy server side rendering.

If I were to build a clone of Typora or Bear, I’d use Slate because 1. those editors are close to what Discord has as its chat editor and Discord uses Slate 2. Slate has better markdown support out of the box.

However if I were to build a Notion clone more focused on WYSIWYG, then I’d go with ProseMirror.

I wouldn’t go with Draft in any scenario since the community seems smaller and the library is less maintained, although twitter uses it.

[1] https://juretriglav.si/what-happens-when-you-type-a-single-l...

bhl··on Notion Timeline View
> Slack & notion make me close my eyes while typing, just because the delay between key press and pixels lighting up is so long that I get confused. It's like speaking with a 400ms or so echo of yourself being played back. Hugely distracting.

That reminds me of this blogpost [1]. It's definitely possible to optimize the input latency of rich text editors in the browser: they just have to be close to the metal of the 'contenteditable' browser api.

[1] https://juretriglav.si/what-happens-when-you-type-a-single-l...

bhl··on Notion.clone: open-source notes editor like in Notion
> the latter I find clunky and hard to build on top of

If you learn ProseMirror [1], then building on top of outline's rich-markdown-editor or tiptap (which is also ProseMirror based) should be easier. What issues are you currently running into with extending that editor?

[1] https://prosemirror.net/

bhl··on California Voters Exempt Uber, Lyft, DoorDash from Having to Reclassify Drivers
The difference in my opinion is with gig workers, there’s a contrasting concentration of power in the hands of a few companies, and those companies play a substantial intermediating role in matching “contractors” with customers.

From the exemption list, is there any that rival the likes of Uber or Lyft?

bhl··on Academic Substack: Open, Free, and Subject to Review
Substack allows writers to create their own paid newsletters and blogs without the hassle of setting up payments or worrying about gmail's spam filters; it also gives writers more control over their relationships with subscribers, since they can export the mailing list. That's the gist.
bhl··on Create React App 4.0
Both the standard react router and nextjs framework are open source.
bhl··on Full-Bleed Layout Using CSS Grid
A compromise might be to hide navigation elements or margin notes until you hover / click on an element, sort of like how Wikipedia enables page previews on internal links.
bhl··on CRDTs are the future
For specific use cases where the data format is not plain-text and or is formatted as json (e.g. Jupyter notebooks, rich text editing like ProseMirror), I can see CRDTs being used to automatically merge files and retain consistency. Two things though:

1. this doesn't require modifying git's merge algorithm itself; just having custom merge drivers built on top.

2. Is using more space (edit history of CRDTs vs a regular json document) worth it for automatic merging?

bhl··on Neue Haas Grotesk (2011)
My go-to sans-serif font is always Inter (https://rsms.me/inter/), which feels similar enough.
bhl··on Universal Basic Income is Capitalism 2.0
It's not a feasible solution for _everybody_. However on the net, by giving that option to _all_ renters, you will discourage the population of landlords from increasing rent in general.
bhl··on Universal Basic Income is Capitalism 2.0
Yes, but UBI lowers the risks involved in moving.
bhl··on Universal Basic Income is Capitalism 2.0
> figure out what American public housing has done wrong (namely the idiotic towers in a park idea) and fix it

I think an issue with this approach is that it's top down, as as mentioned in the article, "those at the top can’t manage all the information about the economy".

A counter-argument may be to just let towns and cities decide what to develop then, since local people have the best information about their neighborhoods. However, 1. this is already the default method and has resulted in housing crises where NIMBYism is rampant. 2. UBI would also help in this case as you're increasing the demand for housing while increasing competition between people living there and not (assuming people want to move to the area in the first place).

← PreviousPage 5 of 13Next →