Thursday, July 18, 2019

Browser Dev Console

console.log

console.trace

console.count

console.assert

console.clear

console.dir

console.group(End)

console.memory

console.table

console.time(End)

Strings and styles

Sunday, July 28, 2019

Magnetic USB cable

I had troubles with a phone battery, so before replacing it I looked up how to properly charge it. Li-Ion batteries are happiest around 50 %, apparently, and don't really care much about how many times you plug them in.

So it means charge it often for shorter periods of time and if you can, don't charge it over 80 %. That also means you'll be wearing out the cable port more, so I decided to try out a magnetic cable.

Because you need to keep a small part with magnet and pins in the phone's port all the time, it's hard to use other cables, obviously. I started with three cables, two for home (computer + bedside) and one for work. Later I added one longer to keep in the car.


I rarely charge on the go, so I have an original cable in my backpack. It's also for my peace of mind, so I don't need to worry it may magnetize something I throw in there. I also still have the luxury of 3.5 mm jack on my phone, albeit I use Bluetooth earbuds for workouts, so audio is sorted out as well.

What I love about the magnetic cable is the magnet is quite strong and to connect it I simply grab the phone and casually move it to proximity of the cable connector, which snaps on promptly by itself. Brilliant! It would also work great in a phone cradle, but I don't use one.

If you have proper magnetic cables, you can share them across devices. The cable shouldn't care if the bit in your phone is shoved into a Micro USB, USB-C or Lighting port, and the other side of the bit is always the same. Make sure the cable is not only for charging, but for data as well!

Small disadvantage is I apparently used the cable to help stuff the phone into my car phone holder, because now I'm having difficulties :-) Cables I use have blue LED, which is quite bright and I had to put a rubber band on it for my nightstand.

And sometimes the phone's display turns on for no apparent reason, like if it lost a charge for a brief moment, but it didn't. I don't know if it's caused by the cable, or it's a software issue. It doesn't occur that often though.

Friday, July 5, 2019

Saving

There are basically three major approaches:

  • save everything at once using a manual trigger (button),
  • save after every change using an event trigger,
  • save after a time period using a timer.

My approach is a combination of all of the above, with incremental saves prevalence. But, as usual, things aren't as simple as they may seem. In forms you can save data only after all required fields are filled. In editing long text there are no partial changes, so there's no cue when to save.

Therefore I have two ways of auto-save in a text. I define a 5 secs timer, that saves the text after it's not changed, which means e.g. arrow keys do not stop this from firing. The other way is I save after Enter key is pressed.

Before each change of text I create a “backup”, to have an undo option in case I or the editor mess it up. After the text is verified, those backups are deleted.

I also try to show saving in some unobtrusive way, like dimming header color or change it's background.