Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 02/09/23 in all areas

  1. David Heffernan

    Nested TParallel.For: Immediate deadlock

    Likely because it has been properly designed by skilled practitioners in this field.
  2. Fr0sT.Brutal

    Move objects to a second Data Module

    In fact, Delphi teaches us bad things with all this visual & RAD button-dropping. It's good for small apps but when they grow, old habits remain and lead to these nightmare. I was in the same situation with an app started when I started learning Delphi so it's evolving with me. In that app I significantly reduced the number of objects in datamodules by changind all temporary queries (that is, those which do not have any datasource attached) from design-time components to temporary objects created at run-time. Their SQLs are defined as literals in datamodule unit and field list is generated dynamically. And with interface-based wrapper the code is pretty simple with GetTempQuery(Database).Q do begin SQL.Text := SQL_Insert; Params ... ExecSQL; end;
  3. aehimself

    Move objects to a second Data Module

    We are developing a 20 year old application at work: over 1,5M LOC, 500-700 frames, couple thousands of units. Today we had a meeting with our teamlead where we successfully convinced him to allow the framework team to go for a full visual and codebase refactoring - effectively building it from the ground up once more; reusing mostly experience and tiny chunks of the original code (yeah, it's that bad). There are things what you can not delay any further. If this is what is needed to improve the coding experience devs will have to get used to the new model. It's for their own sake aswell, after all. With all that said, I'm fully aware that OP probably won't go in this direction. I'm leaving my remark here for future visitors, who might still be able to change their design seeing what the easy way can / will cause.
  4. Are you using the PAServer package from the Delphi program files folder? I had problems like that until I downloaded the one from the website directly on the Mac machine.
  5. programmerdelphi2k

    Resize PNG in Delphi 11

    you're wellcome!
  6. programmerdelphi2k

    Resize PNG in Delphi 11

    thanks for all "like", , :)))
  7. programmerdelphi2k

    Resize PNG in Delphi 11

    not necessary! just if you want and be sure about this!
  8. dmitrok2006

    Resize PNG in Delphi 11

    That is, in the last code at the development stage, the image will be loaded and the file on disk can be deleted?
  9. programmerdelphi2k

    Resize PNG in Delphi 11

    var MyImage: TImage; begin MyImage := TImage.Create(nil); try MyImage.Left := 0; // any values ... MyImage.Top := 0; MyImage.Width := 0; // ... MyImage.Picture.LoadFromFile('....'); // MyImage.Parent := self; // self = form1 -> "parent" to appears on screen of form area!! finally MyImage.Free; end;
  10. dmitrok2006

    Resize PNG in Delphi 11

    Thank you very much, I'll look into it ))))
  11. programmerdelphi2k

    Resize PNG in Delphi 11

    To tell the truth, you would only need to embed a "resource" (image, sound, etc...) in strictly necessary case, where to load it... would be something very time consuming, or if the resource doesn't cost much for your system (memory, performance, etc...)! Overall you could just load it "on-demand" Using a component is just to make the job easier, in fact you can create it at run-time. Or, if you don't need a component, you can just create the component class to do your background work... in code!
  12. programmerdelphi2k

    Resize PNG in Delphi 11

    after this line, "LPictureSource" it's not necessary anymore, then, you can " LPictureSource.Graphic := nil"
  13. programmerdelphi2k

    Resize PNG in Delphi 11

    @dmitrok2006 when loading in "design-time" your image is "embedded" in you exe!
  14. Der schöne Günther

    Nested TParallel.For: Immediate deadlock

    Thank you, that's also the temporary workaround I have come up with. I discovered it when running code from a library in a TParallel.For-loop that also made use of TParallel.For. They all implicitly used the default thread pool. Still, I'd like this caveat to be properly documented, and not to discover it in a running factory like I just did. And it still leaves me wondering why the C# runtime does not have these problems.
  15. https://github.com/kehribar/log2 -tee-
  16. Dalija Prasnikar

    Nested TParallel.For: Immediate deadlock

    The problem happens when outer For loop consumes all available threads and hits maximum where no new threads are being allocated for newly requested task. And then if inner tasks cannot get free thread to run, they cannot complete their job. I have test case that will break more easily as number of needed threads is higher, and sleep also increases the time inner thread runs and gives more time for outer for loop to consume all available threads. Using separate pool for inner for loop solves the problem. This can still be an issue if you have code that indirectly uses nested parallel loops. begin var counter := 0; var pool := TThreadPool.Create; const COUNT = TThreadPool.Default.MaxWorkerThreads * 4; TParallel.For( 0, Pred(count), procedure(i: Int64) begin TParallel.For( 0, Pred(count), procedure(i: Int64) begin TInterlocked.Increment(counter); Sleep(10); end , pool); end ); Writeln(counter); Readln; end. Probably the best solution for parallel for loops that can spawn too many tasks would be to create dedicated thread pool for each loop. The cost of creating a thread pool is not big when dealing with longer running tasks. And for fast running tasks, like in this example, parallel loop is overkill anyway as it can run slower than simple for loop in single task.
  17. Yes; That's what I wrote. procedure InjectMyForm(HandleOfControlOnPropertyPage: HWND; MyForm: TForm); begin SetParent(MyForm.Handle, HandleOfControlOnPropertyPage); ...lots of stuff to do with positioning and window style... end;
  18. aehimself

    Update an application automatically

    TMS has a commercial package, you read more about it at https://www.tmssoftware.com/site/wupdate.asp I wrote my own, open source version which I am using in my main application for a while now and seems to do it's job properly. I attempted to build it up to be as versatile as possible but it's probably still a toddler compared with TMS when it comes to features, though. There's an example code on how to create an update file and how to update your application here:
  19. programmerdelphi2k

    Resize PNG in Delphi 11

    I think that is VCL, not? Image1.Picture.Graphic.SetSize(...) ... procedure TForm1.Button1Click(Sender: TObject); var LPictureSource: TPicture; // load a PNG LPictureTarget: TPicture; // to resize like a Bitmap LPNGresulted : TPngImage; // to save PNG resulted begin LPictureSource := TPicture.Create; LPictureTarget := TPicture.Create; LPNGresulted := TPngImage.Create; try LPictureSource.LoadFromFile('Spiderman.png'); // with transparent background on png LPictureSource.Graphic.Transparent := True; // Memo1.Text := 'Spiderman.png = ' + LPictureSource.Width.ToString + 'x' + LPictureSource.Height.ToString; // LPictureTarget.Bitmap.Create(1, 1); // just for create internal values to canvas, etc... LPictureTarget.Graphic.Transparent := True; // // new size LPictureTarget.Bitmap.Width := Trunc(LPictureSource.Width * 4.0); // size x 4 LPictureTarget.Bitmap.Height := Trunc(LPictureSource.Height * 4.0); // // draw on new canvas resized LPictureTarget.Bitmap.Canvas.StretchDraw(LPictureTarget.Bitmap.Canvas.ClipRect, LPictureSource.Graphic); // Memo1.Lines.Add(LPictureTarget.Width.ToString + 'x' + LPictureTarget.Height.ToString); // LPNGresulted.Assign(LPictureTarget.Bitmap); // Memo1.Lines.Add('PNG = ' + LPNGresulted.Width.ToString + 'x' + LPNGresulted.Height.ToString); // LPNGresulted.SaveToFile('resulted.png'); // just for test load file... // Image1.Picture.LoadFromFile('resulted.png'); Image1.Proportional := True; finally LPNGresulted.Free; LPictureTarget.Free; LPictureSource.Free; end; end;
  20. aehimself

    Move objects to a second Data Module

    +1 for @Stano's idea. At a large number like this it's better to write a factory code and request these items runtime.
  21. I solved this thanks to the kind collaboration of the nSoftware assistance service (SecureBlackBox's developer). There were many challenges to solve to achieve the goal and very little can be found online. It is my understanding that this type of security is not used much in the Delphi environment. However I solved by combining several components provided with the SecurityBlackBox suite: TsbxCertificateStorage to read JKS file to reach public key (used to encrypt the request and verify the signed response) and private key (used to sign the request and decrypt the response) TsbxSOAPSigner to sign the SOAP request (to produce a WSSSignature) TsbxXMLEncryptor to embed in the request the encryption key (transported with RSA-OAEP sha1) and to crypt the SOAP request body (with AES128 algorithm) TsbxXMLDecryptor to decrypt the response (two items encrypted in the response: the sign and the body) TsbxSOAPVerifier to verifiy the sign in the response I've injected this encryption/decryption stuff in THTTPRio events, somthing like this; procedure TMultyAssociativeServiceWrapper.SOAPOnBeforeExecute(const MethodName: String; SOAPRequest: TStream); begin // save the original request (created by THTTPRio) for debug purpose SOAPRequest.Seek(0,0); (SOAPRequest as TMemoryStream).SaveToFile(FFileRequestOriginal); // sign and encrypt the original request SBBSoapSignAndEncryptWithJKS(FFileRequestOriginal, FFileRequestToSend, FCertificateFileJKS, OnPasswordNeeded); // ... do some other stuff ? // update the outcoming request with the signed crypted version SOAPRequest.Seek(0,0); (SOAPRequest as TMemoryStream).LoadFromFile(FFileRequestToSend); end; procedure TMultyAssociativeServiceWrapper.SOAPOnAfterExecute(const MethodName: String; SOAPResponse: TStream); begin // save te orginal response arrived from service for debug purpose SOAPResponse.Seek(0,0); (SOAPResponse as TMemoryStream).SaveToFile(FFileResponseOriginal); // decrypt and verify sign of response SBBSoapDecryptAndVerifyWithJKS(FFileResponseOriginal, FFileResponseDecoded, FCertificateFileJKS, OnPasswordNeeded); //... do some other stuff? // update the incoming response with the decrypted data SOAPResponse.Seek(0,0); (SOAPResponse as TMemoryStream).LoadFromFile(FFileResponseDecoded); end; SBBSoapSignAndEncryptWithJKS does sign + encryption stuff. SBBSoapDecryptAndVerifyWithJKS does decrypt and verify sign stuff. I hope this can be helpful for someone else who runs into this need. If you need the code of the two SBB procedures described above please ask me. I've used SecureBlackBox components but I think that same stuff could be reached also with ChilKat library. I did some tests with the demo library, it works at a lower level of SBB but there are several examples online that could be combined to reach the goal.
  22. TheOnlyOne

    Need a "Delphi programming guideline"

    As I said before: because their Delphi code was really, really old, I proposed my boss to scratch it and start from zero. He was reluctant, so I built it from scratch in a few days (my very private time) - needing another full month to polish the program, to make it ready to be sold - the original program is 150000 lines of code but it is procedural (all data stored in strings) and the old code was never ever deleted from the project. On objects, that code would be rewritten in max 15000 lines! One of the exporters they had was 8000 lines. I implemented it in mine in 60 lines (objects streamed down to binary files). Now I know why my was reluctant to use my code: because he was already convinced by other guys to rewrite it using "brand-new-shiny" web tech. But instead of one programmer (me) and 1 month, their road map is now 10 programmers and one year. Congratulations web guys! _ But I would have been glad if our boss had had the balls to tell us upfront (months ago) that he already decided for web-stuff and not Delphi. Anyway, my CV is again ready to be submitted to companies willing to accept home-office. Is it 4 pages (small font) too long? I don't want to cut down my libraries, scientific publications or the (industrial) robots I worked on . Hope to find something exciting again -> therefore, DB is pretty much excluded - Unfortunately, Delphi comes with this baggage - all still-sending companies are either running on obsolete Delphi code OR their core business involves some "god please kill now be because I am bored" DB-centric architecture. ____________________________________________________________________________________________________ But for Emba: WHY THE FUCK are you sleeping there? Wake up. Hire people. Send them to Facebook, Instagram, Twitter, schools and universities. Don't forget the kindergartens! Today, they don't start teaching programming when you are 23. They start at kindergarten. My 10 years old son already knows 3 languages! Wrote game in Delphi 🙂 Start to show that Delphi is alive and kicking. Get rid of the "old guy" smell. They hired gray beards like Marco Cantu. I thought he was one of "our" guys. Isn't he aware of what is out there? Is he so old that he doesn't know how to use the Internet?
  23. Angus Robertson

    400 Bad Request ,nginx/1.14.0

    ICS has a proxy server sample that includes logging and headers and optionally bodies, I've used it for debugging SSL connections. You can even fake a server SSL certificate (and some anti-malware packages do, to intercept SSL sessions if you can not originate in HTTP. Angus
  24. Remy Lebeau

    Sending Email via GMail Using OAuth 2.0 via Indy

    Failed how, exactly? Since you are posting this in an Indy forum, I'll give you an Indy answer - You can either turn on 2-Factor Authentication in your Google account and then create an App-Specific password for Indy to use, thus not requiring OAuth2 and no code changes or upgrades needed to use TIdSMTP/TIdPOP3/TIdIMAP4. Or, if you must use OAuth2, then install the latest Indy OAuth2 branch code (https://github.com/IndySockets/Indy/tree/sasl-oauth) into your Delphi 2010 (which Indy still supports), replacing any Indy version you may already have installed (https://github.com/IndySockets/Indy/wiki/Updating-Indy), and then you can use TIdHTTP to retrieve an access token from Google, and use TIdSASLXOAuth2 to use that token with TIdSMTP/TIdPOP3/TIdIMAP4.
  25. Remy Lebeau

    Sending Email via GMail Using OAuth 2.0 via Indy

    FYI, this morning I checked in a new 'sasl-oauth' branch in Indy's repo, which includes a new 'IdSASLOAuth.pas' unit for SASL classes for OAUTH10A, OAUTHBEARER, and XOAUTH2 for TIdDICT, TIdPOP3, TIdSMTP, and TIdIMAP4. They are still a work in progress (ie, no parsing of response JSON yet), and you are responsible for obtaining the OAuth tokens externally (ie, over HTTP), but once you have the tokens then you can use these SASLs to login to the DICT/POP3/SMTP/IMAP servers.
×