Monday, October 9, 2017

Absolute imports with create-react-app

When developing React using create-react-app with custom-react-scripts, I wanted to use absolute paths for import, and I found this: just adding NODE_PATH=src/ to “.env” file. It worked on Windows, but not on Linux.

After a while, I sorted it out: echo $NODE_PATH told me that my Linux had NODE_PATH being set somewhere. Then, being conservative, I just added unset NODE_PATH to “~/.bashrc” file, and it finally worked.

JavaScript development is a nightmare these days.

Sunday, October 8, 2017

Google Chrome 61 slow, how to fix

After updating to Chrome 61, I instantly noticed that YouTube became slow, and Google Maps – particularly Street View – became so slow it’s unusable. I went back to Firefox Developer 57, but then I missed Chrome’s search capabilities.

I found out that the problem is the HTML5 canvas, and the fix is rather easy: just disable this flag in Chrome flag page:

chrome://flags/#enable-color-correct-rendering

Instantly all the sites became responsive again.

Wednesday, September 13, 2017

Grep and find aliases

Two quick bash functions to speed up name and content search on files. These are to be appended at ~/.bashrc file:
function gr { clear ; grep -rn $1 . ; }
function ff { clear ; find . -name "$1" ; }

Sunday, September 10, 2017

Holy Grail CSS layout with overflow

This morning – yep, a Sunday morning – I needed to implement an HTML page with the Holy Grail layout. A quick search gave me dozens of implementations, but all of them broke apart when you trew a lot of content into the sections. Being fond of the Flexbox model, I quickly came with an implementation that had all the needed overflow control:

This implementation is also modular: if you don’t need any of the panels, just remove them – the layout will stay working. Also, the satellite panels can have fixed dimensions, see the commented values for width and height.

The funny part is that min-height: 0. It’s there for Firefox; without it, the overflow goes wild. Other interesting thing is the absence of the height: 100% to html and body elements, it’s not needed.

Friday, September 8, 2017

Disabling the useless npm package-lock.json

Recently I’ve updated npm to version 5 while working in one of my projects. Much to my dismay, a “package-lock.json” file started to appear, and I finally understood why I’ve seen this file commited in some projects lately.

But since this feature is basically a horrible idea, I started searching a way to permanently disable it. It looks like I’m not the only one who dislikes this, because I found this excellent post, which points to the solution:

npm set package-lock false

And any more “package-lock.json” files that appear in front of me will be summarily deleted.

Thursday, September 7, 2017

Visual Studio Code settings

This morning I was setting up Visual Studio Code at a Lubuntu virtual machine, and after saving the keyboard shortcuts, I opened my current editor to get the settings. Since some of them I consider essential, I decided to publish them here, for further reference.

Tuesday, August 22, 2017

Simple minimalist JavaScript metronome

These days, when practicing guitar, I needed a metronome. Whey you type “metronome” on Google Search, it actually brings out a functional metronome – however it has no keyboard shortcut keys. So I decided to write a simple metronome, with keyboard keys, from scratch, to suit my needs.

Knowing the imprecision of JavaScript’s setTimeout function, I implemented a timer that adjusts itself each call, thus having a fairly reliable precision.

The code is so simple I decided not to create a GitHub repository, so I’m just sharing the whole source code here: