Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

24 Excellent

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I think I've come across the things you describe when creating xxm. There's more to the project than REST, but to have an out-of-the-box option of hosting web projects created with xxm, I created a really basic HTTP server, that also handles multipart file uploads. So, if you have a web form like this that would allow a user to post a file, the server would process the parts of the request into specific parameters like this. But I'm afraid this is quite an integrated solution and not quite a 'snippet' you can use to apply elsewhere. None-the-less I warmly invite you to take a good look at xxm and see if it could be a fit for any project you're considering that combines Delphi and the web.
  2. stijnsanders

    vtString and vtWideString & vtAnsiString

    I see in System.pas that VAnsiString is of type pointer and not of type AnsiString. I'm not sure you can 'just' cast it into type AnsiString (which happens to also be a pointer internally), but assuming you can: SizeOf(VAnsiString) will probably always be 4 (on 32-bits, 8 on 64-bits), I guess you'll need Length(AnsiString(VAnsiString)) then Move(AnsiString(VAnsiString), ... will actually read the pointer value (and whatever happens to be in memory after that) not the string data itself. You have to dereference, either explicitly: Move(VAnsiString^, ... or I prefer to do this as if I'm letting Move know where the start of the string data is: Move(AnsiString(VAnsiString)[1], ... And you use SizeOf for the Inc again, change that to Length, of better still use an extra local variable so you only need 1 call to Length (and the compiler can optimize register allocation for it)
  3. stijnsanders

    Delphi Compilers - # lines of code

    If you do find anything about it, I wonder how it would relate to dwScript's number of lines of code...
  4. stijnsanders

    JSON parsing question

    If you're willing to examine an alternative, and if you're struggling with other JSON solutions that appear to 'bind' the JSON data to some sort of schema that determine the full extent of what you'd possibly do with the date, check out this JSON unit I've created in the margin of an attempt at a no-frills MongoDB connector: https://github.com/stijnsanders/jsonDoc#jsondoc I also dislike solutions that depend long lists of overloads for all kinds of types, so it depends on Variants heavily, especially that a Variant value can hold a reference to the interface of a live instance if anything, such as another IJSONDocument object. Also arrays in JSON are converted to and from Variant arrays. So using VarType, you could detect when data is an array or not, if it's an sub-object, you'll get varUnknown, look at the function JSON declared in the unit how to get a IJSONDocument reference. Also have a look at function JSONEnum to list the "sectionX" fields the base object might have.
  5. If I recall correctly, the GetPixel method is rather slow. Does FMX.Graphics' TBitmap also have a Scanline pointer property?
  6. stijnsanders

    Can Delphi randomize string 'Delphi'?

    Aah, that makes me think of the infinite monkeys theorem (and also)
  7. stijnsanders

    How create a website whit Delhpi

    I would humbly like to offer another alternative. By no means I want to imply it is any better than the other options of building a website with Delphi, but if you're willing to not use the RAD-side of Delphi, and its IDE, but want to use the Delphi language and its compiler, and combine HTML and server-side logic code in the same files much like (early!) PHP or Cold Fusion, I've created this solution to do just that: https://github.com/stijnsanders/xxm#xxm What I wanted was a way to create a website by working on the code, press F5 in a browser to put it to work, but have the website itself run from a freshly compiled DLL, from a Delphi project. This same DLL would use a generic interface, so by moving it from your development machine to a online web-server, you could use the same DLL with Apache httpd, IIS, or SCGI. It may take some work to get it going and set it up, and you don't have any support of a platform, but if you know what you're doing, that can be a good thing. Most other web-platforms I've witnessed all take some freedom away by the choices that have been made in their design, and you inevitably will hit these limitations later when you're trying to do something the platform wouldn't support. If you're interested to see a fully developed web-application on xxm, have a look here: https://github.com/stijnsanders/tx#tx (I once made "get started" tutorial, but should really update it, replace xxmLocal with xxmHttp and IE with Firefox or Chrome...)
  8. stijnsanders

    Delphi AES encryption/decryption

    If you're interested in another alternative, I've started from the root document to make a pure-Delphi version under a permissive license: https://github.com/stijnsanders/tools/blob/master/crypto/aes.pas I also did HMAC and PKDF2 here
  9. stijnsanders

    TWebBrowser Question

    I remember vaguely that you should be able to 'start' the WebBrowser component with an alternative 'path' into the Windows registry where it should get its configuration from. If that's correct, there might just be a tiny chance the path for the save image dialog is also read from a key somewhere under that registry key... Since I haven't used TWebBrowser all that much, I'm afraid I'm not able to give you code or more accurate pointers where to look for this...
  10. stijnsanders


    Aside from the control flow details, there's more to TMemoryStream, especially when you use it with potentially big blobs of data you're in danger of getting an "out of memory" error, even when there's in fact still memory available. It has to do with fragmentation (something that's in theory less of a problem on 64-bit). I should look up the code I once created to have a custom TCustomMemoryStream descendant that uses VirtualAlloc to reserve the memory to use. Then again, it's not that difficult, the memory allocation itself happens in a virtual method you can override, if I remember correctly. Windows internally has a special trick you can use when you want 2MiB-blocks or multiple's: it enters them differently in the virtual memory mapper so it takes less steps to translate the virtual address to the physical address. If it's performance you want you should check it out. (see MEM_LARGE_PAGES here)
  11. stijnsanders

    New FastCGI for Nginx in Delphi

    I really should make time to take a close look at this one! I've struggled before to get FastCGI into xxm and settled on plain CGI (yuck) and SCGI to interface with (advanced) http services that I couldn't find a specific API for like nginx or lighttpd.
  12. stijnsanders

    Error with PrivateKey

    I've been using WinSCP to perform SFTP where I needed it. The software runs on servers under my control, so it's no problem to have WinSCP installed there. If you call CreateProcess on WinSCP.com with the /nointeractiveinput and the correct command line parameters, you can have a series of command complete and give predictable output you can process.
  13. stijnsanders

    app logins

    I've given this quite some thought. I've made a list once here (it's in Dutch though) what you should do if you want a full fledged account management platform with login, and that's even before GDPR, and not handling what's available from other platforms, e.g. with OAuth or identity services from cloud providers that are available nowadays. I haven't worked with IntraWeb or TMS Web Core, but I've dabbled with a Delphi-(compiler-)based web-platform of my own, with an explicit emphasis on speed, security and portaility (between hosting environments), so yes if you want to build something serious you need user control and it takes some work. For a first big xxm application/website of my own: tx I for now stick to this list I created of everything I think a website with user accounts should have. But for new websites it's increasingly interesting to skip the hard work and make your website depend on a number of options you can expect your users to have an account with: Google, Facebook, Twitter, Microsoft, and if your public is somewhat tech savvy Github. (I should check if reddit has an OAuth api...)
  14. stijnsanders

    QUIC and HTTP/3

    Ah, well here's the interesting thing... Google, who started QUIC as a HTTP/3 proposed successor, kind-of passed it on to that standards body (is it WHATWG? or W3C, I forget en should look it up), and there it kind of took a turn so that QUIC would be more of a kind of like a successor to TCP+TLS but not really but yes really, especially to have HTTP over QUIC instead of TCP+TLS, and have that be HTTP/3 so that you would still have multiplexed streams, but the multiplexing is really done by the layer that does the packet re-ordering that was previously locked in the TCP protocol... So a QUIC library in Delphi? Yes I would like that, but it's quite a big task: it requires crypto by design, sadly enough, so yes it would be nice to see that in future OpenSSL/LibreSSL releases, especially because I've also read that there are parts of the congestion avoidance algorithms that are easy to get wrong or lingering bugs with, as you would need to test them on elaborate networking laboratory set-ups to have then duty-tested and benchmarked... let alone certified for fitness for production... So I'm willing to wait a little.
  15. stijnsanders

    JSON woes

    If anyone cares to try another alternative, I've created my own JSON handler, based on work I had done before to handle BSON for a rough-and-raw handler for MongoDB: https://github.com/stijnsanders/jsonDoc#jsondoc I really dislike long lists of overloads, so it extensively uses Delphi's own Variant type. It also tries to prevent too much allocation of Variant instances. If you need to process identical or similar JSON objects in sequence, re-use the same instance to re-use the allocated keys and values.