Useful extensions for Visual Studio

by Victor 21. October 2015 01:37

Web Compiler:
The easiest and most powerful way to compile LESS, Scss, JSX and CoffeeScript files directly within Visual Studio or through MSBuild.

Image Optimizer:
Lossless optimization of JPEG, PNG and Gifs - including animated Gifs

Bundler & Minifier:
Adds support for bundling and minifying JavaScript, CSS and HTML files in any project.

Web Analyzer:
Provides static analysis directly in Visual Studio for JavaScript, TypeScript, JSX, CSS and more

Querying BsonIgnore fields in MongoDB using LINQ

by Victor 8. October 2015 22:27

If you have a BsonIgnoreIfDefault attribute on a property, that property will not get serialized and persisted to your MongoDB database if its value is the default for its type. The default for reference types is null. The default for primitives are: int/double/long/decimal = 0, bool = false.


Now, let's take a look at a use case. Here, we want MiddleName to never be null, and to be an empty string if it's never set.


public class Person
    public string FirstName { get;set; }

    public string MiddleName
        get { return _middleName; }
        set { _middleName = value == null ? "" : value; }
    private string _middleName = "";

var john = new Person { FirstName = "John" };

PersonRepository.Where(p => p.FirstName == "John", p.MiddleName == "");


In this case, the query will not return anything because an empty string is the default for middle name and we told the serializer to ignore MiddleName if it's the default. So, in the database, this Person object is saved without a MiddleName field. In order to query for any Person that does not have a MiddleName, you have to use null, like so:


PersonRepository.Where(p => p.FirstName == "John", p.MiddleName == null);


.NET | C# | MongoDB

Formatting a phone number in .NET

by Victor 8. October 2015 22:24

If you save your phone numbers as only numbers, eg., 5615551234then you can use this code to format it for display:




which will output 561-555-1234. Neat huh?

Tags: , ,

.NET | ASP.NET | C# | Software Development

ASP.NET Bundling of AngularJS templates

by Victor 7. October 2015 23:47

Saving this link here for future reference. Great post on how to add your AngularJS templates to ASP.NETs bundling and minification process.

Tags: , , ,


Rename database in MongoDB

by Victor 27. September 2014 00:42

db.copyDatabase('OldDatabaseName, 'NewDatabaseName');

use OldDatabaseName




Visual Studio javascript extensions

by Victor 23. July 2014 20:39

This one adds AngularJS intelisense:


This one adds outlining for regions, brackets, braces, and comments:


Tags: , ,

Getting full path in Windows Service

by Victor 14. July 2014 18:53

If you need the application path inside of a Windows Service you can use this property to get it. Something I always forget so here it is for easy reference.

Tags: , ,

.NET | C# | Software Development

Excel - Trim all cells

by Victor 31. May 2013 07:52

Here's a macro to trim all selected cells:


Sub TrimCells()
    Dim R As Range
    Application.EnableEvents = False
    On Error GoTo ErrH:
    If TypeOf Selection Is Excel.Range Then
        For Each R In Selection.Cells
            If R.HasFormula = False Then
                R.Value = Trim(R.Value)
            End If
        Next R
    End If
    Application.EnableEvents = True
End Sub

Tags: ,

Detecting the File Download Dialog in the Browser

by Victor 11. January 2013 19:22

I ran into a scenario in which I needed to know when a PDF file finished "rendering" to the browser. Actually, it was being served as an attachment. Either way, I needed to know when the client got the response back from the server. This stumped me for a while until I found this extremely useful block post describing a very elegant solution using a cookie. The gist of it is to create a token on the client side and send it to the server with your file request. I did it via the query string. On the server side, when the pdf is done, add a cookie with the value of the token. Back on the client side, poll for a cookie with the token. That's it! Check out the full explanation here.

Tags: ,

javascript | jQuery | Software Development | Web Development

Visual Studio Conditional Pre-Build Event

by Victor 9. January 2013 08:35

Say, for example, you want to execute a pre-build event if the current configuration is not Debug. Then you can do it like so:


if not '$(ConfigurationName)' == 'Debug' [YOUR PRE-BUILD STATEMENT]

Powered by BlogEngine.NET

About Us

Wuji Touch is a software consulting firm based in Delray Beach, Florida. We specialize in Microsoft technologies, but we also have experience with Progress OpenEdge, iOS, and Android development. This is our blog. These are the tales of the pains and pleasures we experience daily in our journey through 1s and 0s.

Month List