Search

Tutorials, tips&tricks, snippets..

#KISS: KEEP IT SIMPLE, STUPID!

Create a class from XSD file (and avoid signature error)

It happens to have a XSD file, for example to communicate with an exisisting web service.
I have to create a class (in this case, C# language) starting from a XSD file provived from server side. How to do it?

Continue reading “Create a class from XSD file (and avoid signature error)”

Advertisements

How to create a WCF from WSDL (and prevent errors)

Sometimes you need to create a WCF service starting from a WSDL giving to you the specifications. It is a good practice and quite simple to do.

Continue reading “How to create a WCF from WSDL (and prevent errors)”

SQL Server: check log size

To see how much MB your SQL Server log is, just run this query:

DBCC SQLPERF(logspace)

Traceroute an IP and list the hops using C#

This code snippet perfoms traceroute (“tracert command”) an IP and allow you to know all the hops with some infos, like hostname, reply time address and other stuff.

Below the code.
Continue reading “Traceroute an IP and list the hops using C#”

C#: right pad an array

Here there is a code snippet showing how to right pad an array (in this case, a byte array).

public static byte[] ByteArrayLeftPad(byte[] input, byte padValue, int len)
{
    var temp = Enumerable.Repeat(padValue, len).ToArray();
    for (var i = 0; i < input.Length; i++)
        temp[i] = input[i];
}

Here you can find how to left pad an array.

Wait Until A Condition Is True (and not stuck the CPU!!)

Sometimes the need arises to wait for a condition or property to become true, this is especially useful for unit / integration tests. The System.Threading namespace contains SpinWait which will enable use to enter a condition that we want to wait on to see if it becomes true.

Continue reading “Wait Until A Condition Is True (and not stuck the CPU!!)”

HOWTO: close the TCP connection of other process calling Windows API

We know that TCPview, for example, can close the TCP connection for the other process without closing the process. So how to implement it? Suppose there is a process connecting to the a remote ip and port, how to terminate that connection?

Continue reading “HOWTO: close the TCP connection of other process calling Windows API”

MySQL: import/export single table

Here how import/export single table using MySQL as DBMS:

Exporting the Table
To export the table run the following command from the command line:

mysqldump -p --user=username dbname tableName > tableName.sql

This will export the tableName to the file tableName.sql.

Importing the Table
To import the table run the following command from the command line:

mysql -u username -p -D dbname < tableName.sql

The path to the tableName.sql needs to be prepended with the absolute path to that file. At this point the table will be imported into the DB.

Fast and useful hint to analyze your disk usage

Just click here and discover the power of WinDirStat. If you have a full disk to clean up, this will be your savior.

Powered by WordPress.com.

Up ↑