Understanding Reduce

16.10.2017 02:00

```text Reduce is a in the Array.prototype; which means you can run it on any array or list. It is a method that lets you reduce a list or collection down to a value. ```

```text You have probably written something like this more times than you care to ```

```text The next time you’re about to do that, is the perfect time to figure out how reducers work. Because those four lines can be replaced by a single line using a reducer. ```

```text This is how it works. Reduce takes a function as its argument, and you can also provide an optional default value. I almost always do that. The function takes two arguments one accumulator and the currentValue. The accumulator is the result of what the reducer have done up to this point, and the currentValue is the value of the item in the array. ```

```text For example, the first time it is called in our simple example above the parameters will be (0, 1) and then it will be (1, 2) and so on. ```

```text I personally think that reducers is a great way to turn a array of values or objects into a single value. They produce less code than looping over them. And as a bonus: they have far fewer side affects. ```


15.10.2017 02:00

```text There are a few tasks I have to break down into small chunks. One of them are maintaining the “Audit” section of 1Password, another one is to manage Notifications on OS X. ```

```text The short version is: I don’t want any. ```

```text So. The way you disable notifications on OS X, is more or less the same as iOS. You have to you through every singe app and disable everything. And it is a major pain in the ass. ```

```text My problem with it is two fold. First of all, why not let me mark all of them and do what ever I want to do with either all or any selection of apps. Second, why do I have to click a million different things to just disable notifications? ```

```text This is one of the areas where the iOS influence on OS X was wrong. Not the inclusion of it, but rather that the interface are lacking every ability to work efficient. ```

Something between the sample and a bottle.

15.10.2017 02:00

```text When I want to test an ink, I have two options either I buy or trade a sample or I buy a full bottle. I would probably just get the bottle because it is not THAT expensive. ```

```text What I want is something bigger than a sample, but smaller than a 50ml bottle. 10 or 15 ml would be perfect. Because a small sample is never enough for me to do a proper test. I like to test it in many different pens in order to get the full picture of how a ink behaves. But the problem with the full bottle, is of course to get rid of it, if you don’t like it or don’t see yourself using it all. ```

```text The reason I try to always test a ink with as many pens as possible is because to use a ink with a finer nib versus a broader one or a dry pen vs wet pen is very different. The colours are different. And the dry time is different. ```

```text Some inks look better with a fine line, while others look much better with a big wet one. And some inks are just unusable with a wet nib because you have to take a nap while you wait for a page to dry ```


11.10.2017 02:00

Too many Javascript blogs isn’t possible, right?

```text The pitch for this blog is a collection of short and easy to understand explanation of something related to Javascript. I might sneak in some related topics here and there. But the core focus will be javascript; both as a front end and back end language. ```

```text I’ll publish one post per weekday. ```

```text Enjoy. ```


08.10.2017 02:00

```text I received the [Code & Quill Origin](Code & Quill Origin Grey Dotted + Linjert A5 Hardcover Notatbok – Tudos) free of charge from Tudos for the purpose of reviewing it. ```

```text This is a A5-ish notebook with dot grid on the left side and lined on the right side – what I usually call dual layout. The paper is okay, but it bleeds through a little bit more than I’m used to. It’s not that bad, but a little bit worse than for example Leuchtturm1917. ```

```text The design of this notebook is not ugly, but it isn’t anything I like either. The only way to describe it is how iOS apps used to look before everything went “flat”. There are probably some people that love how it looks. But it isn’t my kind of thing. ```

```text My three big complaints of this notebook is: ```

  • The paper quality makes something to be desired. Close, but no cigar.
  • The lack of felt page markers is really annoying.
  • The format of the book is similar to A5, but a little bit shorter. This drives me nuts. Why wouldn’t you follow an established standard? This is the kind of thing where I mumble “fucking Americans”, we have the metric system and various other systems for a reason.
  • ```

    ```text I have used dual layout notebooks before, mainly the Field Notes special edition from about three years ago, or something. And it never clicked with me. My opinion have been that people should get a Travelers Notebook and fill it with different refills if they just want multiple page layouts in their notebook. ```

    ```text The way I usually use notebooks are either long form writing or writing down lists. And to use a dual layout for something like that is either confusing or plain wasteful. So what I had to do in order to test out this notebook was find something I could use it for where it made sense to have one layout here and another one over there. ```

    ```text I decided to use it for creating “mockups” for app and web development stuff I do at work and for fun. This means I need to carry another notebook, and that was exactly what I needed… ```

    ```text The dual layout is good for some stuff. And my mock up notes are less messy and easier to understand when I use the grid for the mockups (crappy drawings) and the lined part for describing what it is. ```

    ```text Now. I’m not 100% sure if the improvement is big enough for me to justify carrying another notebook. I guess time will show. ```

    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: ```

  • 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: ```

  • 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.
  • ```


    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. ```