Better HN
topnewbestaskshowjobs
Log inSign up

hakunin

2,515 karma · joined Mar 4, 2010 (16y ago) · 549 submissions

https://max.engineer, mastodon:ruby.social/@maxim, x.com/hakunin, bsky.app/profile/max.engineer

meet.hn/city/43.1009031,-75.2326641/City-of-Utica

---

Submissions

comment 3y ago · link · parent

The gem is just for declaring struct keywords (slightly more featureful than vanilla structs). Validation is left up to ActiveModel::Model. I would do a setup like this:

    class ApplicationForm
      extend Portrayal
      include ActiveModel::Model

      class << self
        def from_params(params)
          new(**filter_params(params))
        end

        def filter_params(params)
          params
            .require(model_name.param_key)
            .permit(*portrayal.keywords)
            .to_hash
            .transform_keys(&:to_sym)
        end
      end
    end

    class MyForm < ApplicationForm
      keyword :first_name
      keyword :last_name

      validates :first_name, :last_name, presence: true
    end
Can use it in a controller action like

    form = MyForm.from_params(params)
    if form.valid?…
      # the usual
One of the good things about this approach is that you can also use this object in form_for/form_with in your views.

comment 3y ago · link · parent

I've had great success building form objects with portrayal (https://github.com/scottscheapflights/portrayal) and ActiveModel. You can put validations into them, and auto-filter the params by making a `from_params(params)`-type constructor. In it you can call require/permit with `portrayal.keywords`. You're right that it'd be nice to have this out of the box, but this is just a few lines of glue code to setup. I'm in the process of making a new app template that does that.

comment 3y ago · link · parent

That's true for everything. And yet we still do… everything.

comment 3y ago · link · parent

I wasn't talking about humanities, I was talking about the general value of PhD in response to the parent. Don't know what exactly they study in humanities, but I guess at least some of it has to be done with high rigor and precision.

comment 3y ago · link · parent

From a bystander's perspective (I'm nowhere near a PhD, but have friends who are), I think there's value in learning academic rigor (which is what I think PhD does). I see it like learning to submit a high quality PR into a field of science. You learn to make sure everything you do is well-written, properly backed up, tested, verified, reviewed. There are just way too many ways for humans to come to the wrong conclusions, make unintentional assumptions, or miss alternative explanations. A highly passionate person without academic training is more likely to find themselves falling into these traps. (I'm sure there are notable exceptions). I think with all its flaws, PhD might be the last bastion, in principle, where you're trained to be insanely precise and pedantic. The reality is a lot messier than the ideal, but it's still a valuable pursuit.

comment 3y ago · link · parent

Long names should be a signal that you’re breaking away from current context or doing something unusual. Unnecessary length and redundant context makes names more difficult to discern. I wrote about it a bit more in the “what?” section of this post: https://max.engineer/maintainable-code

457.

Rails – narrative vs. model centric approach(max.engineer ↗)

1 points · by hakunin · 4y ago · discuss

comment 4y ago · link · parent

On Sublime Text Chelevra[1] has been my favorite for a long time. Lately I've also been using a couple of Alabaster[2] variations. To me the most important thing is to have just enough color. I find too much color distracting.

[1] https://github.com/jhermsmeier/chelevra.tmtheme

[2] https://github.com/tonsky/sublime-scheme-alabaster

459.

Good Engineering is not Premature Optimization(max.engineer ↗)

2 points · by hakunin · 4y ago · 1 comment

comment 4y ago · link · parent

Agree with everything, and additionally I keep getting off-by-1-key typos that I didn't have years ago. Especially (for some reason) when trying to type space or backspace.

461.

It's Not Premature Optimization(max.engineer ↗)

1 points · by hakunin · 4y ago · discuss

462.

It's Not Premature Optimization(max.engineer ↗)

2 points · by hakunin · 4y ago · discuss

comment 4y ago · link · parent

I wouldn't write these off entirely. One of their positive outcomes is that you get to switch. Switching is important so you don't get bored or fed up. Just don't take these things too seriously, and don't stick your newfound hype into everything. Let things breathe, sleep on them. For like a few months or years.

comment 4y ago · link · parent

Sometimes this advice is taken the wrong way, and people begin assuming that applying any thought to code design is "being obscure and clever" and "finding contortions". Some of the cleanest, most boring code I've written came out of days of contorting and experimenting to arrive at something that looks entirely boring and obvious. On the other hand, when code is quickly and simply added on, it grows into thousands of lines of messy entangled functions and types that are impossible to follow. We gotta make sure that people don't get the wrong idea with this advice. Simplicity can sometimes take more work and cleverness to achieve than complexity.

465.

I Love Ruby: 65LOC for Neat Atlassian Document Format(github.com ↗)

1 points · by hakunin · 4y ago · discuss

comment 4y ago · link · parent

This has been honestly the best no-barriers blogging experience for me. No publishing, no committing. Just open an editor and create or edit files. They sync via Dropbox. Made a typo in a published article? Just edit the file. Handles HN front page without any issues (it’s a static site deployed to a cdn). Author has been providing amazing support.

Also very convenient for casual writing/editing from any device where an app can sync via Dropbox. Can fix a typo on an iPhone via something like 1Writer while on the go.

467.

Sshfs Is Orphaned(github.com ↗)

191 points · by hakunin · 4y ago · 98 comments

468.

Ask HN: How do you plan back end work?

4 points · by hakunin · 4y ago · discuss

comment 4y ago · link · parent

Falling into the CMS trap[1] at a sensitive time in a startup can kill the business. In brief: when you try to build out too much complexity up front, everything easy becomes hard, everything hard becomes impossible, and generally any change takes too long. And since sometimes you don't have the luxury/runway to retry, you are stuck with it.

[1]: http://max.engineer/cms-trap

comment 4y ago · link · parent

I switched to Fastmail with my own domain (max.engineer), and as I'm changing email on various services, I'm running into the same issues. Synchrony bank and treasurydirect.gov are among the offenders. My solution for these sites was to use another domain I own (a .com) mapped to the same Fastmail account.

My preferred email validation is a combination of string contains '@', actually sending a verification email and/or making an MX lookup.

comment 4y ago · link · parent

While I won't argue that many Russians are indeed nationalistic and pro-Putin, that thread shows the opposite. All anti-war comments are upvoted, anti-west downvoted. Some comments are sarcasm/irony, maybe it was lost in translation.

comment 4y ago · link · parent

I used to find it boring. I always wanted to be objective, and not just say "you have to do it because I said so". I had to dig deep on every one of my gut feelings. I had to do a ton of unpacking of my own instincts. Sometimes I had to correct my own advice when it went from good to bad due to some contextual change that I haven't predicted. Other times I had to argue against good practices that are commonly accepted, because turns out, they aren't always good. Once I realized that all of this stuff has objective underpinnings, and can be unpacked down to some foundational reasoning, the whole thing became incredibly fun. My brain became preoccupied breaking down complex subjective ideas into simple objective ones. Like I got my own source of content in my head. It got especially exciting when I succeeded unpacking some long-term architectural advice that doesn't have any short-term benefits. Not everyone is into that kind of thing though.

comment 4y ago · link · parent

I don't see this answer, so here's my 2c.

I think there is a small distinction in the act of engineering vs. developing, but we all cross that line without noticing. Software engineering is the process of finding the most efficient solution within your constraints by leaning on algorithm/datastruct fundamentals. For example, you don't look at a tool's marketing page, you look at what it's built upon, how it operates, and based on these fundamentals you understand how performance, reliability, and cost will scale. If the fundamentals are too complex, you might have to do some measuring. If you evaluate or build new tools on this basis, you engage in some software engineering. I don't think this has to be some sort of superior gate-kept thing. It's just a kind of work.

We could make a stretch and claim that there's also "fundamental analysis of maintainability", but I firmly believe[1] that maintainability is subjective. We don't call writers "story engineers", and I wouldn't call any immeasurable and subjective work "engineering".

Edit with additional thought: I think there is a perception downside to both: developer and engineer. The "developer" downside is that you're more likely to be perceived as someone who doesn't care about fundamental analysis, and you focus on getting things to work only in the conditions you're familiar with (i.e. on my machine). The "engineer" downside is that you're more likely to be perceived as someone so fixated on the measurable, that you completely ignore the taste and maintainability aspect (falling into the McNamara fallacy). If you can't measure it, it's not worthy of your time.

There are just perceptions, not reality. Naming is hard.

[1]: https://max.engineer/maintainable-code

comment 4y ago · link · parent

This is spooky. I just read this post, cmd+tabbed to my mail app, refreshed, and got a version of this exact email.

I never have problems with gmail+spam otherwise.

comment 5y ago · link · parent

Nice, tweeted it crediting this comment: https://twitter.com/hakunin/status/1467223381854539791.

comment 5y ago · link · parent

The problem is that predicting how a business might evolve is pretty much impossible. It might make more sense to architect for ease of change in general rather than ease of change into a specific direction. To do that (aside from the advice in the article), I like to imagine a scale where static/hardcoded/build-time architecture is on the left end, and dynamic runtime-manageable architecture on the right. To avoid over-engineering, the trick is to always lean as much as possible towards the left side of the scale. Only introduce runtime complexity when absolutely needed.

comment 5y ago · link · parent

Very relatable. Within the context of a single startup this definitely applies. However, in the span of your career, I like to ask — do you want to get fast at writing good code or writing bad code? You won't get perfect code of course, but at the very least you can learn to churn out code that's easy to change. It's not the same thing as expressive code, but it does the job at a startup. (I wrote another article[1] on the topic of writing code that's easy to change a disappointing number of years ago.)

[1]: https://max.engineer/cms-trap

comment 5y ago · link · parent

One codebase that I liked in terms of these qualities (albeit I'm sure it's not 100% perfect) is Redis[1]. There are YouTube videos[2] of antirez walking through it. Would love to find more examples too.

[1]: https://github.com/redis/redis

[2]: https://www.youtube.com/user/antirez/videos

comment 5y ago · link · parent

Author here. Looks like we both have a similar length of experience. I wouldn't give up this battle yet, because

> Firstly you cannot please everyone

> And secondly, programs are not structured for pedagogy

My theory is that you only need to please a couple of maintainers that work with you, not everyone. That's why I proposed a test with 2 colleagues at the end. It could potentially be spiced up with 2 colleagues of different levels. I believe this can act as one of those 20% effort to get 80% there, but definitely don't claim to have proof of this.

480.

Writing maintainable code is a communication skill(max.engineer ↗)

297 points · by hakunin · 5y ago · 93 comments

1
1516171819