Since I always forget the command (I do not use it often enough) [WayBack] Plastic SCM – Branch per task guide:
cm add -R .
That adds the current directory (.) recursively, taking into account the ignore.conf file.
–jeroen
Posted by jpluimers on 2021/05/18
Since I always forget the command (I do not use it often enough) [WayBack] Plastic SCM – Branch per task guide:
cm add -R .
That adds the current directory (.) recursively, taking into account the ignore.conf file.
–jeroen
Posted in Development, PlasticSCM, Software Development, Source Code Management | Leave a Comment »
Posted by jpluimers on 2021/05/18
A while ago, I needed to get RowVersion binary data out of SQL Server. People around me told me it is stored as BigInt.
I luckily bumped into [WayBack] sql server – Cast rowversion to bigint – Stack Overflow.
That post explains RowVersion is not stored as BigInt. Both RowVersion and BigInt take up 8 bytes of storage, but RowVersion is big-endian and unsigned, whereas BigInt is little-endian and signed.
A few quotes from it:
In my C# program I don’t want to work with byte array, therefore I cast rowversion data type to bigint:
SELECT CAST([version] AS BIGINT) FROM [dbo].[mytable]So I receive a number instead of byte array. Is this conversion always successful and are there any possible problems with it? If so, in which data type should I cast rowversion instead?
and
You can convert in C# also, but if you want to compare them you should be aware that rowversion is apparently stored big-endian, so you need to do something like:
byte[] timestampByteArray = ... // from datareader/linq2sql etc... var timestampInt = BitConverter.ToInt64(timestampByteArray, 0); timestampInt = IPAddress.NetworkToHostOrder(timestampInt);It’d probably be more correct to convert it as ToUInt64, but then you’d have to write your own endian conversion as there’s no overload on NetworkToHostOrder that takes uint64. Or just borrow one from Jon Skeet (search page for ‘endian’).
Code: [WayBack] Jon Skeet: Miscellaneous Utility Library
Related:
The Intel x86 and also AMD64 / x86-64 series of processors use the little-endian format, and for this reason, it is also known in the industry as the “Intel convention“.
Endianness is also important
Additionally, as Mark pointed out,
BitConverter.GetUInt64is not converting properly. Mark is not completely right–BitConverteris either big-endian or little-endian depending on the system it’s running on.
--jeroen
Posted in .NET, Database Development, Delphi, Development, Jon Skeet, Software Development, SQL Server | Leave a Comment »
Posted by jpluimers on 2021/05/18
[WayBack] Any idea why we get this error, or even better, how to fix it : [dcc32 Error] JclRTTI.pas(663): E2134 Type ‘<void>’ has no type info We compile same c… – Tommi Prami – Google+
So the JCL needs to have the compiler setting Emit runtime type information set to true (which is the default for projects, but can be turned off).
Thanks Stefan Glienke for reporting the fix.
–jeroen
Posted in Delphi, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2021/05/14
The Microsoft rebuilt move affects these Chocolatey Microsoft Visual C++ Redistributable packages, usually multiple times:
You get error messages like this:
ERROR: Checksum for 'C:\Users\saroot\AppData\Local\Temp\chocolatey\vcredist2010\10.0.40219.2\vcredist_x86.exe' did not meet '66B797B3B4F99488F53C2B676610DFE9868984C779536891A8D8F73EE214BC4B' for checksum type 'sha256'. Consider passing the actual checksums through with --checksum --checksum64 once you validate the checksums are appropriate. A less secure option is to pass --ignore-checksums if necessary
The cause is [Archive.is] vcredist-all fails to install due to broken checksum of vcredist2005, vcredist2008 and vcredist2010 · Issue #105 · jberezanski/ChocolateyPackages
jberezanskicommented
Great, Microsoft is apparently on an in-place installer update spree.
Actually, this is not a problem with
vcredist-all, but rather with those specific packages and should be reported to maintainers of those packages. It so happens, however, that I’m also one of the maintainers of vcredist2008 and vcredist2010 (which live in https://github.com/chocolatey-community/chocolatey-coreteampackages/tree/master/manual). I’ve already prepared a fix for 2010 and I guess I’ll do 2008 tomorrow.As for 2005, I can see that it has the same maintainer as
vcredist2010had until very recently – when we took over that package because the maintainer did not respond. So we probably should take over 2005, too.
Progress
The vcredist2010 package has been modified two times for this:
Hopefully the vcredist2008 and vcredist2005 packages will follow soon.
–jeroen
Posted in C++, Chocolatey, Development, Power User, Software Development, Visual Studio C++, Windows | Leave a Comment »
Posted by jpluimers on 2021/05/13
A while ago I needed an estimate for [WayBack] How to calculate bitmap size? – Stack Overflow, which does an accurate calculation for the size of the pixel storage (i.e. without headers):
pixelStorageSize = (( width*bitsPerPixel + 31) / 32) * 4 * height
Here:
It was derived from [WayBack] Capturing an Image – Windows applications | Microsoft Docs and shorthand for what is explained at [WayBack] BMP file format: Pixel storage – Wikipedia
The bits representing the bitmap pixels are packed in rows. The size of each row is rounded up to a multiple of 4 bytes (a 32-bit DWORD) by padding.
For images with height above 1, multiple padded rows are stored consecutively, forming a Pixel Array.
The total number of bytes necessary to store one row of pixels can be calculated as:
- {\displaystyle {\text{RowSize}}=\left\lceil {\frac {{\text{BitsPerPixel}}\cdot {\text{ImageWidth}}}{32}}\right\rceil \cdot 4=\left\lfloor {\frac {{\text{BitsPerPixel}}\cdot {\text{ImageWidth}}+31}{32}}\right\rfloor \cdot 4,}
- ImageWidth is expressed in pixels, note the special parentheses.
The total amount of bytes necessary to store an array of pixels in an n bits per pixel (bpp) image, with 2ncolors, can be calculated by accounting for the effect of rounding up the size of each row to a multiple of 4 bytes, as follows:
- PixelArraySize = RowSize · |ImageHeight|
- ImageHeight is expressed in pixels. The absolute value is necessary because ImageHeight can be negative.
I think I needed this to estimate how many bitmaps would fit in
[WayBack] Virtual address space – Wikipedia, which on 32-bit Windows by default is limited to 2 GiB, and can be extended to 3 GIB by enabling the IMAGE_FILE_LARGE_ADDRESS_AWARE executable header flag.
This flag imposes the risk of many libraries and DLLs to fail because they do not get the pointer math right. You often do not have control of future versions of DLLs being loaded in your process space and their risks, so do not ever use that flag.
–jeroen
Posted in Algorithms, Development, Software Development | 1 Comment »
Posted by jpluimers on 2021/05/13
Sometimes an install is not just as simple as C:\>choco install --yes oracle-sql-developer.
Edit 20210514:
Note that most of the below pain will be moot in the future as per [Archive.is] Jeff Smith 🍻 on Twitter: “we’re working on removing the SSO requirement, it’s already done for @oraclesqlcl – see here … “ referring to [Wayback] SQLcl now under the Oracle Free Use Terms and Conditions license | Oracle Database Insider Blog
SQLcl, the modern command-line interface for the Oracle Database, can now be downloaded directly from the web without any click-through license agreement.It means the Oracle acount restriction will be lifted, and downloads will be a lot simpler.
I started with the below failing command, tried a lot of things, then finally almost gave up: Oracle stuff does not want to be automated, which means I should try to less of their stuff.
First of all you need an Oracle account (I dislike companies doing that for free product installs; I’m looking at Embarcadero too) by going to profile.oracle.com:
[WayBack] Chocolatey Gallery | Oracle SQL Developer 18.4.0 (also: gist.github.com/search?l=XML&q=oracle-sql-developer)
Notes
- This version supports both 32bit and 64bit and subsequently does not have a JDK bundled with it. It has a
dependency on thejdk8package to meet the application’s JDK requirement.- An Oracle account is required to download this package. See the “Package Parameters” section below for
details on how to provide your Oracle credentials to the installer. If you don’t have an existing account, you can
create one for free here: https://profile.oracle.com/myprofile/account/create-account.jspxPackage Parameters
The following package parameters are required:
*
/Username:– Oracle username
*/Password:– Oracle password(e.g.
choco install oracle-sql-developer --params "'/Username:MyUsername /Password:MyPassword'")To have choco remember parameters on upgrade, be sure to set
choco feature enable -n=useRememberedArgumentsForUpgrades.
Then the installation failed fail again: ERROR: The response content cannot be parsed because the Internet Explorer engine is not available, or Internet Explorer's first-launch configuration is not complete. Specify the UseBasicParsing parameter and try again.
The trick is to RUN IEXPLORE.EXE AS ADMINISTRATOR ONCE BEFORE INSTALLING FROM CHOCOLATEY. Who would believe that.
The reason is that the package uses Invoke-WebRequest which requires Internet Explorer and PowerShell 3. Chocolatey packages however need to be able to run on just PowerShell 2 without Invoke-WebRequest.
Maybe using cURL can remedy that; adding a dependency to is is possible, as cURL can be installed via chocolatey: [WayBack] How to Install cURL on Windows – I Don’t Know, Read The Manual. Another alternative might be [WayBack] Replace Invoke-RestMethod in PowerShell 2.0 to use [WayBack] WebRequest Class (System.Net) | Microsoft Docs.
Posted in CertUtil, Chocolatey, CommandLine, Database Development, Development, DVCS - Distributed Version Control, git, Hashing, OracleDB, Power User, PowerShell, Security, SHA, SHA-1, Software Development, Source Code Management, Windows, XML, XML/XSD | Leave a Comment »
Posted by jpluimers on 2021/05/13
Quite some time ago, I was researching spurious exceptions in a Delphi application, then finally replicated them in a unit test suite.
One of them was occurring almost all of the time: EInvalidOp.
It is one of the floating point exceptions (incidentally exampled at [WayBack] Exceptions: Declaring Exception Types) all inheriting from the [WayBack] EMathError Class:
EMathErroris the base class for floating-point math exception classes.EMathErroritself is never raised.The following exceptions descend from
EMathError:
Meaning Parameter out of range Processor encountered an undefined instruction Floating-point operation produced result too large to store Floating-point operation produced result with no precision Attempt to divide by zeroRun-time exception information is saved in fields provided by [WayBack]
EExternal.
In my first case (which I described in delphi – Invalid floating point operation calling Trunc()), not all input scenarios had been tested in a certain scenario. In a production environment, one of the inputs was really high.
In a later case, the actual cause was not a floating point problem at all, but a use-after-free scenario that overwrite a floating point value with something not so compatible also causing a simple Trunc statement to fail in the same way.
In that case, the production data could never reach the big numbers that failed, so no new tests were needed.
–jeroen
Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »
Posted by jpluimers on 2021/05/12
Posted in Development, Go (golang), Software Development | Leave a Comment »
Posted by jpluimers on 2021/05/12
Quite a while back, @NS_Online (Dutch railroads) did not accept plus signs in email addresses. I verified a few times over the years and not much progress.
This is a reminder to myself to re-check.
Edit 20230418: it has started working, see further below.
Below the fold the Twitter thread that started with [WayBack] Jeroen Pluimers on Twitter: “Toch jammer dat @NS_online valide email adressen met een plus-teken erin weigert.… “
Hopefully by now they retraced themselves from the bad company of many other parties failing to adhere to clear and long existing internet standards: [WayBack] User:Me at work/plushaters | Mozilla Community | FANDOM powered by Wikia.
Their web care team and their developers made some very inexcusable assumptions there:
Some links on email addresses and their validity:
Posted in Development, Power User, Software Development, Web Development | Leave a Comment »
Posted by jpluimers on 2021/05/12
(Tagged FastMM4 as that’s the first code I saw these warnings to be turned off)
Delphi 7 introduced introduced warnings for unsafe constructs like W1047 and W1048 so you could prepare your code for the first Delphi .NET compilers .
The oldest online documentation on this is in Delphi 2007:
Type Switch Syntax{$UNSAFECODE ON}or
{$UNSAFECODE OFF} Default{$UNSAFECODE OFF} Scope Local
You have used a data type or operation for which static code analysis cannot prove that it does not overwrite memory. In a secured execution environment such as .NET, such code is assumed to be unsafe and a potential security risk.
You have used a data type or operation for which static code analysis cannot prove that it does not overwrite memory. In a secured execution environment such as .NET, such code is assumed to be unsafe and a potential security risk.
You have used a data type or operation for which static code analysis cannot prove that it does not overwrite memory. In a secured execution environment such as .NET, such code is assumed to be unsafe and a potential security risk.
After Delphi 2007, the .NET compiler got shelved, but the errors and warning stayed as they serve a good purpose for native code as well.
Delphi 2007 did not document any of the other directives.
Unlike the D2007 documentation, however, the UNSAFECODE should be written UNSAFE_CODE as with using {$WARN UNSAFECODE ON}, you will get this error:
E1030 Invalid compiler directive: 'UNSAFECODE'
Looking at the library code and example code that ships with Delphi, these are the valid $WARN compiler directives having to do with UNSAFE:
UNSAFE_CAST (since Delphi 7, but only used in Vcl.WinXPanels.pas introduced in Delphi 10.2 Tokyo and up)UNSAFE_CODE (since Delphi 7, but still documented as UNSAFECODE)UNSAFE_TYPE (since Delphi 7)UNSAFE_VOID_POINTER (since Delphi XE3, as precursor to the NEXTGEN compilers)The ultimate source for these is the file DCCStrs.pas that has shipped since Delphi 2009: [WayBack] warnings – Identifiers for Delphi’s $WARN compiler directive – Stack Overflow.
A problem is that current documentation still lists the wrong name in many places:
- UNSAFE_TYPE
- UNSAFE_CODE
- UNSAFE_CAST
This one finally got it right: [WayBack] Warning messages (Delphi) – RAD Studio
UNSAFE_TYPEW1046 UNSAFE_CODEW1047 UNSAFE_CASTW1048
Note it also documented UNSAFE_VOID_POINTER:
UNSAFE_VOID_POINTERW1070 [WayBack] W1070 Use of untype pointer can disrupt instance reference counts (Delphi) – RAD Studio
And these warning messages still do not contain the directives, but do explain the underlying code construct better:
You have used a data type or operation for which static code analysis cannot prove that it does not overwrite memory. For example, you might receive this warning if you declare something as absolute. Such code can be considered a security risk.
You have used a data type or operation for which static code analysis cannot prove that it does not overwrite memory. Such code can be considered a security risk.For example, using GetMem can elicit this warning because a block of memory has no associated type.
You have used a data type or operation for which static code analysis cannot prove that it does not overwrite memory. For example, you might have cased one record to another or one instance to another.
You have to use these directives:
// Get rid of "W1047 Unsafe code 'ASM'", "W1047 Unsafe code '^ operator'", "W1047 Unsafe code '@ operator'" and similar {$WARN UNSAFE_CODE OFF} // Get rid of "W1048 Unsafe typecast of 'TFreedObject' to 'PByte'" and similar {$WARN UNSAFE_CAST OFF}
Back in the days, some people were not amused and disabled the warnings, for instance in [Archive.is] Re: How can I eliminate these warnings in Delphi 7 which did not appear in Delphi 5. – Google Groups:
Dennis Passmore:I have one include file that I usually include in all projects as follows—– WarningsOff.inc —————-
{$IFDEF CONDITIONALEXPRESSIONS}
{$IF CompilerVersion >= 14}
{$WARN SYMBOL_PLATFORM OFF}
{$WARN SYMBOL_DEPRECATED OFF}
{$WARN SYMBOL_LIBRARY OFF}
{$WARN UNIT_DEPRECATED OFF}
{$WARN UNIT_LIBRARY OFF}
{$WARN UNIT_PLATFORM OFF}{$WARN UNSAFE_TYPE OFF}
{$WARN UNSAFE_CODE OFF}
{$WARN UNSAFE_CAST OFF}
{$IFEND}
{$ENDIF}
———————and it gets ride of all unwanted warnings in the IDE or even DCC32.exe when compiling the project
from the command line.I just add the following line to the project .dpr file and do not worry about the rest.
{$I WarningsOff.inc}
Dennis Passmore
“If you cannot conceive the idea you
will never achieve the desired results”
I disagree with such an approach, as those warnings have their purpose.
Knowing how to selectively disable/enable them however, is important.
–jeroen
Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »