Archive for the ‘Software Development’ Category
Posted by jpluimers on 2019/07/31
Patching code at debug-time: [WayBack] It’s a blong, blong, blong road…: ‘What if?’ scenario analysis in the CPU window.
Remember:
- There are dragons
- Patching too many bytes will kill a kitten and likely your application.
- Bytes in memory might not be what they seem, especially when having breakpoints (and the debugger frantically trying to set/remove $CC bytes for the INT 3 instruction)
I’ve done this for 20+ years and usually use the $90 byte (NOP instruction) though your experience may be different.
–jeroen
Posted in Debugging, Delphi, Development, Pascal, Software Development, Turbo Pascal | Leave a Comment »
Posted by jpluimers on 2019/07/31
I like this built-in construct by fbehrens most:
$result = If ($condition) {"true"} Else {"false"}
Everything else is incidental complexity and thus to be avoided.
For use in or as an expression, not just an assignment, wrap it in $(), thus:
write-host $(If ($condition) {"true"} Else {"false"})
There are even more elegant constructs, but those require setting up an alias before using them.
Source: [WayBack] Ternary operator in PowerShell – Stack Overflow
–jeroen
Posted in CommandLine, Development, PowerShell, PowerShell, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2019/07/30
A race condition can be this small:
if Assigned(Setting.OnChanged) then
Setting.OnChanged(Setting);
If in between these lines, the value of Setting.OnChanged becomes nil, then you have an access violation.
It is a very slim, but real chance.
–jeroen
Posted in Delphi, Development, Multi-Threading / Concurrency, Software Development | 4 Comments »
Posted by jpluimers on 2019/07/30
Cool tip by mjolinor to execute the scripts 1.ps1, 2.ps1 and 3.ps1 from a master.ps1 script in the same directory:
&"$PSScriptroot\1.ps1"
&"$PSScriptroot\2.ps1"
&"$PSScriptroot\3.ps1"
Source: [WayBack] scripting – Run Multiple Powershell Scripts Sequentially – on a Folder – Combine Scripts into a Master Script – Stack Overflow.
It uses $PSScriptroot which got introduced in PowerShell 2 in modules and extended in PowerShell 3 to be available in all scripts. More information in [WayBack] about_Automatic_Variables | Microsoft Docs
–jeroen
Posted in CommandLine, Development, PowerShell, PowerShell, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2019/07/26
Utility for converting curl commands to code
For my link archive: [WayBack] Convert cURL command syntax to Python requests, Node.js code
–jeroen
Posted in *nix, *nix-tools, cURL, Development, JavaScript/ECMAScript, Node.js, Power User, Python, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2019/07/25
Need to check on this compiler error that you can solve by moving the generic class TExceptionThread<T> from the implementation section of a unit to the interface section.
[dcc32 Error] Test.ExceptionLogging.pas(246): E2506 Method of parameterized type declared in interface section must not use local symbol 'TExceptionThread`1'
My gut feeling is that that this either has to do with RTTI generation, or is a limitation of the compiler.
I need to trim that one done since it does not match any of these:
–jeroen
Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »
Posted by jpluimers on 2019/07/25
I love the solution with piped Join-Path constructs answered by David Keaveny in [WayBack] powershell – How do I use join-path to combine more than two strings into a file path? – Stack Overflow:
Since Join-Path can be piped its path value, you can pipe multiple Join-Path statements together:
Join-Path "C:" -ChildPath "Windows" | Join-Path -ChildPath "system32" | Join-Path -ChildPath "drivers"
Of course you could replace the built-in [WayBack] Join-Path by using using the .NET Framework [WayBack] Path.Combine Method (System.IO), but then you loose code completion.
If you do like that, here is how:
[System.IO.Path]::Combine("C:", "Windows", "system32", "drivers")
–jeroen
Posted in CommandLine, Development, PowerShell, PowerShell, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2019/07/24
A while ago, I got a question on code metrics, so here some links for my reading list:
Delphi related:
--jeroen
Posted in Development, Profiling-Performance-Measurement, Software Development | Leave a Comment »