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,862 other subscribers

Archive for December, 2013

Funny Delphi code of the day: on literals

Posted by jpluimers on 2013/12/09

The fact that the [WayBack] 31-character limit on ClientDataSet field and index names is worse, but I just encountered this GetParamNameWODog function in a Delphi 3rd party library:


function GetParamNameWODog(const ParamName: _string): _string;
begin
if (ParamName <> '') and (ParamName[1] = '@') then
Result := Copy(ParamName, 2, 1000)
else
Result := ParamName;
end;

What’s wrong with using the Length function here?

Yes, SQL Parameter names will probably less than 1000 characters, but then the 1000 literal should be a constant with a meaningful name, and the '@' literal should be too. Read the rest of this entry »

Posted in Delphi, Delphi XE3, Development, QC, Software Development | Tagged: , , | 12 Comments »

“Hoogtes” waar ik gewoond heb / “Altitudes” of where I have been living

Posted by jpluimers on 2013/12/09

(English translation below)

Edit 20230510 – added new URLs after the AHN viewer moved from ahn.geodan.nl to new domains ahn.arcgisonline.nland www.ahn.nl.

Nederlands

Veel van Nederland ligt onder zeeniveau, inclusief de meeste plaatsen waar ik gewoond heb, maar ik wist nog niet hoe ver het van N.A.P. “zeeniveau” afweek.

Via toeval kwam ik er achter dat dit on-line heel makkelijk op postcode opvraagbaar is, met een URL als deze:

http://ahn.geodan.nl/ahn/viewer3/zoekpc.php?postcode=1060NP

https://ahn.arcgisonline.nl/ahnviewer/?find=1060NP

Je krijgt dan een resultaat als dit:

Volgens AHN2 is de gemiddelde hoogte in postcodegebied 1060NP -1.8 m.

(Inmiddels – 2023 – geen tekst meer met gemiddelde hoogte, maar als je klikt op een locatie krijg je de gemeten hoogte aldaar)

Onderaan de postcodes waar het om gaat.

Vrijwel mijn hele leven was dus beneden zeeniveau, maar ik ben boven zeeniveau geboren (:

En als bonus: AHN Viewer en AHN [Wayback/Archive] AHN Viewer | AHN (snapt geen URL parameters) en [Wayback/Archive] AHN-viewer (snapt wel URL parameters, zie [Wayback/Archive] ahn.arcgisonline.nl/ahnviewer/Release_notes_versie_2_februari_2019.pdf).

Er is ook een postcodetool, maar die snapt geen URL parameters: [Wayback/Archive] Postcodetool

English

Most of The Netherlands is below sea level, including most of the places I lived, but I didn’t know how far from N.A.P. “sea level” that was.

By coincidence, I found out that it is easy to find this relative altitude by Dutch poascal code with a URL like this:

http://ahn.geodan.nl/ahn/viewer3/zoekpc.php?postcode=1060NP

https://ahn.arcgisonline.nl/ahnviewer/?find=1060NP

It will get you a result like this, where the last number indicates altitude:

Volgens AHN2 is de gemiddelde hoogte in postcodegebied 1060NP -1.8 m.

(By now – 2023 – no text with average altitude, but if you click you get the measured altitude value)

Below is a list of postal codes where I lived or where my post got delivered.

So I lived most of my life below sea level, but was born above it (:

As a bonus, I also found AHN Viewer and AHN [Wayback/Archive] AHN Viewer | AHN (does not allow URL parameters) and [Wayback/Archive] AHN-viewer (allows URL parameters, see [Wayback/Archive] ahn.arcgisonline.nl/ahnviewer/Release_notes_versie_2_februari_2019.pdf).

There is even a postal code tool, but it does not support URL parameters: [Wayback/Archive] Postcodetool

Postcodes / Postal codes

jeroen

via:

Posted in About, Internet, Personal, Power User | Leave a Comment »

Unix/Linux ln command, I always forget of the left part is the file or link (it is the file)

Posted by jpluimers on 2013/12/06

Like forgetting about the tar syntax, I usually forget which is the left parameter in an ln command (the file or link? it is the file!)

Thanks [WayBackcyberciti.biz:

There are two types of links

  • symbolic links: Refer to a symbolic path indicating the abstract location of another file
  • hard links : Refer to the specific location of physical data.

To create a symbolic link in Unix or Linux, at the shell prompt, enter the following command:

ln -s {target-filename} {symbolic-filename}

–jeroen

via: How to: Linux / UNIX create soft link with ln command.

Posted in *nix, Cygwin, Endian, Linux, Power User, SuSE Linux | 2 Comments »

Owly CI should team up with Ohloh

Posted by jpluimers on 2013/12/05

This was originally scheduled for December 1st at noon and therefore made it to the “Missed Schedule” list as well:

Two interesting sites I found recently:

OwlyCI is like NuGet for Delphi. They add Delphi open source repositories, and provide them as installable packages, and shows build statistics.

Ohloh provides statistics (including build statistics!) for open source repositories (any language and environment)  and shows various other statistics like check in counts, LoC, etc. Koders merged into Oholoh about a year ago.

I think they should team up (:

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

.NET/C#: Some links on validation/guarding/checking

Posted by jpluimers on 2013/12/05

From my link archive:

–jeroen

Posted in .NET, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 3.0, C# 4.0, C# 5.0, Development, Software Development | Leave a Comment »

SQL Server: some links on BULK IMPORT format files

Posted by jpluimers on 2013/12/04

From my link archive:

Note that for importing decimal/numeric columns, you have two options:

  1. Cast through FLOAT using a FORMAT file
  2. Use OpenRowSet with VARCHAR, then CAST afterwards
    Weird rounding for decimal while doing a bulk insert from a CSV.

Some more links on this:

–jeroen

Posted in Algorithms, CSV, Database Development, Development, Floating point handling, Software Development, SQL Server, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012 | Leave a Comment »

Windows Development: Switching JIT debuggers (via: Stack Overflow)

Posted by jpluimers on 2013/12/03

StackOverflow user User Sertac Akyuz posted a small Delphi snippet showing how to switch the Windows JIT debugger.

I’ll need to complete it somewhere, but since the concept is interesting, here is his answer:

Write a simple application that would launch the debugger you want in case of an application crash.

Register your app in

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug

In case of an 64bit OS, also to the following key

HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug

add/modify the string named Debugger with value:

"C:..\Win32\Debug\Project1.exe" %ld %ld

A very simple application:

procedure TForm1.FormCreate(Sender: TObject);
begin
  ComboBox1.Items.Add('BDS 16');
  ComboBox1.Items.Add('BDS 15');
  ComboBox1.Items.Add('WinDbg');
  ComboBox1.Items.Add('VS');
  // etc..
  ComboBox1.ItemIndex := 0;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  proc: THandle;
begin
  Assert(ParamCount >= 2);
  proc := OpenProcess(SYNCHRONIZE, False, StrToInt(ParamStr(1)));
  case ComboBox1.ItemIndex of
    0: ShellExecute(0, '', 'C:\..\RAD Studio\9.0\bin\bds.exe',
          PChar(Format('/attach:%s;%s', [ParamStr(1), ParamStr(2)])), '',
          SW_SHOWNORMAL);
    1 : // etc..
    2: ShellExecute(0, '', 'C:\Program Files (x86)\..\windbg.exe',
          PChar(Format('-p %s -e %s -g', [ParamStr(1), ParamStr(2)])), '',
          SW_SHOWNORMAL);
    3: ShellExecute(0, '', 'C:\Windows\system32\VSJitDebugger.exe',
          PChar(Format('-p %s -e %s', [ParamStr(1), ParamStr(2)])), '',
          SW_SHOWNORMAL);
    //..
  end;
  if Bool(proc) then begin
    WaitForSingleObject(proc, INFINITE);
    Application.Terminate;
  end;
end;

–jeroen

via: windows – Switching JIT debuggers? – Stack Overflow.

Posted in .NET, Delphi, Development, Software Development, Visual Studio and tools | Leave a Comment »

Garmin Forerunner 305 GPS – Mac data analysis and blogging | Jon Worth

Posted by jpluimers on 2013/12/02

Indeed, the TrailRunner software is much nicer than the Garmin stuff. It needs the Garmin stuff (in order to download the data from the ForeRunner), and for that you need to have a good quality USB cable, otherwise the Forerunner will charge, but not transfer data).

So if you have a Mac, download TrailRunner – Mac OS X route planning and journaling for iPhone, Nike+ SportBand, Garmin ForeRunner GPS.

–jeroen

via: Garmin Forerunner 305 GPS – Mac data analysis and blogging | Jon Worth.

Posted in Apple, Mac, Mac OS X / OS X / MacOS, Mac OS X 10.4 Tiger, Mac OS X 10.5 Leopard, Mac OS X 10.6 Snow Leopard, Mac OS X 10.7 Lion, MacBook, MacBook-Air, MacBook-Pro, OS X 10.8 Mountain Lion, Power User | Leave a Comment »