Riaan Lehmkuhl's Blog

Subversion, Progamming, Tips & Tricks and whatever else springs to mind.
13Jul

Add Google Talk Online Presence to Web Pages

13 July 2008 00:08 by Riaan Lehmkuhl
If you use Google Talk instant messenger and would like to stay connected with visitors on your website, the Google Talk chatback badge is a cool way to display to them when you are online and available to chat / IM with them.

Just point your browser to http://www.google.com/talk/service/badge/New, and follow the easy instructions.

Currently rated 3.0 by 5 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
11Jul

Unable to run Proclarity Web Professional

11 July 2008 00:05 by Riaan Lehmkuhl

A while after installing and configuring Proclarity 6.3 the users started receiving a blank page when accessing Proclarity Web Professional:

Click to see larger image 

After some searching I found this post: http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=2901084&SiteID=17. There is a bug in Proclarity, for which MS has released a hotfix: http://support.microsoft.com/kb/946719.

Downloaded an installed the hotfix just to find a brand new error:

Unable to run Proclarity Professional. Either the required components are not installed or you don't have permission to download them.

 

Click to see larger image 

The user is a member of the Administrator so permissions shouldn't be an issue. The search continues…

I found a new hotfix rollup package released after the one I had installed: http://support.microsoft.com/kb/953604. But after installing it, the problem was still there!

Back to Google…

I tried everything suggested in this post about the subject: http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=2396186&SiteID=17

  • Give users professional access in the ProClarity Administration Tool (Analytics Server Administration Tool).
  • Select the components folder in the admin tool, right click the web professional and choose properties. Make sure the box "required component" is selected.
  • Made sure no pop-up blockers are enabled.

Oops! Still the same error.

To my surprise, it worked when I ran Web Professional from the server. This meant that Proclarity is working but that there has to be a problem with the user access.

Time to fool around... In the Analytics Server Administration Tool, I added a new user Role, ProclarityWebUsers, and added the required users to it. Then on the Publishing tab of the role properties I clicked on Allow All.

Click to see larger image 

And the same on the Access Rights tab.

Click to see larger image 

Returned to Proclarity Web Professional and another big surprise… It worked!

 Click to see larger image

If you are experiencing the same issues, I hope this helps. I'm not a Proclarity guru and have no idea which of these steps are the actual ones to solve the problem.

Happy analytics!

Currently rated 3.0 by 5 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
19Jun

Adding an Ordinal column using a sub query

19 June 2008 23:10 by Riaan Lehmkuhl
This is just a simple way of adding an ordinal column to a SQL result using a sub query. This method depends on the Primary Key field of the table. I used the Northwind database for this example.
The idea is to select the Products with an ordinal numbered column...
Ordinal ProductID ProductName CategoryID
1 11 Queso Cabrales 4
2 12 Queso Manchego La Pastora 4
3 31 Gorgonzola Telino 4
4 32 Mascarpone Fabioli 4
5 33 Geitost 4

To do this I've created the following stored procedure with the CategoryID is an optional parameter:
CREATE PROCEDURE [dbo].[sp_SelectProducts]
(
@CategoryID INT = NULL
)
AS
DECLARE @sql NVARCHAR(4000)
SET @sql = N'
SELECT top 5 (SELECT COUNT(*) 
FROM Products p 
WHERE p.ProductID <= Products.ProductID '
IF (@CategoryID IS NOT NULL) BEGIN
SET @sql = @sql + N' AND p.CategoryID = Products.CategoryID '
END
SET @sql = @sql + N') AS Ordinal,
ProductID,
ProductName,
CategoryID,
QuantityPerUnit,
UnitPrice,
UnitsInStock,
UnitsOnOrder,
ReorderLevel
FROM Products
WHERE Discontinued != 1'
IF (@CategoryID IS NOT NULL) BEGIN
SET @sql = @sql + N' AND CategoryID = ' + CAST(@CategoryID AS NVARCHAR)
END
EXEC sp_executesql @sql;
For each product that is returned we get it's ordinal position by counting the ProductIDs already returned and it self.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
12Jun

Microsoft Excel - How to check if a value exists in a range

12 June 2008 23:04 by Riaan Lehmkuhl
I had to compare some simple lists. I could have used a database, loaded the lists and used sql to do the comparisons. Not in the mood for that, then let's just use Excel.
We have the following two lists in a spreadsheet and we want to know which of the values in column B exists in column A:
  A B C
1 Fusce Vestibulum  
2 mauris mattis  
3 nulla Fusce  
4 pellentesque consequat  
5 iaculis libero  
6 aliquam eu  
7 eu sem  
8 tincidunt Nullam  
9 consequat iaculis  
10 metus elit  


After some digging around in the Excel functions, I found VLOOKUP that does the trick:
  A B C
1 Fusce
Vestibulum
=VLOOKUP(B1,$A$1:$A$10,1,FALSE)
2 mauris mattis #N/A
3 nulla Fusce Fusce
4 pellentesque consequat consequat
5 iaculis libero #N/A
6 aliquam eu eu
7 eu sem #N/A
8 tincidunt Nullam #N/A
9 consequat iaculis iaculis
10 metus elit #N/A


In column C it prints the search value if it was found, or "#N/A" if not found. This is ok, but we can make it look a bit nicer by adapting the formula a little bit:
  A B C
1 Fusce
Vestibulum
=ISNA(VLOOKUP(B1,$A$1:$A$10,1,FALSE)=B1)=FALSE
2 mauris mattis FALSE
3 nulla Fusce TRUE
4 pellentesque consequat TRUE
5 iaculis libero FALSE
6 aliquam eu TRUE
7 eu sem FALSE
8 tincidunt Nullam FALSE
9 consequat iaculis TRUE
10 metus elit FALSE


Using the updated formula, "TRUE" is printed if the value in column B is the same as the value returned from VLOOKUP otherwise "#N/A" is returned. This in turn is handled by the ISNA function, that's return value is then inverted so that the "TRUE" for "#N/A" is displayed as "FALSE" (the value was not found).

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
12Jun

Simple lamda expression example in C#

12 June 2008 22:58 by Riaan Lehmkuhl
A friend asked me for an example of a lamda expression, and after going through my code and searching the net, I discovered this little gold nugget:
A lambda expression is a way of creating a function without giving it a name.
Suppose you defined: bool blah(n) { return n%2 == 1; } That's a function named blah. (n => n%2 == 1) int[] numbers = {5,4,1,3,9,8,6,7,2,0 }; int oddNumbers = numbers.Count(n => n % 2 == 1); "numbers" is the sequence. It's an array, implementing IEnumerable<int>.
If you just call numbers.Count() you'll get 10. The version with the lambda expression is saying "only count elements which match this predicate".
It's sort of similar to calling: numbers.Where(n => n % 2 == 1).Count();
Reference:
http://www.eggheadcafe.com/software/aspnet/31850595/confused-about-the-lamda.aspx

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
11Jun

The UNIX date command and Date manipulation

11 June 2008 22:44 by Riaan Lehmkuhl
You need to do something on a daily with a file in a directory named yyyy-mm-dd.txt (year-month-day.txt).
That's easy enough:
#!/bin/ksh
# just get the current date
today="`date +%Y-%m-%d`"
filename="${today}.txt"
echo $filename
Oops, you need the file from yesterday. Not so simple any more as the unix date command just sets or prints the date.
Let's do some of the usual date math (month ends, leap years, etc.).
#!/bin/ksh
# default is one to travel back in time to yesterday
daystogoback="1" 
# to be a little dynamic, we can use an argument to go back n days.
if [ $# -eq "1" ]; then
   daystogoback="$1"
fi
# get the current year month and day
nowy=`date +%Y`
nowm=`date +%m`
nowd=`date +%d`
# get rid of the month's possible leading zero
nowm=`echo $nowm*1|bc`
# if today's day is greater than the number of days to go back
# we really can just take the shortcut and subtract the days to go back
# because we will stay in the current month and nothing fancy is needed
if test $nowd -gt $daystogoback
then
        nowd=`echo $nowd-$daystogoback|bc`
else
# if we are in January, we have to go to the previous year 
# and set the month to December
# else we can just subtract the month
        if test $nowm -eq "1"
        then
                nowy=`echo $nowy-1|bc`
                nowm="12"
        else
                nowm=`echo $nowm-1|bc`
        fi
# now we can calculate the day, but first we have to see
# how many days in the month...
# we default to 31 and do nothing more for the months with 31 days
# we have to check for February and then for a leap year (28/29)
# the rest of the months will have 30 days
        newd="31"
        case "$nowm" in
                "1") ;;
                "3") ;;
                "5") ;;
                "7") ;;
                "8") ;;
                "10") ;;
                "12") ;;
                "2")    if test "0" -eq "`echo $nowy%4|bc`"
                                then
                                        newd="29"
                                else
                                        newd="28"
                                fi ;;
                *) newd="30" ;;
        esac
# subtract the current day from the days to go back 
# and then from the total days in the month
        nowd="`echo $daystogoback-$nowd|bc`"
        nowd="`echo $newd-$nowd|bc`"
fi
# now we just do some formatting for the month and day
if test $nowm -lt "10"
then
        nowm="0$nowm";
fi
if test $nowd -lt "10"
then
        nowd="0$nowd";
fi
# our new date
filedate="$nowy-$nowm-$nowd"
# and the file we need to access...
filename="${filedate}.txt"
echo $filename
Always fun playing with dates.

References:
KSH script BASICS
Wikipedia: Korn shell

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
26Mar

View running 4GL SQL queries

26 March 2008 22:39 by Riaan Lehmkuhl
It has been a while since i have had to work with Informix / 4GL. I have already forgotten tha simple commands to view the current running SQL query with an executing 4GL script. So this is more of a note to myself, but if it helps you, I'll be overjoyed.
First find the correct process:
> ps -ef | grep glgo root 7618 7368 63 22:58:19 pts/ta 0:21 fglgo the_4gl_name_here
Then get the correct session using the pid from the previous result:
> onstat -g ses | grep 7618 1644203 root ta 7618 myserver 1 200704 187952 off
Now get the current executing sql of the session id above:
> onstat -g sql 1644203
If you would like the display to be automatically refreshed, just add a 'r' switch:
> onstat -gr sql 1644203
I hope I will remember to come and look for this next time I need it in a few months time.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
09Jan

Accessing fields in the BindingSource.Current property

09 January 2008 22:18 by Riaan Lehmkuhl

I was using the Current property of a BindingSource object in VB.Net for sometime now using inplicit conversions to access fields:

MyBindingSource.Current(0) = someValue While in C# we need to explicitly cast the Current property to some type and use that. I tried using typeof(...) and got this peculiar result...
typeof(MyBindingSource.Current) 'Myproject.Form1.MyBindingSource' is a 'field' but is used like a 'type'

Then I tried .ToSting(), and this had a more promising result...
MyBindingSource.Current.ToString() "System.Data.DataRowView"

So, if you want to access a field in a BindingSource:
DataRowView drv = MyBindingSource.Current as DataRowView; drv[0] = someValue; //or assignment (if the field's type is an int) int someValue = Convert.ToInt32(drv[0]);
Hope i save someone five minutes.

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
04Jan

Windows.Forms Binding errors with .Net 2.0 (Part 3)

04 January 2008 22:13 by Riaan Lehmkuhl
On to the next hurdle (sigh).

The problem:
In a DataGridView, when deleting the last remaining data row, the UserDeletedRow event does not fire.

The solution:
To work around this we need to add some logic to the UserDeletingRow event handler to count the number of rows and call the event handler when necessary... private void DataGridView1_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) {    if (DataGridView1.RowCount == (DataGridView1.AllowUserToAddRows ? 2 : 1))       DataGridView1_UserDeletedRow(DataGridView1, new DataGridViewRowEventArgs(e.Row)); } private void DataGridView1_UserDeletedRow(object sender, DataGridViewRowEventArgs e) {    // do something here... }

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
03Jan

Windows.Forms Binding errors with .Net 2.0 (Part 2)

03 January 2008 22:05 by Riaan Lehmkuhl
Hi, this is number two of my Binding error series.

I've got a BindingSource setup with the Sort property set to a valid column name and all works well, (dejavu) but the problem is when the form closes, and starts Disposing controls, I get this message:
"Sort string contains a property that is not in the IBindingList."

The solution is almost the same as in Part 1, but this time we want to clear the Sort property of all BindingSources on the form...
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) {    try {       if (disposing && (null != components)) {          foreach (System.ComponentModel.IComponent comp in components.Components) {             if (comp is System.Windows.Forms.BindingSource)                (comp as System.Windows.Forms.BindingSource).Sort = null;          }          components.Dispose();       }    } finally {       base.Dispose(disposing);    } }

Notice the bit where we loop through the components to be disposed of. Now Isn't this fun!

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Riaan Lehmkuhl


Me, a disorder of the brain that results in a disruption in a person's thinking, mood, and ability to relate to others.

Recent comments

Comment RSS

Thingies

Calendar And Month List

<<  September 2010  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar

Disclaimer & Privacy

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Privacy:
We use third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.

Most comments

Cool Quote

I know that you believe that you understood what you think I said, but I am not sure you realize that what you heard is not what I meant. - Robert McCloskey