1,525 karma · joined Nov 19, 2015 (11y ago) · 387 submissions
comment 2w ago · link · parent
Using Gleam in an Elixir project did/does rely on mix_gleam. I've used it some years ago and it worked then, but I haven't had recent experiences. There is a pull request[0] to Elixir to add built-in support for Gleam and as I understand it the Gleam team have made several changes to Gleam tooling to facilitate it, but it's unmerged as of now.
Using Elixir in a Gleam project is just an external function away, just like using Erlang or JavaScript (when using the JS target). E.g.
@external(erlang, "Elixir.Some.Module", "my_fun")
fn my_fun(some_arg: Wibble) -> Wobble
You can also write .ex files in your codebase and use functions from them as externals and they'll be compiled by Gleam.The two main issues on that side are macros and structs. Since Gleam doesn't know about Elixir source or Elixir macros, you can't use them directly. But you can have an .ex file that uses macros and then you can call functions from that file. Structs are trickier, because they're just dynamic maps with a special key-value pair, and maps in Gleam (called Dict) have fixed types for the keys and values. That means you can't model a struct as a Dict. Gleam uses records for its own custom types, so what you can do is either use records on the Elixir side (with the Record module or by hand), or map the Elixir side data structures to be more palatable for Gleam (and vice versa) in your external functions --- which is what you generally do with externals anyway. Of course, if you only intend to pass the Elixir structs around and then back to Elixir, you can model them as external types that are then opaque to Gleam.
comment 1mo ago · link · parent
Edit: One source in English but even this is a while ago: https://www.bbc.com/news/articles/cvj6jkx6g1r0o
comment 1mo ago · link · parent
Now, I'm not a fan of Google and I'd much prefer this whole project was scrapped, which is why I'm interested if there are sources that provide something that I've missed from the Finnish media.
[0] https://suomenluonto.fi/uutiset/luonnon-monimuotoisuudelle-t...
comment 1mo ago · link · parent
> More than 75% of Finland’s land area is covered with forest. [...] About 3 million hectares of Finnish forests are protected or under restricted use, which represents 13% of the total surface area of forests (forest land and low-productive forests). The area of protected forests fully excluded from fellings is 2.5 million hectares, which represents 10.8% of the total surface area of forest and low-productive forest land.
comment 1mo ago · link · parent
There was one UX papercut that ended up messing some data on tracks that I had to correct later: fields with multiple values, like "Artists", show the multiple values like "Beats and Styles; Toni W.". But the field in the UI is also editable as a text field, and if you manually write that with the semicolon, it stores one artist with the semicolon included! It took me a while to realise that I can right click to open an editor where multiple values can be entered and edited separately.
comment 2mo ago · link · parent
As kids we didn't know why this would happen, we just knew that it did and used it every game.
comment 4mo ago · link · parent
I have it guarded by a simple cookie check now, which seems to work well enough. Only a small subset of bots pass it. It likely kills search engine discoverability, but that's the tradeoff I have to make.
comment 5mo ago · link · parent
Technically you might argue that I should show 1 AM if the user did run at 2 AM in summer time, but everyone I personally know keeps their schedule over DST transitions. That is, if they did something at X o'clock before the transition, they'll keep doing it at X o'clock after it (sleep be damned). So generally showing 2 AM would be the most correct solution.
You cannot get that information from just UTC if you don't know where the user was when they made those historical events. Thus you either have to keep a history of their location (complicated) or just store the local timestamps (or at least the offsets) at the time of event. Always being able to convert from UTC with no extra data assumes that the user will never move, which might be fine if your application is limited to users in a single country.
comment 5mo ago · link · parent
The naming of "timestamp with time zone" is one of my favorite pet peeves. It's one of those things that you can say "well technically it's true" about.
The article suggests that for past events, UTC and this timestamptz would be acceptable as a general rule, but even there it depends on what you will be doing with the data. If you intend to interpret it as a series of local occurrences and try to visualize/summarize that data later, you may be in for a surprise as your user has moved to another timezone and now all the past events are translated to the wrong local hours [1]. For example, your system might end up showing that the user's best time for jogging based on historical data is at 2 in the night.
comment 5mo ago · link · parent
The article suggests that for past events, UTC and this timestamptz would be acceptable as a general rule, but even there it depends on what you will be doing with the data. If you intend to interpret it as a series of local occurrences and try to visualize/summarize that data later, you may be in for a surprise as your user has moved to another timezone and now all the past events are translated to the wrong local hours [0]. For example, your system might end up showing that the user's best time for jogging based on historical data is at 2 in the night.
comment 6mo ago · link · parent
But I also just followed it for the first time from beginning to end, not doing anything. Because I assumed someone had already done the math.
comment 9mo ago · link · parent
19.
Facebook's Fascination with My Robots.txt(blog.nytsoi.net ↗)
91 points · by Ndymium · 9mo ago · 53 comments
comment 9mo ago · link · parent
> Then drop any elements and attributes that are not allowed by the sanitizer configuration, and any that are considered XSS-unsafe (even if allowed by the configuration)
The XSS-unsafe functions are all named "unsafe". Although considering web programmers, maybe they should have been named "UnsafeDoNotUseOrYouWillBeFired".
[0] https://developer.mozilla.org/en-US/docs/Web/API/HTML_Saniti...
comment 10mo ago · link · parent
If you compile it to JS, then the guarantees change to JS's guarantees.
Personally I've felt that the JS target is a big plus and hasn't detracted from Gleam. Writing a full stack app with both sides being in Gleam and sharing common code is something I've enjoyed a lot. The most visible impact is that there's no target specific functions in the stdlib or the language itself, so Erlang related things are in gleam_erlang and gleam_otp, and e.g. filesystem access is a package instead of being in the stdlib. If you're just into Erlang, you don't need to interact with the JS target at all.
comment 11mo ago · link · parent
LiveView does provide the tools to simulate latency and move some interactions to be purely client side, but it's the developers' responsibility to take advantage of those and we know how that usually goes...
comment 12mo ago · link · parent
1800 kWh is very little. We use around 12000 kWh and our neighbours' new house uses around 8000 kWh annually and most of that is heating. I'm not sure how many houses can hit 1800.
comment 1y ago · link · parent
Last I heard there was a feature branch for testing a software implementation of floating point that would fix these issues, but naturally it would be a lot slower. I haven't tried it myself.
comment 1y ago · link · parent
comment 1y ago · link · parent
Turns out you can play it with an angry face.