ClosedXML is a library which provides object oriented way to manipulate Excel 2007/2010 files. I used it in one of the projects to parse table of data from spreadsheet. However, I discovered that there was no way (maybe there is now) to parse the table using the column names. For a while I used column indexes but when the table comes in with rearranged columns the mapping breaks. So I came up with the following solution.
Gentle Logic
Developer's Life... in debug mode.
Thursday, September 1, 2016
Wednesday, December 30, 2015
TSQL: count specific children in hierarchy
We have a project with hierarchical data: there are products nested in different categories and categories in its turn nested in segments. The goal was to count products and display this count on parent nodes. So basically we needed something like this:
As you can see there is amount of products displayed next to every node. Lets take a look on how to count those products using TSQL and CTE tables.
Tuesday, December 29, 2015
.NET: Custom minified script bundles with sourcemaps
I stumbled upon a situation where I had to create minified javascript bundle with a sourcemap for this bundle. There is no default implementation at the moment, however there are classes in Microsoft.Ajax.Utilities namespace which can be used to do it.
Wednesday, September 23, 2015
Drawing graphs with vis.js
First of all I want to give a shout out to the guys who made amazing visjs library - it is a great thing. It has a ton of different features, I used only network, but there are much more out there.
We had a task recently: our customer works with a chain of suppliers and factories often related to each other, and all this data is stored in the database. We had to find a way to visualize data and display it as user friendly graph. And we found vis.js :) So we took our data, mapped it properly and got this with no effort at all:
Let's take a look on how it’s done.
Friday, July 3, 2015
Tip: get rid of ads in skype
Skype ads are annoying...
Tuesday, May 12, 2015
Tip: POST request using Fiddler Composer
Quick reminder on how to compose requests using Fiddler.
Tuesday, April 14, 2015
Managing encrypted files
Imagine that we have a system which generates a certain amount of small .pdf or .xlsx reports and stores them on disk. The requirement is to encrypt those reports and store them as encrypted files. Original file must never hit the disk and all the encryption must be done in memory.
Tuesday, April 7, 2015
Exploring BMP format
Let's decode bitmap image file. Just because it's simple and I want to dig into something. And because BMP is relatively easy.
Thursday, December 25, 2014
C#: Using Microsoft Unity dependency injection in Unit Tests
After working with Ninject and Windsor for a while I finally faced Microsoft Unity dependency injection container. And here is the way to build up an infrastructure for Unity container to use it for example in Unit tests.
Friday, December 12, 2014
MSSQL: Synonyms, Post Deployment scripts and Database Project.
MSSQL Synonyms allow to create proxy tables in one database for another database so we can query tables from both databases and even make joins between them. Obviously it can be done via cross-database queries, however sometimes second database is on the remote server and it is useful to have synonym for it in your database.
Thursday, December 4, 2014
MSMQ reading and writing
MSMQ is a message queue implementation by Microsoft, which allows different applications to communicate with each other quite reliable. MSMQ supports sending objects and streams, does not require any additional software. However, it doesn't have embedded subscriber (or any bus management) implementation. We used MSMQ for logging, in order to reduce database load. So we needed a reliable way of reading from / writing to MSMQ. Let’s see how it can be done.
Thursday, July 31, 2014
EF Code First: Create table out of Enum
Imagine you have a number of enums in your code. They are defining static data and you want those enums to be mirrored in database as tables with appropriate data. Here is the tip how to quickly map enums to your tables and to seed them with enum values.
Wednesday, July 30, 2014
Entity Framework Code First: Custom data context initializer
While working with Entity Framework Code First at some point you will probably decide to create custom database initializer which allow you to create/recreate database based on flag in configuration file and automatically seed this database with data, stored procedures, views etc.
Saturday, July 26, 2014
How does WebActivator work?
WebActivator allows to execute some code before application starts (or when it's shutting down). Which becomes really useful when you are making your own packages and you want your package to do some actions when application starts/shuts down. And the person who will use your package does not need to do those actions manually.
Let’s look at the features of WebActivator and get inside the source code to see how it works and what does it mean when you meet in code something like:
[assembly: WebActivator.PreApplicationStartMethod(typeof(SomeClass), "SomeMethod", Order=1]First of all lets look at the WebActivator structure.
Saturday, July 19, 2014
Tip: skype chat commands
Recently I discovered the fact that Skype has a bunch of useful chat commands which can save time clicking around UI and overall come in handy.
Those should be used in latest Skype version and can be typed as a message, no one else will see it except you.
/get uri for example will return you an url that others can use to join the group conversation.
/remotelogout will sign out all other instances except the current one. Ain't it useful to log off Skype you left open at work? :)
/showplaces will show all the other instances where this Skype name is currently signed in.
/alertson and /alertsoff will enable/disable message notifications for current chat. By the way enabling notifications can be used with filter /alertson [text] specifying text which should appear in chat to trigger notification.
Complete list of commands can be found here or simply type /help in chat and it will give you the same link.
Thursday, July 3, 2014
Tip: Using syntax highlighter
I know i should've used this amazing SyntaxHighlighter (many thanks to the developer!) from the very beginning, but for some reason i got to it only now. So here is my quick glance on this beautiful product. :)
Thursday, August 29, 2013
Check Gmail inbox via Windows 7 PowerShell Part 2: message body
Here i wrote about how to quickly check gmail inbox messages using gmail rss feed and powershell. But what about getting the email body or applying some sort of filtering? Luckily, powershell allows us to execute c# code :)
Tuesday, August 20, 2013
Why multiple inheritance is bad?
I'm not against multiple inheritance. Anything can be a tool in the right hands, and multiple inheritance is a such tool. But it is common question: why multiple inheritance is not suitable for most situations? And really it is not very good. Almost any problem could be solved using single inheritance, interfaces or composition. Many languages deny multiple inheritance, and here is my point of view on this problem.
Imagine, we have two classes "cat" and "duck" :)
Monday, August 19, 2013
Tip: analyze .net stack and heap
Sometimes it is necessary to analyze values stored in stack and heap. Or maybe you need to answer the oldest question on earth: "do the array of ints stored in stack?". You can once again use SOS dll for it.
Friday, August 16, 2013
Tip: find memory leaks in .net application
Sometimes we face some nasty problems, while working with managed code. And one of them is memory leak. When you see in task manager, that an application slowly (or rapidly) consumes precious memory, it means that garbage collector can't release some resources, allocated in code. Sometimes it is easy to find the weak spot, sometimes it is not. Memory leak can be represented by something like holding the reference to managed object longer, than it's needed, or not releasing unmanaged resources.