Collection of interesting news, resources, tips or issues and their solutions that caught my attention.
git, a commit is referenced via its hash value - 40 digit string. Usually, only the first 8 digits are used, as that's enough to be able to (visually) differentiate one commit with others. Alas, it may lead to a security hole if such a way is used in, let's say, a build script - because of Commit Hash Collisions. Thanks to that, one might also take down Github Actions.
Applications are being served on many types of devices - desktop, mobile (Android, iOS), and even on something more exotic, like smartwatches. Every device means a different way of application usage, so are the requirements for API. Oftentimes, there is one, general-purpose API that serves all types of clients, but it may become cumbersome. Why not have one API per user experience? Read more about Backends For Frontends pattern.
@types directory is significant for TypeScript compiler, as it looks there for type declarations before it reaches the actual package
node_modules directory. The logic behind this behavior is that if the package itself had type declarations, you wouldn't have installed it from DefinitelyTyped.
DefinitelyTyped is the repository for TypeScript type definitions. We may call it the official repository now, but that has not always been the case. When Boris created a repository for this project nobody knew TypeScript will become so widely-used. Read its whole story from zero to hero.
In GitHub, you can highlight not only the code syntax but also a differences, just like with
git diff command. It may be very helpful while providing some step by step guides in READMEs or issues.
Here's the syntax:
```diff +foo -bar baz ```
that results in:
+foo -bar baz
Unfortunately, it's not possible to use both language syntax and diff highlighting together.
You can push your
console.log()-driven development to a more advanced level with
console.group() method. It creates a new inline group, indenting all following output. To move back, use
console.groupEnd(). Check this article about advanced logging.
In TypeScript, the difference between union types and intersection types can be counter-intuitive at first glance. Ryan Cavanaugh gave a great explanation: "the union of the domain of values produces an intersected set of properties and vice versa."
Besides learning new stuff, networking is another crucial part of conferences or other events. But, it can be hard to join the discussion of the group of people one doesn't know. That's where the Pac-man rule comes in. When standing as a group of people, always leave room for 1 person to join your group.
How to make your application more accessible? What about to include No mouse day into your development process?
How to make your application faster? Firstly, you may want to know how does it behave under a slow connection. To get an idea of what is it like, developers at Facebook have 2G Tuesdays - simulating slow connection for the whole one day. This is how the performance should be tested! From the talk New adventures in front-end by Vitaly Friedman.
Some time ago I was struggling with TypeScript generic types and decided to reach for help from smarter guys on Stack Overflow. I received an answer, thanks! The solution is based on very specific conditional type which I was not familiar with back then,... and I'm probably still not. But, there is a one truly helpful talk by Gregor Woiwode describing the matter of this TypeScript magic. I really recommend you to watch if you want to understand it better.
Is your project compiled from TypeScript? Are you too strict? If so, you may like
--strict compiler option. It's a shorthand for enabling all (currently 7) strict type-checking options. You can always turn off individual options if needed.
I have recently revealed my first browser extension, which enhances Google Calendar. To work it needs to fetch calendar data from Google API. There is a neverending (okay, several steps...) approval process one has to undergo to get API access. To make the extension work also under Firefox I had to specifically request support to whitelist
allizom.com as a verified domain. It just cannot be simpler, everything for the user's security...
Learning in public - is a quest to be as open as possible. But there's also kind of a counterpart to such spreading movement, that has probably always been a part of the World Wide Web - dark web. Beware, not The Dark Web, but The Real Dark Web - rarely acknowledged majority of web developers.
Did you know the difference between
hidden? Neither did I! See examples and explanations.
Bad Frost is a father of Atomic design concept, which is now 6 years old. In his article he writes about the inception of the idea and how have the design systems changed throughout the years. If you work with CSS you may like the BEM methodology which clicks with this concept very well.
npm comes with some very handy scripts by default, which one of them is
npm version. It is used to bump your package version (in package and shrinkwrap files). In a git repository, it also creates a commit and adds a tag in semver notation. This step might not be desirable when you use a different type of versioning, so it can be skipped by running it with
The security of the system must be preserved even when its architecture and functionality is publicly known, as far as the keys stay secure. Kerckhoffs principle about cryptosystems.
Level up your git terminal skills.
git add -N adds a new file to the history without its content. Then it is easy to see the whole file with
git diff and add only some portions of it with
git add -p. Kudos to Olivier.
Don't know why, but I have been neglecting CSS
background-position's offsets for a very long time. Probably I forgot it exists! I'm pleased I've discovered it just recently. Now I'm again able to position background images relative to the edges of their elements.
Icon fonts have still their place even in today's world of wide SVG support. With fontello.com is possible to easily create one font with characters from different sets. And that's very handy!
Staying in sync with the project's dependencies versions across different workstations and servers can be sometimes problematic.
npm ci can help with many issues. It stands for a clean install and is available since version 5.7.0. It installs dependencies only from your
package-lock.json file (it also removes
node_modules directory). It should be used in the CI environment, project setup, etc. I've started using it in all my projects ever since.
window resize event behaves a bit unexpected, well, just at a first glance. It is fired almost whenever you scroll a page in the mobile browser. My investigation revealed it's the correct behavior. It's common for mobile browsers to show/hide omnibar or other toolbars while scrolling up & down which does change the size of the visible area - thus firing the event is expected.