My Bower/Gulp settings

This is my Gulp.js workflow settings based on examples shown in this PluralSight course (I really recommend you to watch it). I am using these gulp plugins: main-bower-files for creating list of js files to be injected gulp-inject for injecting js/css files into index.html file When you install some library via bower you should do so with the –save option, so that it automatically updates the bower.json file. Like this bower install angular –save That will add following line to bower.json file: “dependencies”: { “angular”: “~1.4.8″ } Why do you need it? Because the main-bower-files plugin will then read this “dependencies” section and inject listed scripts …

Continue Reading

Recover deleted files by VisualStudio

Image this: You are working on a new functionality. You open up your IDE and start hacking away. You create several new files, invest your time and effort and then you accidentally delete the wrong file. No problem, that’s what we have Git for, right? But you forgot to add that now deleted file to version control. Aaarrrrggh. There is no way to retrieve that lost file. Bad, bad stupid little programmer. There is one little hack to save you (if you are in Windows): Locate the folder of deleted file and press Ctrl-Z. That will undo your deletion. It …

Continue Reading

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) { var result = await SomeDbQueryAsync(item); results.Add(result); }); The code looks remarkably similar, but the 1st sample will throw this exception “A second operation started on this context before a previous asynchronous operation completed. Use ‘await’ to ensure that any asynchronous operations have completed before …

Continue Reading

VisualStudio has problem when multiple versions of Typescript are installed

You can have several versions of Typescript installed on your machine and each project in Visual Studio can be configured to use different version by specifying that version in .csproj file. Like this But you might still have problems with IntelliSense for some native javascript objects. VisualStudio uses file lib.d.ts  to learn interfaces of window objects, events, etc. This lib.d.ts is updated with each version of typescript you install. When some interface become obsolete, it is removed from lib.d.ts, and VisualStudio then marks usage of such an interface as invalid and refuses to build. Now you have problem. You can either manually update …

Continue Reading

Hledám kancelář

PROSÍM O SDÍLENÍ Od 1.1.2016 budu pracovat na volné noze a potřebuji si najít nějakou pěknou kancelář. Nechci být celý den zavřený v kanceláři úplně sám, takže bych se rád k někomu připojil nebo našel někoho, kdo se připojí ke mně. Jsem programátor, takže k práci potřebuji klid na soustředění. Potřebuji také dobré světlo, aby mě nebolely oči a neleskl se monitor. Většinou pracuji ve stoje se sluchátky na uších, takže se nebudeme moc rušit. Ideální by bylo najít někoho s podobnými požadavky na práci: ticho, světlo, příjemný prostor a stabilní rychlý internet. Lokalita: Liberec nebo velmi blízké okolí  

Continue Reading

C# Coding conventions

These coding conventions were originally written by my colleagues Filip Kassovic and Michal Třešňák in ST-Software. I have only made slight updates and published it on my blog. Do not use “var” keyword when not necessary var response = SomeClass.SomeMethod(input); Reason we don’t see the type of “response” “Find Usages” or “Find all references” doesn’t find usage of type when using “var” Exceptions obviously, you have to use it for anonymous types var anonymous = new { A = 1, B = 2 }; Do not use complex object initializer PaymentTransaction transaction = new PaymentTransaction { Token = statusResponse.RefNo, Error = …

Continue Reading

Download files via POST request in AngularJs

There are times when you need to download file but the download is initiated via POST request, because the request contains too much parameters to fit into limited GET request. In my case I needed to generate ZIP file. First you need to define custom method on your $resource which will handle the download method, like in the example below. Have a look at the transformResponse method. It creates a Blob from the server response (binary representation of the Zip file) and tries to extracts the file name from response headers. Then you need to define method on controller. User clicks button “Download ZIP”, your …

Continue Reading

How to write for-loop like code in SQL

I needed to dynamically generate missing items in database. I had a list of Sports and Categories, and I needed to generate items with all combinations of these two entities. But some of them already existed in database, so those should be skipped. My idea was to perform kind of for-each loop iterating over the Sports collection, but written in SQL. In each iteration I would check if given combination already exist in DB and if not, I create it. SQL Cursor comes to help If you run into issues with another coding technique and need to get something done …

Continue Reading

C# – How to find overlap of datetime intervals

I needed to count the overlap of the datetime intervals. After some coding I’ve refactored the code to static class and uploaded to Github, so that others can use it too. It might save you some time 🙂 There are currently two methods. One to get the interval overlap and the other to count the interval duration. Go ahead and check out our company GitHub. The code is pretty straight forward, so no need to explain too much.

Continue Reading