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


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

    The art of SQL

    05.09.2017 02:00

    ```text The way we have built applications (I’m using the term applications here for everything from web sites, to backends, apps etc) that had more complex requirements than some file based storage is databases, and most of them used to be based on the simple idea of tables and relations between them. You can look at it as a spreadsheet that can reference between sheets and have strong requirements to what kind of data is allowed, both per row and per table. Most databases use some variant of the SQL language. ```

    ```text Today many use a different data model than SQL databases like for example the document based model of MongoDB. There are many good reasons to go for either. The good thing about something like mongoldb is that you don’t need to think that much about how to design the database to make it scale well enough. And it is much easier to get it to work in a distributed model. ```

    ```text While to good thing about SQL databases is that many of us know them really well. We know how to design them to be fast, flexible and scale really well. Not to mention how to tune the database servers behind them. And we also have really good systems for abstracting away some of the more complex parts of it; like Django’s ORM or .NET’s Entity Framework. ```

    ```text There is an art to designing good databases, that perform well and solve the problems you want to solve. You can ask for just the data you want, and do a lot of the heavy lifting on the database server instead of on your webserver or in your application. By using stored procedures (small programs that live in the database) or using views to simplify complex queries(a view is a way to make a “table” out of a complex query) ```

    ```text I love SQL and have spent a lot of time over the last fifteen years or so to learn it really well. And I don’t think SQL will go anywhere. But using SQL is in many ways a tool where it isn’t any better than the developer behind it is. Kind of like C. It is a absolute nightmare if the developer don’t know what they are doing, and it is amazing if the developer is. ```

    ```text What I hope is that those who don’t care move over to SQL, and those who do take their time and learn how to master this amazing piece of technology. ```

    Cloud backup in 2017

    29.08.2017 02:00

    ```text I’m a little bit more interesting in backup than the average person because I did lose a lot of data, including all the pictures I took before 2006 or something. And I am a strong believer in having a cloud copy of all your important data. It doesn’t have to be a “backup”, but I recommend it, but Dropbox could be good enough for many people. ```

    ```text It was three obvious options when I came up with my previous online backup strategy: ```

    - Use Dropbox if you just want a online copy of your data
    -   Use Backblaze if you want a “set it and forget it” type solution.
    -   Use Crashplan if you have more complicated requirements; like backing up external drives or network storage.

    ```text My storage requirements used to fairly simple, but after close to five years of using a DSLR, my raw files take up far more storage than I want to pay for on a MacBook Pro. ```

    ```text The way I have been doing it up this point is to use Backblaze for everything on my SSD, and upload a copy of “archival stuff” to Dropbox. But I started to investigate other solutions this summer, because it had become way too cumbersome. And I wanted to have a single solution for everything. ```

    ```text Backblaze is a great app, and I think it is the best option for most people. But it is a little bit too hard to make it do exactly what you want, if you are a little bit picky. ```

    ```text So, I decided to look at Mac OS software that backs up to Amazon Glacier. Glacier is either a service or a storage class for S3 (another service) where it is very cheap to upload and store data, but more expensive (and slower) to receive data. In other words, it is cheaper than S3, if you only upload data and don’t access it that often. Which is exactly what I need for a backup solution. ```

    ```text I tired Freeze and then Arq; but ended up sticking with Arq because it was much more mature and rock solid. After using Arq on my MacBook to backup both the internal storage and an external archive drive, I have no big complaints about it. It was all the features you would expect from a premium backup application. But I do miss a pause function that isn’t based on time; some times I just want to pause it until I resume. And the drive scanning is a little bit slow. ```

    Book review

    25.08.2017 02:00

    ```text Jeffery Saddoris of the co-host of the On Taking Pictures podcast, the podcast that inspired me to move from being someone who enjoyed to take snapshots to becoming someone who has photography as a serious hobby, recently self published [Photography by The Letter](Home – Photography by the Letter) the most enjoyable photography book I have ever read. And I have read an embarrassing amount of photography books over the last four and half years. ```

    ```text This is the book I wish was there when I first got my Canon 650D. ```

    ```text It is a beautiful, straight to the point, concise and informative book. ```

    ```text My impression after reading through it during the train ride back home from work yesterday and the rest on my way to work this morning is that this book has everything you need to know until you want to take a deep dive into a certain area. ```

    ```text The problem I have had, and still have to this day with most photography books is that they are written in a overindulgent manner with a serious case of “word diarrhea”. Isn’t more information better? In general yes, but the devil is in the details. You don’t want too much details that can confuse you in a general overview. More details is good when you know the basic, know how to use it, and wish to take a deep dive into to get a deeper understanding. ```

    ```text This is the perfect book to start out with, and I also enjoyed it as a more experienced photographer. ```

    X-Pro 2

    21.08.2017 02:00

    ```text I loved my X100T, and I love my X-Pro2, but it is a little bit too small when I walk around for hours after hours shooting non stop. If you are going to get one accessory for your X-Pro 2 or X100 then I’d get a thumb rest. ```

    ```text The basic idea is that you are this little piece of metal to the flash hotshoe, that extend a curve against the right side of the camera. Giving you a surface to rest your thumb on. The result is a more ergonomic experience, if you have larger hands. ```

    ```text The good thing about smaller cameras are that they are smaller, easier to have with you everywhere, while the bad thing about smaller cameras is that they are way less ergonomic in many ways. Or I do at least think so. ```

    ```text I added one of these to my X100t, and it made it much more comfortable to use. And I did the same with my X-Pro2. I either had to do this or add a larger grip. I personally prefer this because it doesn’t make the camera larger, while giving me more or less the same thing. ```

    ```text You’ll find cheap ones, and you’ll find expensive ones. They do more or less the same thing, and both work. The more expensive ones are much better; the paint don’t rub off; you don’t have to use a screw to secure them. I use the ones made my Lensmate (order them directly if Amazon won’t ship them to your location). ```

    Analog Photography

    14.08.2017 02:00

    ```text Let me preface what I am about to say by defining what I mean by analog photography. Because analog cameras comes in many shapes and forms. Everything from point and shoot, to very advanced SLR models to the ones that might have one but don’t require a battery. ```

    ```text What I am talking about here is: ```

  • A system camera: you can change the lenses and set settings like shutter speed and aperture manually.
  • It is mechanical. This means that the only thing that require a battery (if there is one) is the light meter. Everything else works fine without a battery.
  • There are no “auto” modes.
  • ```

    ```text There are many reasons to why I love analog photography: focus, simplicity and relatively cheap gear. I think digital SLR or digital range finders are the best place to start learning because you can shoot so much, without costing you that much money. You are set if you get a crop sensor camera, a 35mm lens, some batteries and SD cards. And the only cost moving forward after that and a Lightroom license is electricity and external hard drives if you fill up your computer. While analog have a real cost connected to it. Around $10 USD per roll of film, and usually 2-3x the cost of a roll to develop it; if you dont do so yourself. ```

    ```text My current camera is a silver Nikon FM that I inherited, it came with a 50mm f/1.8, and I also bought a used 24mm f/2.8. I mostly use the 50 because it is my focal length, and it is so much lighter. ```

    ```text If I go out with my FM to shoot, I usually just bring a few spare rolls of films. And that’s it. I have used it for around a year, and the battery is still going strong. What would be the result if the battery died while traveling or being a place I could not get a replacement? Well, I’d just use the f/16 Sunny method (Sunny day, 1/100, f/16, ISO 100) . ```

    ```text My X-Pro 2 is a little bit more of a drag to get it all sorted. I usually havet o check how much room I have left on my cards. Then I usually bring at least one spare battery. ```

    ```text You can probably get set up with a excellent analog SLR + a really good lens for less than the price of a entry level DSLR kit. And if you are willing to pay a couple of thousands of USD, you could get the camera I really want: a Leica M6. ```

    ```text The most important thing I have gotten from shooting film for around a year now is a much better understanding of focusing, exposure and speed / ISO. ```

    ```text When you shoot digital, you are used to being able to change the ISO as you please. This is not the case for analog. Instead of having a sensor, you have a roll of film. This means that you need to figure out what is the best compromise for the kind of shooting your are doing the next X. In other words: until you have shot 24 or 36 shots. ```

    ```text You can push or pull (shoot at a higher or lower ISO than it is rated as) but you need to do so for the whole roll. ```

    ```text My personal preference is to shoot 400 films. I prefer Fuji Superia for colour and Ilford HP5 for black and white. Sunny day: ISO 400, and I usually push to 800 in general or 1600 if it is really dark. ```

    ```text Again. You can’t switch it up in the middle of a roll. ```

    ```text The first thing you learn when you start shooting analog, with the kind of cameras I like is how focusing really work. I kind of knew how it worked. The basic idea is that you twist the focus ring until what you want to have in focus are in focus. You can also do so by using a distance scale on many older lenses (and Leica lenses). The F-number shows you what will be a focus in terms of meters / feet with your current focus point. ```

    ```text The second thing I got into my fingers is how different exposure settings impact each other. For example: with this film I can’t shoot here, because it is too dark. Or I can’t go down to F2 here, because my camera don’t go above 1/1000th of a second, and I use a ISO 100 film. Or I either have to go for a very slow shutter speed (potential shake / blur) or I need to go for really shallow depth of field). ```

    ```text You have all the same problems wit ha DSLR, but you almost always have extreme shutter speed and ISO options that you can get a compromised version of what you thought you wanted. ```

    ```text If you think it is a hassle to adjust all of it yourself, you are kind of right. But it is much easier when you have physical dials for everything. You usually just pick “I want this shutter speed” or “I want this f-stop” and adjust accordingly. And it is much easier to focus manually on cameras that are made for it. SLR’s often have a micro prism and range finders are rangefinders. Both are based around the principle where you only need to make sure that the stuff in the “focus area” line up. ```

    What would a true digital Leica M look like

    12.08.2017 02:00

    ```text If one would pick the three most influential camera’s in history, I would say the Leica M3, then the Nikon F4 and last the iPhone. The reason is that the M3 basically invented 35mm photography and how cameras looked and worked up until the SLR; the F4 is the prototype for how SLR’s looked and worked from it was introduced up until today. And nobody thought of phone photography as anything but a gimmick before the iPhone; not the first one though. Probably the 4S? ```

    ```text Anyways. ```

    ```text If you look at the Leica M series from the M3 up to the M6, you see a camera that has just what you need to create. Combined with build quality that makes it possible for cameras made in the 1950’s through the 1990’s to still function today. The reason is that Leica continues to service them, and all of their modern M mount lenses are still compatible and neither the batteries nor the film is proprietary. ```

    ```text There have been a few attempts at making digital Leica M’s- But I’m not convinced that we have seen the first true Leica M. There are a number of reasons for this. Most of all because they are too much like a digital camera and not enough like a true M. ```

    ```text If you pay $8000 for a camera, then you either expect the best technology on the market or something that is built to last. All analog Leica M’s were expensive new. But that is fine if you can use it for over 60 years when its maintained properly. ```

    ```text I think that a Leica M digital camera should look and work like a M6, except for the thing that advances the film and the thing you use to rewind it. Those can we just get rid off. But the rest should be the same. ```

    ```text A ISO dial. ```

    ```text A shutter speed dial ```

    ```text You turn it on or off with the shutter speed dial. ```

    ```text And no screen or additional buttons. ```

    ```text There should be a “analog” counter like you have on a M6; but it should show how many more pictures there are room for on the SD. And it should use standard batteries you can get in any photo store. ```

    ```text The view finder should not require any form for batteries, and the only parts that should use battery power is the sensor (when its in use), the light meeter and the counter thing I mentioned above. ```

    ```text And of course no auto shit; we are talking about a Leica M after all. ```

    ```text But. If this is a camera that is going to be useful in 20 years, then they need to be clever regarding the sensor. A 24MP Full frame sensor is probably good enough for the nest 5-10 years for most people. But I still think they should be upgradable. Send it in to Leica to get the latest generation “M” sensor in it. Just like a M3 from 1954 can use the latest in 35mm film technology. ```

    ```text Let Leica be Leica. ```