Mock window.location in unit tests

When you run unit tests (I am using Jestjs) on functions which read window.location.href or window.location.search, you need to somehow mock the value. Problem is that when you try to edit the value of window.location.search it will not work. Neither will work overriding it by Object.defineProperty(). But there is a simple workaround solution, and that …

Workaround for eternal problem with node-gyp on Windows

This is super annoying. Reliance on node-gyp on Windows is such a pain! The error description says the it can not find the Python executable, even though it is there. There is a workaround – 2021 SOLUTION Re-Install node-gyp globally – npm install -g node-gyp@latest  Delete node-modules Delete package lock file Reinstall all packages again (pnpm i …

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 …

Ohlédnutí za konferencí Wisephora 2016

Děkuji Topmonks za super konferenci. Udělala mi radost 🙂 Nosné myšlenky, které jsem si odnesl (Podle mých zápisků v notýsku, není to doslovný přepis, spíše zachycení poselství. Nebyl jsem na všech přednáškách, takže něco chybí… A něco mě třeba tolik nezaujalo 🙂 ) @steida – Člověk umře a Bůh se ho zeptá: “Tak co, jak bylo …

Difference between async loops in C#

What do you think will happen when you run these 2 snippets of code? They both looks quite similar at the first sight, don’t they. This one var results = new List<SomeClass>(); mylist.ForEach(async item => { var result = await SomeDbQueryAsync(item); results.Add(result); }); versus this one var results = new List<SomeClass>(); foreach(var item in mylist) …

How to speed-up generating PDFs via TMS Flexcel

In my current project we needed to generate lot of PDFs from the same excel template.  For this we use TMS Flexcel library. It is a simple library for generating Excel or PDF files in .NET. It loads a xls template from filesystem, populates it with data and that’s it. Quite easy. But generating tons of files in a …

Ohlédnutí za DevFestem 2014

Letošní DevFest se mi hodně líbil a oproti minulému jsem si ho mnohem více užil a méně se dozvěděl 🙂 Což bylo samozřejmě dáno tím, že jsem se tentokrát rozhodl nehonit se přednáškami a snažit se stihnout co nejvíc. Přednášek a navzájem si konkurujících akcí bylo tolik, že by se to stejně stihnout nedalo. Na …

Handle exceptions in ASP.NET + IIS

Handling exceptions in ASP.NET can be quite tricky. There is lot of ways how to handle them, some are described in the links below (see resources to study). Our solution looks like this Web.config <system.web> <!– MVC Settings –> <compilation debug=”true” targetFramework=”4.5.1″ /> <customErrors mode=”On” /> <!– TODO: Use RemoteOnly for production –> </system.web> <system.webServer> …