When it comes to code readability, the initialiser syntax makes declaring C# objects very easy and clean to read. It also makes writing the code much faster since you do not need to be adding new constructors and lets you see what properties you have left to assign. But what about performance? Is one method faster than the other? I created some tests to see if the object constructor vs initializer syntax performance is difference is noticeable, here are the results.

To test this I created a console app with a stopwatch that would check to see the amount of time taken to declare an object using a standard constructor and time to declare using the object initializer syntax, aka using curly braces to declare an object.

I used the following code to do this.

I ran the console app using Visual Studio 2017 and the result was a little surprising. 5ms might not seem like a lot to some, but when you are dealing with some code that does this millions of times, this is a big difference. I ran it a few more times and It varied between 2ms-5ms.

I wondered if this was just down to the order in which they were run and not to do with the method used. So I switched the tests around so that Test 2 would run first. If this tool 0ms and the other still took 5ms, then it would be a solid conclusion that using object constructors are faster than using the initializer syntax.

With the methods switched around, it shows that it doesn’t matter which method is used, it is the first one that takes the longest. After this point, all further declarations are instant. To be fully sure of this, I added a for loop that would run this code 100 times. Here is the output.

As you can see, the first call took 2ms and all subsequent calls were instant. At this point it is safe to say that both methods of declaring objects in C# are equally as fast. There is no benefit to using a constructor to declare your objects. Since it takes longer to write code this way, it is best to use the object initializer syntax when writing code.

I have recently needed to spend some time looking for some good WordPress documentation plugins to use on this website. There are quite a few out there but the quality can vary quite a bit. To save you some time, I have put together a list of the best documentation plugins for WordPress so you can start building a documentation wiki right away.

Documentor is a great plugin if you are building documentation for a product where the site itself is dedicated to that product. If you are running a website where you want to document many things that have diverse categories, this plugin is not the best choice. You can pay for the pro version which will allow you to document multiple items, something that might be worth it if you prefer the quality of this plugin.

This one is quite good. In fact, its very good. I used this one for quite a while and had very little trouble with it. You can create many documentation entries. So if you run a site where you want to document lots of different things, this plugin will allow you to easily There is a limit to the amount of documents that can be nested inside one documentation entry. Might be a limitation for some people. I also experienced a weird 404 error when using a redis cache. Whatever way this plugin rewrites urls, causes issues. It would be good if this could be disabled.

This plugin is probably the best quality one you will find, but this comes at a price, literally. If you just want to add documentation for a single product or subject, this is just fine. If you want to document multiple things, something you can do in the likes of weDocs, you will need to pay. This addon costs $29 and all of the other addons cost money too. It is possible to get the same functionality with a free plugin, but this one does have a good level of quality to it.

The quality of this plugin is not as high as the other wordpress documentation plugins. It is reliable though, it lacks the fancy UI elements that the others have, but it is solid and functional. It has not been updated in a while though, so I expect this may eventually stop working or lead to some compatibility issues.

Facebook blocked my domain

So you have hit a critical moment in the managment of your blog or website. All your hard work to build great content is looking like it will be for nothing as your entire domain is now banned from Facebook. What can I do now? The Facebook support website seems to bring you in an endless loop and none of the information seems to work. Fear not, this is not as big of an issue as you think…well assuming you are innocent, its not a big deal. If you have been blocked because your websites content breaks Facebook rules, then this is not the guide for you.

You can usually tell that your website is blocked from Facebook when you attempt to share content. You will either find that the preview does not load or that you get an error message like this one

“Warning – We can’t review this website because the content doesn’t meet our Community Standards”

How To Get Your Website Unblocked On Facebook

So this guide will only work if you are innocent. If your site has been blocked by Facebook and you believe it is a mistake, then this guide will show you how to appeal it. More often than not, Facebook will unblock your website after 30 days or so if it is been flagged by an automated system. As far as I know, permenant bands need to be issued by a human and they are less likely to make these kinds of mistakes. Either way, mistakes happen and this is how you undo the issue.

Start by visiting the Facebook help site here. Scroll to the bottom of the page and you will see a section that says “find answers or contact support”. Click the “Get Started button”. Since this is a Javascript powered page, i cant share the Url, you will need to follow the steps in ths tutorial instead.

Scroll down through the page and click options you need. You may be able to find the answer already here. If not, Facebook actually have a live support system and it is very good. If you scroll to the bottom of the page you will see the option to use the chat support. If thhe chat support is offline, or not available in your country, you can send an email. When it happened to me, I had to send an email. Facebook called me the next day to tell me that the domain block was a false positive and that the issue had now been resolved in their system.

Facebook support chat

Facebook support chat

So if you are innocent and believe an automated system has accidentially blocked your domain from Facebook, this method of contacting Facebook will allow you to get it unblocked very easily.

I was recently setting up PHP 5.6 on IIS 8.5 and hit an error.

I had been following a guide and this one didn’t make much sense. After trying to endlessly debug this i found out that it wasn’t actually anything to do with PHP or IIS, it was a dependency issue. Thankfully, the fix for this is very simple. In order for PHP to function under IIS 8, it needs the Visual C++ Redistributable for Visual Studio 2012 Update 4. In particular it needs the 32-bit version. I was running under a 64 bit OS, but it seems that PHP was running as a 32-bit application and required the 32-bit redistributable. So even if you have 64 bit, download the 32-bit version of the installer.


When it comes to handling datetime on SQL server it can get quite error prone when you are dealing with different regions and end up getting an out or range date exception if you are trying to add a date that is in EU date format to a server that is expecting a US date format.

Rather than having to worry about generating the string for the timestamp you can make SQL Server generate the timestamp for the datetime field automatically when you insert the row. This can be done by setting the default value for the field to a method called “getdate()”.

If you are using SQL Server Management Studio you can set the default value of datetime to the current time using the following. Make sure you set “Allow Nulls” to no and then add the method to the default value field.

SQL server default date time

SQL server default date time

All Uniq based operating systems contain a massively powerful command line interface that can let you do a lot of really cool things that you may not have realized. If you are looking for a piece of text in a huge directory of files, there is no need to go through each file and check. You can run a very simple command that will perform the search for you.

The following code will allow you to find a string inside a directory of files using any Linux/Unix based operating system using the Grep command. To make this command work correctly, make sure you are inside the directory that you wish to search.

If you wish to perform this command on a different directory that you are not currently inside, use the following command.

This will search for all files that contain ‘mystring’ inside the /var/myfolder directory. The -r argument will make this recursive so that it will also search all subdirectories. If you just want to search the top level directory, remove this -r command.

If you are using the sortable feature of the jQuery library, you will likely want a way to get the order of the elements. You can do this very easily using one of the built in events. The following code will obtain the element order for a sortable div and output the data to the console.

The output will be a simple numeric array e.g. [1,2]. You can loop over this array and do what you need to do. You can also save these to a comma delimited string if you need to submit the order of a sortable list through a form.

This tutorial will guide you through the steps required to get Node.js and Angular 2.0 setup installed on your windows system in order to begin development with Angular 2.0 web applications. The setup is fairly simple, so there shouldn’t be too much room for things to go wrong. This is what you need to do to setup node.js and angular 2.0 for development on windows. For setup on Linux, the process is quite similar, but the commands will differ.

Install Node.js and NPM

You can download this from the official node.js website. It is a simple installer. Make sure you install the “npm package manager” as part of the node.js install. Click here to download Node.js from the official website. 

Once you have this installed, you should be able to use it right away without needing to restart your PC, but you should test it out first to make sure. Open command prompt and run the following 2 commands to make sure that node.js and npm are correctly installed with the path variables setup.

You now have the means to get started.

Install Typescript for Angular 2.0

Typescript is what is used for Angular 2.0 development. You can install this using npm. Run the following command inside the windows command prompt to install typescript.

And thats is, you now have your system setup to begin developing applications with node.js and Angular 2.0. To make sure everything works, here are some extra steps to setup a simple project.

Creating a Test Project

You should try keep all of your development under 1 main directory. Make sure that the command prompt is open as an administrator and run the following commands to setup a development area on the C drive.

You now have the directory setup and ready to store a test project. You will now need set this directory up in order to correctly host an Angular2.0 project.

In order to get a project going you need to setup a config file for typescript in the root of the project folder. This needs to be created for each project. You can create it manually each time once you get familiar with what needs to go inside. For now you can run the following command to build it.

Navigate to your testproject directory and you will see that there is now a file in this folder called tsconfig.json. Open this file up and add some additional lines to it. Modify the file so that it contains the following content.

From the command prompt, make sure you are in the same directory as the tsconfig.json file. Once here, run the following command.

You will get some prompts from the window asking you to enter information. The default information will suffice for most of it. Once complete, you will now have a file called package.json inside of the project directory. Open up this file and add some additional data, your file should be structured more like this when you are finished.

From the same project directory as before, run the following command to install all of the project dependencies.

This will take a few minutes to complete, once it finishes you will be ready to add some components to your app.

Create Angular 2.0 Hello World

This part is easy and not so easy. Particularly if you are doing everything manually. Rather than explain it all, there is actually a very good example on the official website that will explain how to get a simple hello world style application setup and running. Click here for the official quick start guide on the angular website. 


Quite often when dealing with an API or some other external service, you will find that you get Unix timestamps returned to you or alternatively have to provide a timestamp in Unix form when sending a request back. Since you are going to be running your .NET code on a windows machine, you don’t have a built in way to get the time in Unix format. It is pretty simple to obtain a Unix timestamp though. Here is what you need to do to convert C# DateTime object to a Unix timestamp.

The following helper method can be used to convert a standard datetime object into a Unix timestamp value. The value is quite large and will get bigger as time goes on, so make sure to use an appropriate variable type. Long will work fine for this scenario.

It’s a pretty simple method with little to explain. Its worth noting that you need to keep this as a long. Int is not going to be big enough to hold the time value.

If you want to do things in reverse. I.e. Convert a Unix timestamp back to a C# DateTime object, you can use the following helper method.


Back in the early days of DDOS attacks this would have been a highly dangerous tool. Thankfully it is very easy to block a basic attack like this, so i don’t see the risk of explaining how to use this method. Apache has a tool built into it that will allow you to send a predefined number of requests to a website in order to see if it can handle the load. Here is what you need to do to benchmark a website using Apache.

Apache has a fantastic benchmark tool that you can use to check the performance of your website. If you are expecting a flood of traffic for some particular reason, it would be good to know if your server is capable of handling such a flood. This tool will give you a good idea on whether the server is going to be able to handle the load of traffic.

The format of the command is very simple. You can run it on any server that is using apache. Since most web servers that run apache, will be using some flavor of Linux, i will give you the linux command line method of performing this. The application is called ApacheBench. It may already be installed, but if it isn’t it should be easy to install it.

Once you have it installed you can run a quick test to see how your server handles it. The format of the request is very simple. The first number is the total number of requests you want to send and the second is the amount of requests you want to send at the same time (concurrently). The concurrent value is the most important as this is the one that is most likely to crash the server if it receives too many requests at once. You can play around with the values as you please.

The following command will send a total of 1000 requests to a single URL by grouping them in sets of 100 requests at a time. Make sure to include the “/” at the end of the website path.

If i run the above command against this website I get the following results.