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 4,262 other subscribers

Archive for July 18th, 2018

Pretty printing HTML is the same as formatting code: How do you format code in Visual Studio Code (VSCode) – Stack Overflow

Posted by jpluimers on 2018/07/18

I was looking for a HTML pretty printer (…) but in Visual Studio code, that is called code formatting, which supports many languages out of the box (including HTML) without requiring extensions like Atom.io (see below).

The shortcuts are at [WayBack] How do you format code in Visual Studio Code (VSCode) – Stack Overflow.

For Mac OS X/OS X/MacOS they are (the second one only appears when you have a code selection):

  • document: ShiftOptionF
  • selection: CommandK CommandF

Read the rest of this entry »

Posted in Development, Software Development, Visual Studio and tools, vscode Visual Studio Code | Leave a Comment »

ColorButton unit with TColorButton saved for posterity as http://delphi.about.com got hi-jacked.

Posted by jpluimers on 2018/07/18

Hopefully my blog will last longer than the original delphi.about.org articles.

Last year, I noticed yet another path into bit rot: [WayBack] The title reads “Source Code for the TColorButton Delphi Component”… I must be going blind because I can’t find it – Thomas Mueller (dummzeuch) – Google+

In this case, http://delphi.about.com/library/weekly/aa061104a.htm got redirected via http://delphi.about.com/od/vclusing/fl/Source-Code-for-the-TColorButton-Delphi-Component.htm to [WayBackhttps://www.thoughtco.com/source-code-for-tcolorbutton-4077901 which is a copy of the original article failing to preserve the download links of the original source code.

It doesn’t help that the original source download at http://delphi.about.com/library/code/ncaa061104a.htm also redirects to https://www.thoughtco.com/delphi-programming-4133475 a generic catch all of [WayBackDelphi Programming where http://delphi.about.com also redirects to.

In other words:

http://delphi.about.com got hi-jacked.

So here are some links to various forms of that source code:

–jeroen

Posted in Color (software development), Delphi, Development, Software Development | 2 Comments »

Firebird: the way you compare dates highly influences fetch times

Posted by jpluimers on 2018/07/18

I was amazed the influence on how you compare dates would be a factor 1000 change in fetch times even though I wrote about date, time and timestamp conversions before in Source: Firebird – adjusting Delphi stored TDateTime (or OLE Automation date) fields that contain Dates, Times or DateTimes.

All queries were ran at 20170410.

Slow

select id, date '1899-12-30' + data.datadate as datestamp
from   data
where  1=1
-- slow: prepared 0.066 sec; fetched 10.549 sec 250 rows
    and date '1899-12-30' + data.datadate >= '2017-04-08' -- last 2 days
    and date '1899-12-30' + data.datadate <= '2017-04-10' -- today

Fast

select id, date '1899-12-30' + data.datadate as datestamp
from   data
where  1=1
-- fast: prepared 0.063 sec; fetched 0.009 sec 250 rows
    and data.DATADATE >= date 'Now' - date '1899-12-30' - 2 -- last 2 days 
    and data.DATADATE <= date 'Now' - date '1899-12-30' -- today 

Fast

select id, date '1899-12-30' + data.datadate as datestamp
from   data
where  1=1
-- fast: prepared 0.070 sec; fetched 0.011 sec 250 rows
    and data.DATADATE >= date '2017-04-10' - date '1899-12-30' - 2 -- last 2 days 
    and data.DATADATE <= date '2017-04-10' - date '1899-12-30' -- today

Fast

select id, date '1899-12-30' + data.datadate as datestamp
from   data
where  1=1
-- fast: prepared 0.073 sec; fetched 0.009 sec 250 rows
    and data.DATADATE >= date '2016-04-08' - date '1899-12-30' -- specific date range start 
    and data.DATADATE <= date '2016-04-10' - date '1899-12-30' -- specific date range end

The table looks like this:

CREATE TABLE "DATA" 
(
  ID                        INTEGER         NOT NULL,
  DATADATE         DOUBLE PRECISION,
  DATATIME         DOUBLE PRECISION
);
CREATE ASC INDEX DATA_DATADATE ON "DATA" (DATADATE);

–jeroen

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