hjertnes.blog

Awesome Babel Plugin

01.02.2018 01:00

I have been doing a lot of major re-structuring of my day job front end code this month, and I guess I’ll continue doing that at least until the end of next month. And I was looking for a better way to dealing with import paths.

As you structure grows you’ll probably have more and more of some import statements like this “import foo from ‘../../../../../bar’”. And I was thinking: there got to be a better way. And after googling for a while I found this. It is a babel plugin that let’s you use tilde to reference the root (where you webpack config lives).

If you want to import the file in the root called “bar.js” or “bar.jsx” you only have to do “import foo from ‘~/bar’” instead of having to figure out how many levels under it you are coming from.

I have used it for a few weeks now and love it. It makes it far less likely that you need to do a lot of code changes when you only are moving stuff around.

SQLite.swift + App Groups

01.02.2018 01:00

I had a hard time to get Sqlite.swift to work nice with a App Group container. Look in the gist for details on how to get it work.

#

31.01.2018 01:00

A great episode of The Omni Show.

#

31.01.2018 01:00

#

31.01.2018 01:00

Xcode X at WWDC? 🤔

#

30.01.2018 01:00

I guess this will be a week with a lot of podcast skipping, because I don’t give a shit about the HomePod

#

30.01.2018 01:00

[@jack]1 I fixed the mb.el issue you added.

#

30.01.2018 01:00

Hello World?

Exception handling.

30.01.2018 01:00

Handling exceptions is a pain in the ass no matter what language you use. I hate it in JavaScript, I hate it in C# and I hate it in Python. Exceptions are in many ways the least horrible way to deal with errors, at least that I know about.

Most languages that have try / catch or try / expect(python) syntax let you specify a exception or not. This means that you add multiple blocks of code to deal with different scenarios.

For example:

  • Try to read a file

  • Do this if the file doesn’t exist

  • Do this if we don’t have the permissions

  • Do this if the file is empty

  • Do this if we receive some other error.

This is not possible with the current catch(error){} syntax in JavaScript. But there are some ways to simulate it.

It’s not perfect, but it is a start.

#

29.01.2018 01:00

Micro Monday. This week I recommend everyone to follow the awesome [@belle]1 she is one half of the startup Hello Code. They make one of my favorite apps Exist and the Hello Code podcast is awesome.