hjertnes.blog

#

11.12.2017 01:00

Charging the iPhone 8 Plus

11.12.2017 01:00

It takes forever to charge the iPhone 8 Plus using the charger and cable you got with the phone; and it is a little bit better if you use a iPad charger. But it still takes a very long time.

But, you can get faster charging if you take one of the Apple MacBook Pro USB C bricks and plug one of the LIghtning to USB-C cables into it. My impression is that it charges around twice the speed.

Which brings me to my point. Why can’t Apple start to bundle better chargers with their devices? Or at least a cheap version of their current chargers with USB-C instead of USB-A. To charge using the USB-A cables is horrible. It takes forever. It is bad user experience to wait longer.

I get the margins argument, that people use every time someone thinks Apple should do better. And, yes, I get that. But I just want Apple to start moving in the right direction. Because if Apple comes out with phones with bigger and bigger batteries, the charging over USB-A thing will become a joke.

If you want faster charging: get a MacBook Pro power brick (the 13 inch version is good enough) and a Lightning to USB-C cable.

React

11.12.2017 01:00

One of the first things I wrote down in my notebook as I was planning or trying to figure out if there was enough stuff to write about to do this site was a React introduction. I know React fairly well, and have been working full time with it for quite a while now. I’m not sure how many things there will be to write about React. But I assume there will be a few weeks with React related content.

I’m going to start with basics and then move on to more advanced topics and try to cover the different aspects one have to consider writing an React app. This will also be a excellent opportunity for me to learn the various parts of React I personally don’t use.

The goal at the end of this small or large series of posts will be that you know everything you need to know to build from small apps to large apps; with or without server side rendering.

#

10.12.2017 01:00

I’m fairly happy with the experience of moving over to Lightroom CC this far. Uploads are as fast as I let them to be. And dealing with CC is far less complicated than Classic. No options during import and the previews are hidden under the hood.

There is also a downloader for those of us that want to make backups.

#

09.12.2017 01:00

My first impressions after being in the process of importing all of my raw files into Lightroom CC is that it is that I wish LR was when I got started with it. It might not be what most power users want. But it looks promising.

#

08.12.2017 01:00

I think the basic premise of MeeToo is a good one, but what I don’t appreciate is the lack of understanding between the difference of harassment and sexual harassment. It seems to me that all harassment are treated as and discussed as the same.

Adding stuff to the prototype.

08.12.2017 01:00

So, you have written a neat little utility function to do something with for exampel arrays. That you are going to use all over your React app.

I’m not going to start a religious war there, but you should read this before you start adding stuff to the prototype of objects you don’t “own”.

Let’s say you have written a method called “found” because you don’t know about “find” or because you prefer to get back null instead of undefined. I’m not saying this is a good idea, I would go as far as to say it is a horrible idea. But my point here is mearly to show what is possible. Extending the prototype is a powerful tool though, useful to work around browser bugs or to get around limitations of older browsers.

You could do something like this:

The problem with this is that then you need to import this function (or even worse copy paste it) into each place you need it. Another way to solve this would be to add it to the Array prototype:

There are many reasons to why you shouldn’t do this. The main reason is what I call the jQuery plugin problem: what if two pieces of code extend the same object to the same value. For exmaple, what if you use a plugin that extend the prototype by adding to the same name, but works differently?

Summary: a very powerful and useful trick to have up your sleeve, but it might not be the best to use it on objects you don’t “own”.

Iterators

07.12.2017 01:00

An iterator is the underlying structure of arrays and everything else you can loop over using for example for-of. You probably don’t need to implement one yourself, unless you are trying to make something that is Lazy. A lazy iterator is when it continues to iterate as needed.

The basic idea is that you add a symbol (I’ll add a example below) that returns a object, with a next method, that returns an object with two keys: value and done; done is a boolean telling the code that iterates over the iterator if it is the last element or not.

#

06.12.2017 01:00

I’ve been very skeptical about Lightroom CC; especially about not having a copy of the images locally. But I think I’m going to give it a shot, now that I have enough bandwidth to do it. But, first I need to find out how to back it up.l

Promise Functions.

06.12.2017 01:00

I have talked a lot about promises before. Some people think they are a unnesseary complcation of simple callbacks. I disagree, because async await makes it possible to make code a lot more readable, especially if you need to do a lot of stuff that would have callbacks. But I have not talked that much about two methods that live in the Promsie prototype: all and race.

Promise.all is a method you can use to resolve any number of promises, and it will not resolve until all of them are resolved. The result is a iterable of the result from all of the promises, in the order they were in the array to passed to Promise.all.

Promise.race on the other hand also takes an array, but will resolve when the first promise resolves. Useful if you for example have multiple ways to fetch some kind of data, and you just want the any of them.