Jump to content

Lars Fosdal

Administrators
  • Content Count

    3416
  • Joined

  • Last visited

  • Days Won

    113

Everything posted by Lars Fosdal

  1. The organization wants us to switch from SVN to GitHub, but most of use have very limited experience with git - so it is a learning curve that I expect will yield some hard-earned experiences. However, I think we'd want to go all in, instead of this in-between solution?
  2. Lars Fosdal

    Text 3D is horrible

    First impressions, based solely on the visuals: All sides have the same color, which gives you little to no contrast. You don't have a highlighting color for the contour. Perhaps slightly darker sides would help, and maybe a lighting source to enhance contrasts?
  3. Lars Fosdal

    Using the New Edge browser control

    That second one was bad.
  4. Lars Fosdal

    Capturing Tab key in a TCombobox

    I see that the second option in the answer is the same as mine.
  5. Lars Fosdal

    [REST/JSON] Trabstypage error

    I.e. that server does not produce valid Json.
  6. Lars Fosdal

    Indy package names

    We do use it at work. It is pretty uncomplicated to use, but yeah, a lot of features and settings to be explored to master it fully.
  7. Lars Fosdal

    Indy package names

    @dummzeuch Have you tried the free Solo version of Continua CI? It is full featured but limited to one task at a time. Beats batch files by a mile.
  8. Lars Fosdal

    Automatically killing a service when stuck

    "Let it crash" is not on my list of stability strategies.
  9. Lars Fosdal

    Capturing Tab key in a TCombobox

    What if you test it on the Form/Frame OnKeyDown and check if the Sender is that Combo? Would you then be able to instruct the Combo to do the "Enter thing"?
  10. Lars Fosdal

    Automatically killing a service when stuck

    No, it can't. Only what you decide should happen, can happen. Only if it was badly written, or there were no measures in place to regulate resource consumption (number of threads, memory, limited resources). On killing threads - often there is a risk to just kill a thread that is doing some sort of processing, particularly if that processing stores or sends data somewhere. Killing it could lead to memory leaks or limited resource leaks as it would be terminated without cleaning up after itself. A watchdog needs to be aware of what it is watching. It is kinda pointless to restart a process that is not processing, if there is nothing to process. But, since we have zero clue to what kind of processing this mystery service will perform, there is little use in speculating on how to handle "anything nasty" that could happen.
  11. Lars Fosdal

    [REST/JSON] Trabstypage error

    Your Json example consists of an array containing a single string that appear to contains the Json you actually want. { "result": ["[{\"email\":\"XXX@gmail.com\",\"regid\":\"12312312312312312313213w\"},{\"email\":\"YYYY@gmail.com\",\"regid\":\"AAAAAAA\"}]"] } That is why you see the \" escape for each double quote in the actual Json. If you removed the outer array and string quotes, you would see this, but that is not valid Json, as there is no left side reference to that array. { [{ "email": "XXX@gmail.com", "regid": "12312312312312312313213w" }, { "email": "YYYY@gmail.com", "regid": "AAAAAAA" }] } For it to be valid, it would need to look like this. { "result": [{ "email": "XXX@gmail.com", "regid": "12312312312312312313213w" }, { "email": "YYYY@gmail.com", "regid": "AAAAAAA" }] } Somewhere in the process, that Json has been badly mangled. Why is there an outer array and string quotes around the Json you want? The question is: did it happen on the server side, or on the client side?
  12. Lars Fosdal

    How to create a efficient LookupCombo

    You don't want do direct app to DB operations, but put something like a rest service in between the app and the DB.
  13. Lars Fosdal

    Automatically killing a service when stuck

    What are the pitfalls that can cause the service to stop running? If the service stops hard, Windows can restart it, but if it becomes unresponsive - that is harder to deal with. What if it is partially unresponsive? Is it safe to kill it? I'd prefer to know the risk factors here. Normally, healthy code does not suddenly stop running?
  14. OMG, @Anders Melander - I feel for you! Refactoring is hard with mastodont routines like that.
  15. Lars Fosdal

    Automatically killing a service when stuck

    Here is a very simplistic mechanism we use in production to have an application or service restart itself. No second process. We use it for our services that runs 24/7/365 to do f.x. restarts for upgrades (Rename running .exe, copy new exe to same name, prepare restart and exit service). https://pastebin.com/YCiqiNAq
  16. Lars Fosdal

    GetIt

    Perhaps it works well because I am very restrictive with installing plugins?
  17. Lars Fosdal

    Delphi Version Numbers

    https://blog.dummzeuch.de/2014/04/17/determine-the-delphi-installation-directory-from-a-batch-file/ gives some clues. IMO, the versioning variations border on ridiculous.
  18. It quite often doesn't work. I blame the debugger. One thing that helps a little, is to make sure that you switch the active thread to the one where you expect the break - but it is no guarantee.
  19. We use frame/form inheritance for look and feel for some dialogs - but it is indeed a PITA.
  20. Lars Fosdal

    GetIt

    VSCode is ok for files sizes within what is normal for source code. If you have source files that are megabytes of data, VSCode is not your biggest problem. VSCode does not compile projects. It is an editor. Any compilation is done by an external compiler. The VSCode + plugin updates are seamless and recovers your workspace in the exact same state as you had before the update - even including unsaved files. Why would you postpone an update to an editor? Comparing VS with VSCode is apples and oranges. Of course any VSCode plugin will only be as good as the developer or team behind it - just like plugins and components for any IDE.
  21. Lars Fosdal

    More performance Stringgrid sorting algorithm help

    I like inline declarations with their scope limitations. I particularly like the inline declaration of loop variables with type inference. I do not like the leaks inline declared variables can cause with captures. https://quality.embarcadero.com/browse/RSP-29564
  22. I was pondering on what I could do to simplify doing ad-hoc queries and minimize the scaffolding code required, so I came up with this. Note that this code was yanked from one of our units, and hence is not directly runnable as it is missing some functions, and the code that sets up the connection, etc. - but it should give you the general gist of it works. It is not pretty nor perfect, but it works, and if there are glaring mistakes or potential problems, I expect you will tell me all about them 🙂 unit SomeUnit; type RUser = record id: Integer; name: string; displayname: string; end; implementation procedure TSomeClass.ListThoseUsers(const aDB: TDatabase); var Users: TArray<RUser>; begin Users := DB.SelectArray<RUser>('select id, name, displayname from v_users'); // Do whatever you need to do with the user list here end; I am pretty sure that you can create records with fields of types that will cause the TValue conversion to fail horribly, but this deals fine with the basic types as well as enumerated types. Note that the record type needs to be declared in the unit's interface section to get the proper RTTI. Doing a test run from at home to a database server in Trondheim, 700km away - the logs showed SelectArray<SomeUnit.RUser>("select Id, Name, DisplayName from v_users") returned 161 rows in 0:00,024 24 ms is not blisteringly fast, but acceptable. function TDatabase.SelectArray<T>(const sSQL: String): TArray<T>; var Info: String; StopWatch: TStopWatch; Query: TFDQuery; Retry: Boolean; FieldName, RetryMsg: string; rType: TRTTIType; RecField: TArray<TRTTIField>; DBField: TArray<TField>; fx, rx, rc: Integer; begin Retry := False; repeat if Connect then try if Retry then RetryMsg := '#RETRY ' else RetryMsg := ''; StopWatch := TStopWatch.StartNew; rtype := TRTTIContext.Create.GetType(TypeInfo(T)); Info := RetryMsg + 'SelectArray<'+rtype.QualifiedName+'>("' + sSQL+ '") '; Query := TFDQuery.Create(nil); Query.Connection := Connection; Query.ResourceOptions.ParamCreate := False; Query.FetchOptions.Mode := fmAll; Query.FetchOptions.Unidirectional := Unidirectional; Query.SQL.Text := sSQL; try Query.Open; rc := Query.RecordCount; if (Query.FieldCount >= 1) and (rc > 1) then begin RecField := rtype.GetFields; // Fetch field list from record type SetLength(DBField, Length(RecField)); try // Lookup record fields in database result set. Will raise exception if field not found for fx := Low(RecField) to High(RecField) do begin FieldName := RecField[fx].Name; DBField[fx] := Query.FieldByName(FieldName); end; except on E: Exception do begin Info := Info + ' - Field ' + rType.QualifiedName + '.' + FieldName + ' was not found in result set.'; raise; end; end; // for each row in the result set SetLength(Result, rc); for rx := 0 to rc - 1 do begin for fx := Low(RecField) to High(RecField) // for each field in the record, transfer row field to record field do begin if RecField[fx].FieldType.TypeKind = tkEnumeration then RecField[fx].SetValue(@Result[rx], TValue.FromOrdinal(RecField[fx].FieldType.Handle, DBField[fx].AsInteger)) else RecField[fx].SetValue(@Result[rx], TValue.FromVariant(DBField[fx].Value)); end; Query.Next; end; if DebugLogging then DebugOut(Info + ' returned ' + rc.ToString + ' rows in ' + TimeSpanToStr(StopWatch.Elapsed)); end else begin SetLength(Result, 0); end; finally Query.Free; end; Retry := False; except on DBE:EFDDBEngineException do begin LogDBException(DBE, Info, Retry); if not Retry then RAISE; end; on E:Exception do begin LogException(E, Info); RAISE; end; end else raise EDbConnectionFailure.Create(Info + ' DB Error: Could not connect.'); until not Retry; end;
  23. Lars Fosdal

    GetIt

    GUI Design? Not so much, except from SVG fiddling. Mostly PowerShell programming and debugging. Many other languages support debugging in VSCode. Then there is searching in source code. Make a workspace, add your source code folder(s), add the source directories for Delphi and third party code. Search in files, search in current file, highlight selected text. Awesome. My point was originally focused on the ease of upgrade of the IDE and it's plug-ins.
  24. Lars Fosdal

    GetIt

    Off topic is my modus operandi, it seems.
  25. Lars Fosdal

    GetIt

    I was being overly polite.
×