Skip to content

Month: October 2013

WordPress – Time To First Byte Slow – IIS

I had a problem with a WordPress website that I recently moved to a new server running PHP 5.4 and IIS. I found that the fix to my problem was in the wp-config.php file. I had to change the hostname of the MySQL db from localhost to Maybe this is an issue with IPv6 being enabled on the server. I’ll try and look at that later.


/** MySQL hostname */
define('DB_HOST', 'localhost');


/** MySQL hostname */
define('DB_HOST', '');


CentOS 6 – Change System Language

I recently bought a server whose language was set to something other than English. Here is the way to change the language.

Run the following commands

 nano /etc/sysconfig/i18n

and replace with the following


Log out and log back in. You should see the change.

C# List to DataTable

Don’t recall where I found this but converts List to DataTable.

public static System.Data.DataTable ToDataTable<T>(this IList<T> data)
            System.ComponentModel.PropertyDescriptorCollection props = System.ComponentModel.TypeDescriptor.GetProperties(typeof(T));
            System.Data.DataTable table = new System.Data.DataTable();
            for (int i = 0; i < props.Count; i++)
                System.ComponentModel.PropertyDescriptor prop = props[i];
                //table.Columns.Add(prop.Name, prop.PropertyType);
            object[] values = new object[props.Count];
            foreach (T item in data)
                for (int i = 0; i < values.Length; i++)
                    values[i] = props[i].GetValue(item);
            return table;


Using C# to check if string contains a string in string array

Pieced this together from stackoverflow…

string stringToCheck = "text1";
string[] stringArray = { "text1", "testtest", "test1test2", "test2text1" };

This checks if stringToCheck contains any one of substrings from stringArray.


If you want to ensure that it contains all the substrings, change Any to All:

if(stringArray.All(s => stringToCheck.Contains(s)))