The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,861 other subscribers

Archive for 2011

Restarting InterBase from the command-line on Windows and Mac

Posted by jpluimers on 2011/12/08

I recently wrote this script for like the upteenth time, so now it is on bo.codeplex.com and in my BIN directory on Windows and in my sh directory on my Mac.

Note for the scripts in this post:

Windows

restart-InterBase.cmd:

net stop IBG_gds_db
net stop IBS_gds_db
net start IBG_gds_db
net start IBS_gds_db

It restarts only the default instance.

Usually it is enough to restart the Guarduan (IBG_gds_db), but sometimes that hangs, so I restart both the Guardian and the DB service (IBS_gds_db).

You can do the same with Firebird of course, and adapt for non-default instances: just find the right service names using a script like this:

sc query

then search the output for entries matching InterBase or Firebird like these:

SERVICE_NAME: IBG_gds_db
DISPLAY_NAME: InterBase XE Guardian gds_db
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 4  RUNNING
                                (STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

SERVICE_NAME: IBS_gds_db
DISPLAY_NAME: InterBase XE Server gds_db
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 4  RUNNING
                                (STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

Mac OS X

You can find the name of your Interbase service when you look at the user-installed services:

bash-3.2$ cd /Library/StartupItems/InterBase_gds_db/
bash-3.2$ ls -l
total 16
-rwxr-xr-x  1 root  wheel  636 Oct 21 15:44 InterBase_gds_db
-rwxr-xr-x  1 root  wheel  204 Sep 14  2007 StartupParameters.plist
bash-3.2$ cat StartupParameters.plist
{
  Description     = "InterBase Server";
  Provides        = ("InterBase Database Server");
  Requires        = ("DirectoryServices");
  Uses            = ("Disks", "NFS");
  OrderPreference = "None";
}
bash-3.2$

You can restart the InterBase Database Server using this command:

sudo SystemStarter -vdD restart "InterBase Database Server"

The SystemStarter -vdD parameters make the output add verbose, debugging information and dependencies.
–jeroen

Posted in Database Development, Development, InterBase | Leave a Comment »

Trouble with Google Reader and GEXperts RSS feed :)

Posted by jpluimers on 2011/12/07

While catching up my feeds after an astonishing holiday around the Antarctic Peninsula (some photos at Flickr), I bumped into a Google Reader issue with the GExperts.com RSS feed: all posts seem to be stamped 20111117T0555.

Funny, as I remember being late to report GExperts 1.35 for Delphi XE2 was released a while a go :)

It reminded me to ask Thomas to publish the XE2 version of his Experimental GExperts build though.

Lets hope he is faster than me catching up :)

--jeroen

via: Google Reader feed for GExperts.org.

Posted in About, Antarctic, Delphi, Development, Personal, Software Development, Travel | 7 Comments »

SQL Server inverse of (equals) is ((not equals) or (is NULL)

Posted by jpluimers on 2011/12/07

Usually getting queries right with SQL Server comes down to handling NULL correctly.

For instance, on this table:

MYTABLE
ID LAST_NAME
6 COUNT(*)
1 FOO
2 BAR
3 FOO
4 **NULL**
5 BAR
6 FOO

What are the results of these SELECT statements

SELECT COUNT (*)
FROM MYTABLE

SELECT COUNT (*)
FROM MYTABLE
WHERE     (LAST_NAME = 'FOO')

SELECT COUNT (*)
FROM MYTABLE
WHERE     (LAST_NAME <> 'FOO')

SELECT COUNT (*)
FROM MYTABLE
WHERE     NOT (LAST_NAME = 'FOO')

You might think they are like these, as LASTNAME <> ‘FOO’ looks like the inverse of LASTNAME = ‘FOO’:

  • 6
  • 3
  • 3
  • 3

But in fact the results are these:

  • 6
  • 3
  • 2
  • 2

When you look closely to the SQL statements below, you will see that the inverse of EQUALS contains an IS NULL, the same for the inverse of NOT EQUALS:

SELECT COUNT (*)
FROM MYTABLE

-- inverse of NOT EQUALS
SELECT COUNT (*)
FROM MYTABLE
WHERE     (LAST_NAME = 'FOO') OR (LAST_NAME IS NULL)

SELECT COUNT (*)
FROM MYTABLE
WHERE     (LAST_NAME <> 'FOO')

SELECT COUNT (*)
FROM MYTABLE
WHERE     (LAST_NAME = 'FOO')

-- inverse of EQUALS
SELECT COUNT (*)
FROM MYTABLE
WHERE     (LAST_NAME <> 'FOO') OR (LAST_NAME IS NULL)

-- inverse of EQUALS
SELECT COUNT (*)
FROM MYTABLE
WHERE     (NOT (LAST_NAME = 'FOO')) OR (LAST_NAME IS NULL)
  • 6
  • 4
  • 2
  • 3
  • 3
  • 3

Lesson learned: always take into account NULL when trying to formulate your SQL comparisons well.

–jeroen

Posted in Database Development, Development, SQL Server, SQL Server 2000, SQL Server 2008 | Leave a Comment »

When writing applications, include Keyboard Shortcuts for both the CUA and Windows/Apple shortcuts

Posted by jpluimers on 2011/12/06

When you write applications, it is important to include both the CUA and the Windows/Apple keyboard shortcuts, and get the tab order of keyboard accessible user elements right.

Many modern applications seem to put less and less emphasis on the most efficient user input device: the keyboard.

You should: it makes your application much more pleasant to use.

I wrote about CUA before, but the Windows and Mac shortcuts are just as important.

A small table (please post a comment if you know additions):

Keyboard Shortcuts for the most common tasks.
Function CUA Windows Mac
Copy Ctrl + Insert Ctrl + C Command + C
Cut Shift + Delete Ctrl + X Command + X
Paste Shift + Insert Ctrl + V Command + V
Delete before cursor Backspace Delete
Delete after cursor Delete Fn + Delete
Undo Alt + Backspace Ctrl + Z Command + Z
Redo Ctrl + Y Command + Y
Confirm the current task Enter Return
Cancel the current task Escape Escape
Next field Tab Tab
Previous field Shift + Tab Shift + Tab
Next pane Ctrl + F6
Previous pane Alt + F6
Next window F6  Cmd + `
Previous window Shift + F6
Application menu Alt + Space
Windows menu
Local menu Shift + F10 Local Menu

Note that many Linux programs follow both the CUA and Windows settings.

References:

–jeroen

Posted in .NET, Delphi, Development, Keyboards and Keyboard Shortcuts, Power User, Software Development, xCode/Mac/iPad/iPhone/iOS/cocoa | Leave a Comment »

xkcd: Citogenesis – how citations get to life, and survive

Posted by jpluimers on 2011/12/05

No need to say more:

–jeroen

Via: xkcd: Citogenesis.

Posted in Opinions | Leave a Comment »

Source Code Pretty Printing in various languages

Posted by jpluimers on 2011/12/05

Totally forgot about this: YAPP – yet another pretty printer.

–jeroen

via: delphi – Save source code with formatting syntax highlight – Stack Overflow.

Posted in .NET, C#, Development, Prism, Software Development | Leave a Comment »

Cool tool of the day: Tasker for Android

Posted by jpluimers on 2011/12/02

Quote:

Tasker for Android is an application which performs Tasks (sets of Actions) based on Contexts (application, time, date, location, event, gesture) in user-defined Profiles, or in clickable or timer home screen widgets.

This simple concept profoundly extends your control of your Android device and it’s capabilities, without the need for ‘root’ or a special home screen.

Highly recommended, for instance to wake up your phone in an emergency.

–jeroen

Posted in Android Devices, LifeHacker, Power User | Leave a Comment »

File Extensions of Files Generated by RAD Studio – RAD Studio XE2

Posted by jpluimers on 2011/12/01

With Delphi 1, it was easy to choose what to put in your version control systems: basically .pas, .dfm, .dpr, .inc, .res, .cfg and you were set.

Now there are many more extensions involved, so it is harder to choose what to put in your version control system and what not.

The File Extensions of Files Generated by RAD Studio page helps you with that: it lists most of the Delphi file extensions (.local is a noticeable exception) that are used today.

–jeroen

via: File Extensions of Files Generated by RAD Studio – RAD Studio XE2.

Posted in Delphi, Development, Software Development | 4 Comments »

Duh moment: in C#, the integer zero (0) is compatible with all enums

Posted by jpluimers on 2011/11/30

Even if you have used something for over a decade, you can learn about it :)

I was refactoring bits of code where someone clearly didn’t understand the benefits of enumerations, similar to this very contrived example:

using System;

namespace Demo
{
    // explicit equivalence of: 
    // public enum TrafficLight { Red, Yellow, Green };
    public enum TrafficLight { Red = 0, Yellow = 1, Green = 2 };

    public class Program
    {
        public static void Main()
        {
            // old code:
            Console.WriteLine(IntIsRedTrafficLight((int)TrafficLight.Red));
            Console.WriteLine(IntIsRedTrafficLight((int)TrafficLight.Yellow));
            Console.WriteLine(IntIsRedTrafficLight((int)TrafficLight.Green));
        }

        public static bool IntIsRedTrafficLight(int trafficLight)
        {
            return (trafficLight == (int)TrafficLight.Red);
        }
    }
}

The code was using way too many casts, and my goal was something as simple as this: Read the rest of this entry »

Posted in .NET, C#, Development, Software Development | Leave a Comment »

yyyy-mm-dd for vba – Parse data and time string to Access Date value – Stack Overflow

Posted by jpluimers on 2011/11/29

A co worker at a client had trouble importing textual date strings into Microsoft access.

Since many databases like yyyy-mm-dd as a universal import date format, I suggested trying that and searching for some backing on the Internet.

Indeed this StackOverflow answer confirmed my gues.

–jeroen

Via: vba – Parse data and time string to Access Date value – Stack Overflow.

Posted in Access, Database Development, Development, Software Development | Leave a Comment »