TaskFreak! v0.6.2 – Customizing Status

Background Knowledge


The progress of a task in TaskFreak! is shown as a percentage value and is not exactly visually appealing to quickly spot the progress. With a few minor alterations we can show the percentage completed bar that fills as the task progresses and a gradient bar indicating the progress along with the percentage value.

This solution was posted by Searcher at Re: Taskfreak Customizing Status.

Continue reading

How To – Convert MSSQL Timestamp/Datetime to Unix Timestamp

Background Knowledge


I will explain how to convert a DATETIME (data type) value in Microsoft SQL Server to Unix timestamp and how to convert Unix timestamp to DATETIME. A Unix timestamp is a integer value of seconds since January 1, 1970 at midnight. For further explanation of Unix timestamps refer to Wikiepedia, UnixTimestamp.com or http://unixtimesta.mp/.

Note: This solution only work on dates prior to 2038-01-19 at 3:14:08 AM, where the delta in seconds exceeds the limit of the INT data type (integer is used as the result of DATEDIFF). See source for further details as I have not verified a solution to this problem.

Solutions


Convert Datetime Value to Unix Timestamp (today)

1
SELECT DATEDIFF(s, '19700101', GETDATE());

Result: 1305630800

Convert Datetime Value to Unix Timestamp from two Values

1
SELECT DATEDIFF(s, StartTime, EndTime) AS Duration FROM Programs

Result: 3600

Convert Unix Timestamp Value to Datetime Value

1
SELECT DATEADD(s, 123456789, '19700101');

Result: 1973-11-29 21:33:09.000

Source: How do I convert a SQL Server DATETIME value to a Unix timestamp?
Source: DATEADD (Transact-SQL)
Source: DATEADD
Source: DATEDIFF (Transact-SQL)
Source: DATEDIFF

How to – Turn on Line Numbers in Visual Studio/Express 2010

Background Knowledge


This applies to Microsoft Visual Studio/Express 2010 and as far as I know 2008 as well.

Solution


  1. Go to the menu “Tools” -> “Options”.
  2. In the Options dialog go to “Text Editor” -> “All Languages” or pick a specific language.
  3. On the right hand side under “Display” place a checkmark on “Line Numbers”.
  4. Click on the “OK” button.

Example of a Basic ODBC (MSSQL Server) Query using PHP

An example of a basic ODBC (MSSQL Server/DSN-Less) query using PHP.

Example of Result Set Returning One Row

1
2
3
4
5
6
7
8
9
$szDBConn="DRIVER={SQL Server};SERVER=SQLServerNameHere;DATABASE=DatabaseNameHere";
$szDBUsername="UsernameHere";
$szDBPswd="PasswordHere";
$szDBQuery="SELECT FooBar, Foo_Bar, Foo_ID FROM FoobarSubscribers WHERE FooID=777";
$rDBConnect = odbc_connect($szDBConn, $szDBUsername, $szDBPswd);  
$rDBRes = odbc_exec($rDBConnect, $szDBQuery);
$szLastCheck = odbc_result($rDBRes, "LastCheck");
odbc_free_result($rDBRes);
odbc_close($rDBConnect);

Example of Result Set Returning Multiple Rows in an Object

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$szDBConn="DRIVER={SQL Server};SERVER=SQLServerNameHere;DATABASE=DatabaseNameHere";
$szDBUsername="UsernameHere";
$szDBPswd="PasswordHere";
$szDBQuery="SELECT FooBar, Foo_Bar, Foo_ID FROM FoobarSubscribers";
$rDBConnect = odbc_connect($szDBConn, $szDBUsername, $szDBPswd);  
$rDBRes = odbc_exec($rDBConnect, $szDBQuery);
while($obRows = odbc_fetch_object($rDBRes))
{
	print $obRows->ColumnName1."<br />";
	print $obRows->ColumnName2."<br />";
	print $obRows->ColumnName3."<br />";
}
odbc_free_result($rDBRes);
odbc_close($rDBConnect);

Example of Result Set Returning Multiple Rows in an Array

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$szDBConn="DRIVER={SQL Server};SERVER=SQLServerNameHere;DATABASE=DatabaseNameHere";
$szDBUsername="UsernameHere";
$szDBPswd="PasswordHere";
$szDBQuery="SELECT FooBar, Foo_Bar, Foo_ID FROM FoobarSubscribers";
$rDBConnect = odbc_connect($szDBConn, $szDBUsername, $szDBPswd);  
$rDBRes = odbc_exec($rDBConnect, $szDBQuery);
while($saRows = odbc_fetch_array($rDBRes))
{
        print $saRows['ColumnName1'];
        print $saRows['ColumnName2'];
        print $saRows['ColumnName3'];
}
odbc_free_result($rDBRes);
odbc_close($rDBConnect);

Comments/description of Example

Line #1
Database connection string to define the driver, server host name and database name.
The “server host name” is the server name or IP address of your database server. If your host has multiple instances the “host” value would be formatted like so “foo\bar”. If your using SQL Server Express the “host” name locally would be “.\SQLEXPRESS”.
Line #2-#3
Database login credentilas; username and password.
Line #4
SQL query.
Line #5
Connect to the database defined by Line #1, Line #2 and Line #3.
Line #6
Prepare and execute an SQL statement.
Line #7
Fetch results returned back from the SQL statement. I use a while loop to enumerate through each row of results returned. If you know only one row is going to be returned the while loop is not necessary.
odbc_free_result()
Close database connection.
odbc_close()
Close database connection.

Client-side Image Maps with XHTML 1.1 Strict

I oddly just realized now that Mozilla Firefox is not handling client-side image maps correctly as it should with a DTD of XHTML 1.1 Strict in text/html. I will not go into test cases unless one finds it necessary as everything has been laid out in the two links below. However, why has this not been resolved or is there a proper solution to this matter? I have not been able to find a answers and oddly this issue has been brought up back in 2001. One would think enough time has past.

Any explanation, comments, or help would be greatly appreciated.

Source: Image map handling
Source: Bug 109445 – Referencing a client-side image map declared with id attribute doesn’t work in text/html (usemap)