Monday, December 8, 2014

Format date and time using Moment.js

The javascript function below will format a given datetime object like facebook ish using momentjs.

function formatDateTime(dte, format) {
    var diff = moment().diff(moment(dte), 'days');
    if (diff == 0) {
        return moment(dte).fromNow();
    }
    else if (diff == 1) {
        return moment(dte).calendar();
    }
    else {
        if (format) {
            return moment(dte).format(format);
        }
        else {
            return moment(dte).format("MMM DD, YYYY hA");
        }
    }
}

The return value will depend on the datetime pass to the function:

If today
"a few seconds ago" or "13 minutes" ago or "an hour ago"

If yesterday
"Yesterday at 5:15 PM"

If the second parameter is pass it will use it base on momentjs formating

Everything else
Oct 16, 2014 1PM

Tuesday, July 15, 2014

HowTo: Convert a given number into its ordinal value in VB.NET

Found this code from stackoverflow and made some small change to it,  this will convert any given number to its ordinal value.

Example:
Convert(1) will return 1st
Convert(11) will return 11th
Convert(12) will return 12th
Convert(23) will return 23rd

Public Function Convert(ByVal number As Integer) As String
        Dim ones As Integer = number Mod 10
        Dim tens As Integer = Math.Floor(number / 10) / 10
        If (number > 10 And number < 14) Then
            Return number.ToString() & "th"
        Else
            Select Case ones
                Case 1
                    Return number.ToString() & "st"
                Case 2
                    Return number.ToString() & "nd"
                Case 3
                    Return number.ToString() & "rd"
                Case Else
                    Return number.ToString() & "th"
            End Select
        End If
    End Function

Friday, June 27, 2014

Dotnetnuke Messages and Notifications links not working properly

It take me a week to figure this out, had to look into the source code,  In our case the issue occur because we have a custom User Profile page and the Message Center page in not a child of that page.

We just move the messages page under profile page and everything works properly.  Also make sure you clear cache under host settings.

I ask a question about this on DNN Q&A

Tuesday, June 10, 2014

Free Convert VB.NET to C#, developerfusion and teletik Code Converter

I've been using developerfusion.com for a long time to convert the C# code I need to VB.NET and it always work like a charm, but its been crappy lately so I tried the Code Converter provided by telerik and It works perfectly.

Whatever: the objects moment.js makes are not JavaScript dat...

Whatever: the objects moment.js makes are not JavaScript dat...: Cast them back to plain Jane dates like so: var lastHalloween = moment().subtract('year', 1).toDate();

Saturday, May 31, 2014

DotNetNuke and Apache Solr in action



All search functionality of zeekbeek.com is powered by SOLR.

Also we are using jQuery Waypoints for infinite scroll of search results and jQuery BBQ for handing #hash.

Tuesday, May 27, 2014

A problem occurred while trying to set the "References" parameter for the IDE's in-process compiler. Error HRESULT E_FAIL has been returned from a call to a COM component.

I resolve my issue with the help from the workaround here.

In my case it was about adding a reference to itself. Removed it and it is working fine now.

Thursday, May 22, 2014

iCalendar Validator

This iCalendar Format Validator is a big help when it comes validating the content of you iCalendar file (ics)

http://severinghaus.org/projects/icv/