Pages

Copy Text From A Tool Tip

Wednesday, 25 February 2015
Today our QA team asked me if they could copy the text from a tool tip in a table. So I deciced to give it a try in JS fiddle. The hack requires you to use the jQuery UI tooltip. Below is the code.

HTML:
<table border="1px">
    <tr>
        <td class="test" title="Tool Tip 1">Test 1</td>
        <td class="test" title="Tool Tip 2"> Test 2</td>
        <td class="test" title="Tool Tip 3"> Test 3</td>
    </tr>
      <tr>
        <td class="test" title="Tool Tip 4">Test 4</td>
        <td class="test" title="Tool Tip 5"> Test 5</td>
        <td class="test" title="Tool Tip 6"> Test 6</td>
    </tr>
</table>

JavaScript:
$( document ).tooltip({
  items: '.test',
  close: function( event, ui ) {
    ui.tooltip.hover(
        function () {
            $(this).stop(true);
        },
        function () {
            $(this).remove();
        }
    );
  }
});
You can see the JS Fiddle here: http://jsfiddle.net/09yfud1c/1/
Read more ...

.Net Web Services - Json Dates

Wednesday, 14 January 2015
I'm probably not the only one that noticed this but have you ever looked at the dates that the .net json serializer returns dates?

 They look like this: \/Date(1239018869048)\/

I was working with backbone.js and mustache.js templating and needed a clean way to format the ugly dates returned above. I know you can switch the serializer to the json.net one (More details here) but that was not possible due to corporate rules. So I decided just to write a function in my backbone model that would clean it up. Here is a sample if your interested:

The Model:

var sample = Backbone.Model.extend({
    defaults: {
        Date: "",
        Subject: "",
        FormatDate: function () {
            //Format date from asp.net date (ie. /Date(1606953600000)/)
                var formatedDate = new Date(parseInt(this.Date.substr(6)));
                return $.datepicker.formatDate("dd-MM-yy",formatedDate);
            }
        }
});
  Now in the mustache template I can just use the FormatDate function in order to display a readable date like so.

 <td><div>{{ FormatDate }}</div></td>
Read more ...

MsBuild targets and tasks

Tuesday, 18 November 2014

Today I came across something cool that I never new was possible. Customizing your build using targets and tasks.

The reason I came across this is because I needed to copy all the dll's for all of my projects to a single references folder so they can be used by various applications from the same location. In addition to having everything in the same location it will insure that all projects are using the latest version of the dll as the dll will be copied to the references folder on every build.

So if you open up your .csproj file with a text editor you will see an xml file structure. This is where the changes will need to be made. In my case I wanted to copy the dll after the build process so the references folder contained the latest version of the dll.

To do this i needed to override the "AfterBuild" target in my .csproj file. You can find the available targets in the following location:

%WinDir%\Windows\Microsoft.NET\Framework\%VersionNum%\Microsoft.Common.targets

Note: you can also create custom targets if you wish.

Now that I know what target i need to override I needed to find the task I was going to use within the target. You can find a list of tasks in the following location:

%WinDir%\Windows\Microsoft.NET\Framework\%VersionNum%\Microsoft.Common.Tasks

Below is a table of commonly used tasks:

TaskDescription
CreateItemCreates items. Since items are evaluated at the beginning of the build, if you need files generated by your build included in an item then you must use this task. If the item that is being created already exists then it will be appended.
CreatePropertyCreates a property. Properties are evaluated at the beginning of the build (except those created by CreateProperty). If the property that is being created exists, it will be overwritten.
CopyCopies files from one location to another.
DeleteDeletes files.
ErrorNotifies MSBuild that an error has occurred. Usually this is used with a Condition attribute that means something went wrong.
ExecInvokes an executable file.
MessagePasses a message to the MSBuild logger.
MSBuildInvokes MSBuild on another project file. You can also use the Exec task to start Msbuild.exe, but the MSBuild task has advantages such as getting the output of executed targets.
Referenced from http://msdn.microsoft.com/en-us/magazine/cc163589.aspx


I needed to copy the references from one folder to another so in my .csproj i added the following in order to complete my task.
     
    
     
   


That's it!
Read more ...

Computer Science?!?!

Wednesday, 26 September 2012
Today i came across this article in MSDN Magazine and thought i would share it with you all. It is an article that gives us programmers some insight on how computer science can help us become better and more efficient our programmers.

Read more ...