• 3 Posts
  • 87 Comments
Joined 1 year ago
cake
Cake day: June 30th, 2023

help-circle



  • Recently I had to do an update to the underlying environment a codebase ran on. This was a somewhat involved upgrade and took a longer period of time than most of our work usually does. I did it in a separate worktree, so I didn’t have to constantly rejuggle the installed dependencies in the project, and could work on two features relatively concurrently

    It also provides some utility for comparing the two versions. Nothing you couldn’t do other ways, but still useful









  • Paradox@lemdro.idOPtoProgramming@beehaw.orgCSS is fun again
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    They can both model any color equally well, it’s just oklch works even closer to how we perceive colors changing. LAB and all derivatives are in Cartesian space, with luminance, a, and b being the defining axises. Luminance is self explanatory, but a and b are just axises of how much red/green and blue/yellow there is. It can be difficult to think of a color in how much blue it is, for example, when the color is something like nearly pure red. They both affect the hue output, so varying one can create strange, unintuitive colors

    LCH works in polar space, like a color wheel. L is still luminance, c is the “colorfulness” and h is the hue. H and C let you set the same values a and b would, but in a more human way. We’re used to thinking about colors changing independent of how much of a color there is, and that’s what LCH does. Vary only the h and you get very different colors. Vary only the c and you get the same color but in different amounts of saturation, from full color to no color




  • Data comes out as a map or keyword list, which is then turned into the repository struct in question. If you want raw db data you can get that too. And you can have multiple structs that are backed by the same persistent dataset. It’s quite elegant.

    Queries themselves are constructed using a language that is near SQL, but far more composable:

    Repo.one(from p in Post, join: c in assoc(p, :comments), where: p.id == ^post_id)
    

    Queries themselves are composable

    query = from u in User, where: u.age > 18
    
    query = from u in query, select: u.name
    

    And can be written in a keyword style, like the above examples, or a functional style, like the rest of elixir:

    User
    |> where([u], u.age > 18)
    |> select([u], u.name)
    

    None of these “queries” will execute until you tell the Repo to do something. For that, you have commands like Repo.all and Repo.one, the latter of which sticks a limit: 1 on the end of the provided query


  • I much prefer the repository pattern, as used by sequel and Ecto

    Your models are essentially just enhanced structs. They hold information about the shape of data. Generally don’t hold any validations or logic related to storing the data. You perform changes on the data using changesets, which handle validation and generating the transaction to persist the data

    It works extremely well, and I’ve yet to encounter the funky problems ActiveRecord could give you






  • An ad hoc sorting system for a grid of tiles on an enterprise app

    Instead of sorting across row wise, it sorted columnar. So it was

    A E I M
    B F J N
    C G K O
    D H L P
    

    Instead of

    A B C D
    E F G H
    I J K L
    M N O P
    

    This was a requirement from the CEO. Since we used this project (dogfooding) we stuck a secret search box/command palette in, which you could hit . and then type the name of the thing you wanted and click it