hjertnes.blog

The Power of Environment Variables

08.10.2017 02:00

```text What is an Environment Variable? It is more or less the same as every other kind of variable, it contains some data. The difference is that an environment variable lives outside of your program and in the “environment” it is being executed. Like for example the command line prompt shell you run your program. This is for example how the path in your zsh or fish shell is stored, so that it knows to look for the program “vim” in /bin, /usr/bin and /usr/local/bin”. ```

```text They are a very powerful tool to have in your belt when you have slightly different configurations for your stuff in various environment. I use them all the time when I run stuff in docker. ```

```text What you can do is to tell your javascript build system or your backend to look for some piece of data in the environment instead of a configuration file. For a backend this might be the database connection settings. Or the URL of your site in the javascript build system. ```

```text Why would you do this instead of a configuration file? Because it Is much easier. And support for it comes out of the box in most programming languages, plus both docker-compose and webpack makes it very easy to integrate with it. ```

```text And you don’t need to maintain multiple configuration files for production, staging, development etc. You just add it to scripts or docker-compose files. ```

```text I used to use it a lot back in the old days. I have started using them all the time again with the growing popularity of docker and docker-compose. And they are in many ways the de facto way to configure docker images at run time. ```

Apple Watch

01.10.2017 02:00

```text So, I’ve had my Apple Watch Series 1 for about a year now. And it is without doubt one of — if not the — most important piece of hardware I have bought. ```

```text The reason? It is the first device I have owned that keep track of how much I move, even when I don’t remember to start tracking a exercise. ```

```text I use my Apple Watch for three things: ```

```text
  • Health and fitness tracking
  • Notifications
  • Simple data capture
  • ```

    ```text I wear my Apple Watch more or less 24/7; and I charge it when I get home from work, between dinner and when I walk my dogs, and when I shower after that walk. This is usually enough to get me through until the next day. ```

    ```text It tracks my hearth rate, and it tracks how much I move and my sleep. And that is more or less it. From a health perspective. Then I use it to monitor important notifications. And I ignore the rest. ```

    ```text And the last thing I use it for is very simple data capture, like adding to Water minder as I drink water. ```

    ```text The thing I think is the real value of a Apple Watch is to not “use” it and let it do its thing, and then use it as a tool to first survey how much you move per week, and then use it as a tool to move more and experiment until you find the spot where it requires work but not too much work to reach your goals. ```

    ```text I’m in much better shape now, than I was a year ago. And I have a much better idea of how I’m going to work against improving it even more. ```

    ```text I have the Series 1, and I probably won’t upgrade this year, unless I break mine. But I will probably upgrade next year. ```

    ```text The band I have used the most is my Product Red sports band. These rubbery plastic bands are much better than the ones you might have used on your cheap Casio watch from when you were growing up. And I think they are the best option for most people most of the time. But you might consider something nicer to do when dressing up; but I never do. ```

    ```text I have one complaint about it: it is sometimes a little bit hard to get the end into the hole. It isn’t a problem most of the time, but sometimes I unbuckle it in my sleep. ```

    How do they hold up?

    01.10.2017 02:00

    ```text In this post I’m going to take a look how various notebooks I have used hold up in use. How does they look when they are new versus after I’m done with them. ```

    ```text Field Notes ```

    ```text I think Field Notes are the gold standard for notebooks that look fantastic both new and even better when they show some wear and tear. While I think their design new look good, they are in no way my favourite. ```

    ```text As said, they look fantastic after being used. The only problem with them is that it isn’t that they don’t hold up that well if you have them in your pack pocket for months, instead of weeks. ```

    ```text Leuchtturm1917 (hardcover, A5) ```

    ```text This notebook looks okay or fine but not fantastic when you start using it. It isn’t ugly or anything, but it is just “utilitarian” and does the job. I don’t think anyone buys a Leuchtturm1917 for its aesthetics, but rather their fantastic paper and features. ```

    ```text The notebook does not look good after a few months of wear and tear, but I have never experienced that any of them are falling apart, even after carrying them in by bag for months. ```

    ```text Nock.co Pocket sized notebook. ```

    ```text This is based on the Blue limited edition one, but I expect it is similar on previous limited editions and their regular black one. ```

    ```text It looks amazing out of the pack. I greatly prefer it to Field Notes. And I think it has a Field Notes thing going for it where it looks cool as the colour are worn off after being in my back pocket for a few weeks. ```

    ```text I’m not 100% sure, but it seems like the material the cover is made of holds up better than Field Notes when it comes down to not falling apart. ```

    ```text Rhoda Webnotebook ```

    ```text Not unlinke the Leuchtturm1917, the orange Rhodia Webnotebook doesn’t look that great after using it for a while. It looks a little bit "dirty" and some posts of ink etc. The black one might not show it as well as the orange one. ```

    ```text Conclusion ```

    ```text If I would pick one of each category, one A5 and one pocket sized notebook based on how they look after being used for a while, I think Field Notes and Leuchtturm1917 is the obvious picks. Field Notes looks the best when they are worn down. And Leuchtturm1917 takes it a little bit better than the Webbie. It doesn’t look good on either; but it is much more visible on the webbie; and neither is made in a way where it looks good. ```

    ```text But this is of course not the way I pick notebooks. My prefence at the moment is Nock.co notebooks for my pocket sized needs, and Leuchtturm1917 for everything else. ```

    Node, Express and Passport

    01.10.2017 02:00

    ```text It took me a while to get it working the first time, and I have seen a lot of interns and student interns struggeling with getting it working with one of our traning assignments at my day job (WA.works). So, I have decided to take the passport section of something I’ve already open sourced, that use Passport and highlight how it works. ```

    ```text Check out the GitHub repo ```

    ```text This is the short version of what you need to get Passport to work: ```

    ```text
  • Set up Express to accept body data, cookie data and to use sessions
  • Enable Passport and sessions
  • Write a local strategy that validates against a local data source
  • Write a serializer
  • Write a deserializer (takes the id from the serializer and fethces the data from the data source)
  • Add code to register, log in and log out; and check if the user is logged in on protected resources.
  • ```

    Review

    24.09.2017 02:00

    ```text Paw is more or less the same as Postman. It is an app you can use to configure more or less any type of HTTP request. It manages sessions, cookies and so on. And I think it is one of the most useful tools available when you do web development. ```

    ```text The reason it is so useful is that you make some kind of API that communicate over HTTP; usually a RESTful one; even though there still are some weirdos using SOAP, probably only of legacy reasons. This is the API your web front end or your native apps are going to talk to. But it is invaluable to make sure that they work as you expect them to before hooking them up to the front end. Because then you know where to start debugging if something isn’t working. It is much easier to do it if you know for certain that it has to be in the client side code. ```

    ```text You can probably do more or less the same with Postman as you can with Paw, I just prefer Paw because it looks much better and is a native Mac app. ```

    ```text What I love about it is that it supports multiple documents, so I can have one document per project I sometimes work on, containing all the requests I have used on that project. It gives me some kind of organisation, and I don’t have to re-create all of the requests between each time I use Paw. ```

    ```text An awesome app that everyone that do any kind of development that involve backends should have in their tool belt. ```

    Tomoe River Paper

    24.09.2017 02:00

    ```text This is probably the most impressive kind of paper on the planet. It is super thin, or can take more or less any ink you throw at it; I think I was pouring ink at it at some point. It is the paper used in the Hobonichi Planner. But the
    other side of the impressive capacity to deal with ink without bleeding through or feathering is that the dry time is very long. ```

    ```text I get why some people love it, and it is the kind of paper everyone should try. But I consider it completely unusable for regular use, because it takes too long for the ink to dry. ```

    ```text Fantastic paper, but not for me, my kind of pens and inks I use. ```

    Some thoughts on cleaning fountain pens.

    18.09.2017 02:00

    ```text How much and how often you clean your pens are up to you, but I think it is a good idea to do it now and then. ```

    ```text I try to do it myself not every time I refill my pens but every other to every third time. And I only do a full “flush water in and out until its 100% clean” when I change inks. I just flush clean water through the pen a few times before I refill it. Takes less than a minute per pen. ```

    ```text If you are using a cartridge converter type pen, then there is no damage to cleaning it every time you have the opportunity. But the more often you clean a piston filler, the shorter time it is between each time you have to grease the piston. ```

    ```text Like with everything else, there is something that is too much and something that is too little; the trick is to find a place in the middle. ```

    ```text You probably know why, but I am going to explain it anyways. The reason you want to flush water through your fountain pen from time to time is to make sure nothing dries up in the feed of your pen; and that is bad because it blocks the ink from flowing through your pen and onto the page. ```

    ```text If you use a piston or a converter, just suck water in and out a few times, and use a bulb syringe if you use cartridges. ```

    ```text But the most important thing is to do a thorough cleaning when you are switching inks. The first reason should be obvious to everyone, but it is to make sure that you see the proper colour of your new ink and not some weird mix between the old and new. But even more important is to make sure that your pen are completely clean when you start using your new ink, because some inks don’t mix that well. Everything from combinations that actually can damage your pen to combinations that clog up your feed. ```

    Review

    17.09.2017 02:00

    ```text I think I first started using Moom when I discovered when the OS X App Store launched.. And I have had it running on all of my Macs since then. ```

    ```text Moom is the only window manager for OS X that have made much sense to me. It combines the simple, with the powerful. ```

    ```text When you install Moom, you get a hover menu when you place your mouse over the green window control button on any given window. You know the button that puts an app in full screen. It will let you resize that window to fill the whole screen, or resize and move it to fill half the screen in four different combos (left half, right half, top half, button half). This is very easy to do, and very power ful and it would require a lot of messing around to do it manually, many times. ```

    ```text You can also create your own, and attach them to that menu or assign keyboard shortcuts. Or even create a snapshot of a specific layout. ```

    ```text The way I use it the most, is when I connect my 27” 4K monitor at work. Because then I want to have four apps on each virtual desktop. One in each corner. ```

    ```text The way I do it is that I laugh four apps; Visual Studio Code, iTerm, Google Chrome and Tweetbot. For the first one. Option Control Space to trigger the Moom shortcut and then 1 to move an app to the top left corner, 2 to move an app to top right, 3 top bottom left and 4 to bottom right. ```

    ```text It usually takes me five minutes to launch and move stuff around to be ready to start working. And that includes the time the various apps need to launch. I don’t even want to thin about how much it would take me manually. ```

    Setting up a backend with Docker, Postgres, Express.

    11.09.2017 02:00

    ```text I often find myself wanting to set up something simple to solve a very specific problem, but in the past I have often just implemented it as a part of the larger monolithic backend for what ever project it is, because the hassle of setting up a new server and configuring a framework etc would be too much for that simple thing. ```

    ```text But with Docker and Docker Compose I no longer think it is much of a hassle to write what should be a separate service as one. The reason is that you just instal what ever Linux distro you prefer, and run docker-compose up -d and you’re set (if the compose file you used works). ```

    ```text It is also very easy to set up a Express.js project, with CORS, PostgreSQL and Basic Auth. And I also think that it is one of the library / language combos that I have used that is the fastest to develop in. ```

    ```text I have finally gotten around to making my boilerplate sample project available on GitHub) It is the same thing I based Pompeii, tracker, active users and many other projects (that aren’t open) on. ```

    ```text The time it takes me from going from idea to working is limited to the time you need to get the code working and a machine running docker compose in the cloud; no fiddling around with configuration or complicated frameworks. ```

    ```text To get something up and running both local and on the server with something like Django or .NET Core would probably take ten times as long. ```

    When is bad paper a good idea?

    11.09.2017 02:00

    ```text Just a short one on bad paper. ```

    ```text They come in two forms, both of them bleed like crazy. That’s what make them bad. But they come in many different thicknesses. Bad thin paper is just horrible; think Moleskine; because you get bleed through on multiple pages at a time. ```

    ```text But. Bad think paper isn’t the worst thing in the world in some ways. Because bad thick paper have the shortest dry time possible. This is because instead of letting the ink dry on top of the paper like you see in the most extreme with Tomoe River, and in lesser degrees on Rhodia and Leuchtturm1917, the ink are just absorbed by the page. ```

    ```text I think it is a good idea when you are learning how to write with a fountain pen; especially if you are a lefty. And if you are in a meeting where you don’t want to stand out as the weirdo with arcane writing instruments and ink all over his fingers. ```