Frozen global object

If your app uses global object as a config, you should make sure, that this object is truly readonly. So that an attacker can not modify it in dev console. This is how to do it. // example of frozen global object // freeze the config object properties const config = Object.freeze({ httpApi: ‘http://127.0.0.1:20003/v1’, wsApi: …

Custom command line shortcuts with Doskey

I’ve learned this nice trick from Petr Horáček aka Besir while working on Nakamotox. So the credit goes to him. You can define custom commands via doskey (only on Windows) and then invoke them via command line. It is quite powerfull, because you can define alias for command with predefined attributes, so it save you lot of repetitive …

Email validator for Angular

Angular has built in email validator, but it is very benevolent one. It allows for single letter domains, therefore email a@b is considered valid. Their motivation is that when used in intranet it can be perfectly valid email, because you can have custom domain names. But it does not make much sense in the broader …

Print document from cross-origin iframe

When you need to show content from some other site, such as Google Docs, you can easily embed it inside an iframe. Google Docs even generates it for you. But what if you need to print that document via some button click? You can not do that, because the cross-origin policy does not allow it. You have basically …

Workaround for ExpressionChangedAfterItHasBeenCheckedError in async pipe

Imagine that you have this piece of code, where userInfo$ is Observable and it value is not yet emitted. <app-change-email [currentEmail]=”(userInfo$ | async).user.email”></app-change-email> The code works, but it will report error ExpressionChangedAfterItHasBeenCheckedError to the console (only in dev mode). That is because the component has received the value, but the value has changed later. Angular …

Angular custom event bubbling

Custom events in Angular by default do not bubble up. It is because they are not really events, they are based on EventEmitter, which is similar to pub/sub mechanism. You can read lengthy discussion about it on Angular’s Github. Unfortunately the examples provided by Angular team often mention $event as named parameter in the event listener, …

Node_modules versus Docker

I’ve encountered strange error lately. Whenever I tried  to run npm install in my project’s folder, it failed. The error says something about not being able to unlink folder. The interesting think was that it only happened under certain circumstances. The reason for this was the when I started docker compose up to run my …

Google’s ReCaptcha not appearing?

Recently I had a weird problem that Recaptcha has not rendered at all in most of the cases. It seemed random however, but most of the cases it failed. Later I’ve figured out, that it was caused by some network race conditions. The solution was then quite straightforwad: manual initialization of ReCaptcha after the script has …

ES6 generators and async/await

Motivation for this blogpost was my initial ignorance regarding the upcoming ES6 and the generator function. Around christmas 2015 I was looking for a new job, and during one of the assigned test-jobs I had to use generator functions, the .co library, two different databases (one SQL and the other NoSQL)  and node.js. I failed, …

Poznámky z Wisephora Live – 28.6.2016

Konference Wisephora byla skvělá, takže když jsem se dozvěděl, že bude mít neformální pokračování, věděl jsem, že budu chtít jít. A stálo to za to 🙂 Sešlo se nás překvapivě málo, asi 12-15 lidí, ale odnesl jsem si spoustu zajímavých myšlenek a podnětů. O tom je vlastně tento článek – shrnutí útržkovitých myšlenek. Prvním hostem …