hjertnes.blog

#

23.04.2018 02:00

The Field Notes pencil is actually good.

Project configuration.

23.04.2018 02:00

If you are working on a software project that have a backend or server component, it probably have some kind of configuration. Like database servers, maybe some API keys to upload to S3 etc. To get configurations right, the first time is always a pain in the ass. Because some of it is about configuring exciting tools and libraries to work with your setup, and other times it is about configuring your stuff depending on where you want to run it.

There are a few different ways you typically would deal with this. And there are a few ways I would encourage you to not do.

The biggest don’t is to not put it in a database, because you might want to take data from production and use it during development to make sure that what you make scales well. Make sure that you don’t keep settings that only works in production in the database. Because it will make stuff like testing production data much harder than it has to. And don’t just hard code settings.

The day I usually do it, is to hardcode the development settings in my projects. And then I re-configure them to run in production. Why? The less time I have to configure the machines of the people I work with, the better it is. When it comes down to the actual configuration I think there are two good ways to do it in 2018. Either with a configuration file or with environment variables. There are places where using a configuration file makes sense, and there are places where using environment variables are better. A configuration file is awesome for all kinds of settings that applies to your software project, as long as they always are the same. The moment where it might change is when you run into trouble. Because it is a pain in the ass to keep multiple almost identical files up to date. A typical software project runs in three different environment: development, staging and production. Development is a developers personal machine, staging is where you test stuff to make sure everything works in a production like environment and production is where your users or customers will use it. The way I do it these days is that everything that is not the same all places are controlled with a environment variable. Usually through a docker-compose configuration file.

What are a environment variable? Well, they are like a variable in your programming language, except that they belong to the environment the program runs in. This means that if you have two programs on written in Java and one in Python that uses the same database, they can read the same connection string.

Let’s say you have a project with two variables that change depending on where you run it: URL and DATABASE_CONNECTION_STRING. The URL is used to display the full URL to a resource for when you need it(for example when sending an e-mail) and the DATABASE_CONNECTION_STRING is used to connect to your database. I use environment variables for this because I can just change them in the script or server configuration. Instead of having to keep multiple copies of large config files on the project side of it. That someone (me) have to keep in sync. On a UNIX/Linux system you could just do something like URL=”https://yourdomain.ltd“ DATABASE_CONNECTION_STRING=“‘postgres://pompeii:pompeii@db:5432/pompeii” command-to-start-your-server to override them.

If you for some reason need to implement some project configuration on your own. Use JSON or YAML. Most if not all developers know the formats, and you’ll find parsers for all languages under the sun. And some in the shadows as well.

#

21.04.2018 02:00

It’s cool that SmugMug have bought Flickr. Flicker was awesome, but I stopped using it because the Yahoo authentication crap drove me nuts. Let’s hope they don’t fuck it up.

ES6 Proxies

20.04.2018 02:00

ES6 Proxies are awesome. I have not used them much “in the wild” yet. But I think they add some very interesting concepts to JavaScript. You are kind of familiar with them if you have worked with Properties in C#, Java, Swift or Objective-C. The short version is that you define a method that is called when you try to retrieve a value or setting a value. But instead of calling .methodToGetMyValue is it called when you try to access some value.

The biggest difference between the JavaScript Proxies and setter / getters is that you define them for a “variable”(in lack of a better word for it). That means that you could define it for an entire list or object or just a value.

#

19.04.2018 02:00

Portacle. Pretty cool, but it’s just Emacs with some fancy wrapping.

#

19.04.2018 02:00

Are there any good, fast, native OS X Slack clients with support for multiple teams?

How I use my Fujifilm x100.

19.04.2018 02:00

I got my X100T when I was a Canon shooter. And then a year later it died, and I replaced it with a X-Pro 2. The result was that I did not use the X100 that much. Mainly because I prefer the X-Pro in more or less every way.

Then I started to use the X100 again. I just leave it in the office, with batteries and a 16GB card. To take snapshots. For, you know all the times you want to take a picture, but the big camera is somewhere else.

#

18.04.2018 02:00

Look here if you have problems with Org Journal not opening the current day when you use M-x: org-journal-new-entry

My GitHub effort.

18.04.2018 02:00

I have a shit load of code on my computer. Most of it is either in use or used to be in use; and was made to solve some kind of problem I wanted to solve.

I have made an effort over the last year or so to make sure that as much of possible of the code I have laying around on my system is on GitHub in a form where it is useable to other people.

Why? I don’t know. Most of it was because I wanted to have more stuff there, I guess. And because it might be usable for someone.

It is also a good exercise to get into writing code that don’t need to be rewritten to be used by other people

Meditation

17.04.2018 02:00

I have been trying to get into meditation for years. Reading countless books and blogposts about it. But it wasn’t before I started to use the Headspace app this year that I got into it. The guided content they have are really awesome. No focus on all the weird stuff like sitting is not a part of it.

One of the things that always was hard to understand from my previous attempt was what was optional and what was the meditation. Like all the weird sitting stuff.