by clemens (03.04.2023)

Using a text input with a list of predefined options

tl;dr

So today I learned that you can use a <input list="option-list"> in combination with a <datalist id="option-list"><option value="a"/></datalist> for the often required use case of a text input with a list of available options and you no longer need to implement that manually all the time.

by clemens (24.03.2023)

How to use the users preferred color scheme on your website

tl;dr

In css, you can use the users color scheme by simply setting the color-scheme on the :root element:

:root {
  color-scheme: light dark;
}
by clemens (24.02.2023)

Postcss requires semicolons after import statement or it will only perform the import for the first line

tl;dr

When merging css files using postcss-import don’t forget to add semicolons after each import statement, or else postcss will only import the first file and for some reason add a @media directive in front of the next import and stop processing of further imports.

by clemens (19.01.2023)

Connecting to node with mix remote when using custom RELEASE_NODE name

tl;dr

If you’ve set the RELEASE_NODE in when starting your server with mix start and then want to connect to it using mix remote, you must first export the same value in RELEASE_NODE in your current shell as well.

by kiru (21.10.2022)

Phoenix Does Not Serve Webmanifest

tl;dr

My site.manifest were not loaded with Elixir Phoenix 1.6. It turned out I have to add the file to the whitelist.

by clemens (05.10.2022)

Printing full error message from :error_logger warning

tl;dr

I’ve got a problem where Phoenix.Channel.Server receives an unexpected message to be pushed to my client via a channel. However that message is very long, and some of the important information is only printed at the very bottom of the log message that has been truncated.

by clemens (29.09.2022)

Hugo .Date.Format strings have more meaning than I thought

tl;dr

On this blog the dates were formatted incorrectly, i.e. 2022-08-30 would be printed as 30-88-022. The solution was that the format strings look like they are just some random date, i.e. .Date.Format "Monday, 01.11.2006", but actually the values for date, month and year are hardcoded like dd.mm.yyyy in nearly every other language. Correct would be .Date.Format "Monday, 02.01.2006".

by clemens (30.08.2022)

Phoenix now requires explicit start of server in prod

tl;dr

In Phoenix 1.6.x you now need to start the server explicitly by setting the PHX_SERVER=true environment variable.

by clemens (02.02.2022)

Atoms are not automatically converted to strings in heex templates

tl;dr

If you’ve got a heex template where you want to insert some data attribute like true, make sure that you convert it to a string first. Otherwise a blank string "" is inserted.

by kiru (04.01.2022)

Elixir Optional Parentheses

tl;dr

Just discovered that you parentheses in Elixsir are optional.

Saw this example on the ecto documentation page:

case MyRepo.insert %Post{title: "Ecto is great"} do
  {:ok, struct}       -> # Inserted with success
  {:error, changeset} -> # Something went wrong
end
by clemens (08.12.2021)

Dependencies in the main mix.exs file in umbrella projects are not included in relases

tl;dr

If you’ve got a dependency that one of your apps in your umbrella project depends on, do not put it in the main mix.exs file at the base of the umbrella project. It will not be included in relases in that case.

by clemens (22.11.2021)

Using avif images with Apache and long cache Times

tl;dr If you want to set long cache times using the headers cache-control and expires for .avif images, you will probably need to add the mime type for avif first like so: <IfModule mod_expires.c> AddType image/avif .avif ExpiresActive On ExpiresDefault "access plus 1 seconds" ... ExpiresByType image/avif A31536000 </IfModule>
by clemens (19.11.2021)

Using <Source> and 'srcset' to force browser to choose correct image on mobile

tl;dr

When using responsive images using <picture> and the sizes attribute is not enough to force the browser to use a small image on mobile. Instead you need to provide multiple <source> tags with the media="(max-width: 200px)" attribute set.

by kiru (11.11.2021)

Ecto 3 breaks assoc loaded

tl;dr

After migrating to Ecto 3, the following code did not work:

Ecto.assoc_loaded?(“e9d7edb4-3aef-45d6-851c-e77a464ef352”)

The Ecto.assoc_loaded?() does not accept any objects, check manually before you call assoc_loaded?()

by clemens (27.10.2021)

Do not log all queries as debug in Ecto

tl;dr

Ecto by default logs all queries as debug to the console when developing. To disable simply add log: false to your ecto config.

by kiru (23.10.2021)

Create Empty File to Deal with Full Disk

tl;dr

Nice trick to deal with disk full issues on a server:

After setting up the server, create an empty 8GB file in /spacer.img.

Why? In case the server goes out of space, simpley delete the file.

That gives you more to fix the actual issue.

by clemens (21.10.2021)

Running Erlang and Elixir as Apps on Android or iOS

tl;dr

The guys at diode.io have build a wrapper around the BEAM so that you can run it as a native app on Android and iOS, using LiveView locally on the device.

by clemens (07.10.2021)

Cleaning Up Digest Files in Phoenix

tl;dr

Digested files in priv/static can be cleaned up using mix phx.digest.clean --all.

by clemens (06.10.2021)

Beware of Zombie Watchers in Elixir

tl;dr

Running custom background watchers with e.g. watchexec will lead to zombie processes if not wrapped in custom shell script that kills the process once elixir quits.

by clemens (06.10.2021)

Use the unary plus operator in JS to parse numbers

tl;dr

Of the dozens of variants to parse a number in JS, the unary plus operator is the preferred method.

by clemens (04.10.2021)

Nesting Anchors not Working in Firefox

tl;dr

Do not try to nest <a> tags in Firefox, that will cause Firefox to mangle up the layout.

by clemens (04.10.2021)

Find all Elements at Mouse Position in Javascript

tl;dr

Get an array of all elements at the specified coordinates, relative to the viewport, using Document.elementsFromPoint().

by clemens (29.09.2021)

Explizite Ansprache in Stellenanzeige ist Besser als Binnen-I

tl;dr

Eine Studie hat gezeigt, dass eine Stellenanzeige mit der Formulierung “Geschäftsführerin oder Geschäftsführer (m/w/d)” mehr Bewerbungen von Frauen und insgesamt mehr Bewerbungen bringt als die Formulierung “Geschäftsführer (m/w/d)”.

by clemens (29.09.2021)

Copy Android App Data Using Backup

tl;dr

When migrating to a new phone, you can copy most app data using the apt backup and restore function.

by clemens (27.09.2021)

For With Reduce in Elixir

tl;dr

You can perform a reduce using for by using the reduce: [] opt.

by clemens (23.09.2021)

beforeunload Deactivated on iOS

tl;dr

On Safari in iOS the event beforeunload does not exist, but it does on Safari for MacOS. Add a global event listener on all clicks on anchor tags as a workaround.

by clemens (23.09.2021)

Using Different Erts Version With Mix Release

tl;dr

If you are using mix release with a different erts version, the path must point to the erts-x.x.x directory inside the erlang installation.

by clemens (23.09.2021)

You Can Simulate iOS Devices on Macos

tl;dr

Use simulator.app from XCode to test your websites on iOS devices.

by clemens (23.09.2021)

Migrations Are Silently Skipped if They Do Not Have an Exs Extension

tl;dr

If you’ve got a migration that has ex as its extension instead of exs its silently skipped.