

PeterPanettone
Members-
Content Count
1418 -
Joined
-
Last visited
-
Days Won
5
Everything posted by PeterPanettone
-
Reliable method for getting the FavIcon URL?
PeterPanettone posted a topic in ICS - Internet Component Suite
I am using Google’s favicon service (https://www.google.com/s2/favicons?domain=...) to get the FavIcon URL of a website/internet-domain (e.g., https://www.cnpack.org -> https://www.cnpack.org/favicon.ico), as the FavIcon URL is not always Website URL + /favicon.ico. Unfortunately, Google seems to apply rate limits to this: When doing this in a batch for many different websites/internet-domains, there is a rate limit warning after 55 or 56 requests: My question is: Does the ICS library have a reliable method to retrieve the FavIcon URL of a domain that is not subject to rate limits? -
Reliable method for getting the FavIcon URL?
PeterPanettone replied to PeterPanettone's topic in ICS - Internet Component Suite
This gave me the highest success rate so far: function FileExistsOnWeb(const URL: string): Boolean; var HTTPClient: System.Net.HttpClientComponent.TNetHTTPClient; Response: System.Net.HttpClient.IHTTPResponse; begin Result := False; HTTPClient := System.Net.HttpClientComponent.TNetHTTPClient.Create(nil); try try // Reasonable redirect limit to prevent infinite loops HTTPClient.MaxRedirects := 10; // Reduced from 20 HTTPClient.HandleRedirects := True; // Shorter timeouts to fail fast on problem URLs HTTPClient.ConnectionTimeout := 3000; // 3 seconds HTTPClient.ResponseTimeout := 3000; // 3 seconds Response := HTTPClient.Head(URL); Result := (Response.StatusCode = 200); except // Catch ALL exceptions including redirect errors on E: Exception do Result := False; // Silently fail - let caller try next URL end; finally HTTPClient.Free; end; end; function GetFavIconURL(const AURL: string): string; // gets the FavIcon URL from AURL var URI: System.Net.URLClient.TURI; Host: string; PossibleURLs: TArray<string>; URL: string; begin Result := ''; // Default to empty string if none found URI := System.Net.URLClient.TURI.Create(AURL); Host := URI.Host.ToLower; // Try multiple common favicon locations in order of likelihood PossibleURLs := [ // 1. Standard favicon (most common) Format('%s://%s/favicon.ico', [URI.Scheme, Host]), // 2. PNG version (increasingly common, better quality) Format('%s://%s/favicon.png', [URI.Scheme, Host]), // 3. SVG version (modern, scalable) Format('%s://%s/favicon.svg', [URI.Scheme, Host]), // 4. Apple touch icon (often high quality, 180x180 or larger) Format('%s://%s/apple-touch-icon.png', [URI.Scheme, Host]), // 5. Alternative Apple icon name Format('%s://%s/apple-touch-icon-precomposed.png', [URI.Scheme, Host]), // 6. Google's favicon service as last resort (always works!) // Google caches favicons from websites Format('https://www.google.com/s2/favicons?domain=%s&sz=128', [Host]) ]; // Test each URL and return the first one that exists for URL in PossibleURLs do begin if FileExistsOnWeb(URL) then Exit(URL); end; // If nothing found, return Google's service as ultimate fallback // This ensures you ALWAYS get something, even if it's a generic icon Result := Format('https://www.google.com/s2/favicons?domain=%s&sz=128', [Host]); end; -
Reliable method for getting the FavIcon URL?
PeterPanettone replied to PeterPanettone's topic in ICS - Internet Component Suite
After guessing the FavIcon URL (https://www.cnpack.org -> https://www.cnpack.org/favicon.ico), we can check if it exists: function FileExistsOnWeb(const URL: string): Boolean; var HTTPClient: System.Net.HttpClientComponent.TNetHTTPClient; Response: System.Net.HttpClient.IHTTPResponse; begin // Default to False - assume file doesn't exist until proven otherwise: Result := False; // Create HTTP client component (nil = no owner, we'll manage memory manually): HTTPClient := System.Net.HttpClientComponent.TNetHTTPClient.Create(nil); try try // Increase max redirects to handle multiple server redirects // Default is 5, which may not be enough for some sites: //HTTPClient.MaxRedirects := 10; HTTPClient.MaxRedirects := 20; // Very generous limit // Enable automatic handling of redirects (should be default, but explicit is better): HTTPClient.HandleRedirects := True; // Set a reasonable timeout to prevent hanging (in milliseconds): HTTPClient.ConnectionTimeout := 5000; // 5 seconds HTTPClient.ResponseTimeout := 5000; // 5 seconds // HEAD method requests only HTTP headers, not the file content // This is much faster than GET because it doesn't download the actual file // For a favicon.ico, we save downloading ~1-50KB of data: Response := HTTPClient.Head(URL); // Status code 200 means "OK" - the file exists and is accessible // Other common codes: 404 (Not Found), 403 (Forbidden), 500 (Server Error): Result := (Response.StatusCode = 200); except // Catch network/HTTP exceptions (timeout, DNS failure, connection refused, etc.): on E: System.Net.HttpClient.ENetHTTPClientException do Result := False; // Any exception means we can't confirm file exists // Catch any other unexpected exceptions: on E: Exception do Result := False; end; finally // Always free the HTTP client to prevent memory leaks // This runs even if an exception occurs: HTTPClient.Free; end; end; -
Reliable method for getting the FavIcon URL?
PeterPanettone replied to PeterPanettone's topic in ICS - Internet Component Suite
Hi Angus, thanks for the answer. I didn't ask for a method to access Google APIs, as I already have one. Does the ICS have ANOTHER technique to get the FavIcon URL? -
Reliable method for getting the FavIcon URL?
PeterPanettone replied to PeterPanettone's topic in ICS - Internet Component Suite
Thanks for the friendly hint. However, IMO, this is a guessing and is far from reliable when scanning many different sites. Currently, I am using this function, which leads to the warning when requested several times: function GetFavIconURL(const AURL: string): string; const DEFAULT_SIZE = 64; // Define a default size var DomainOnly: string; //UrlParts: TURI; // TURI is a record, not a class, so no Free needed begin DomainOnly := System.NetEncoding.TNetEncoding.URL.Encode(AURL); // It's good practice to URL-encode the domain in case it has unusual characters, // though for standard domains it's often not strictly necessary. // For modern Delphi (10.3+), you can use TNetEncoding.URL.Encode (add NetEncoding to uses). // For older Delphi versions, you'd use TIdURI.URLEncode from Indy. // DomainOnly := TNetEncoding.URL.Encode(DomainOnly); // Uncomment if needed // Now, construct the Google Favicon service URL using the extracted domain: Result := Format('https://www.google.com/s2/favicons?sz=%d&domain=%s', [DEFAULT_SIZE, DomainOnly]); //Clipboard.AsText := Result; end; -
Suggestion: InterBase Desktop Community Deployment License (up to 999 free deployments)?
PeterPanettone posted a topic in Databases
Developer Benefits Low Barrier to Entry: Developers could actually deploy small-scale desktop apps using InterBase without worrying about licensing costs until their product gains traction. Encourages Ecosystem Use: More developers would choose InterBase instead of bundling SQLite, Firebird, or other free engines — especially when starting small projects or prototypes. Smooth Scaling Path: Once a developer exceeds 999 deployments, paying for a commercial license would feel natural — they’d already be invested in InterBase and likely earning revenue. Better Integration: InterBase is deeply integrated into Delphi (e.g., FireDAC, IBX, RAD Server). Giving developers an affordable way to ship with it would strengthen the “Delphi stack” story. 🧭 Embarcadero’s Strategic Benefits Increased Market Adoption: Free/low-tier deployments would drastically expand InterBase’s presence in real-world applications, especially among small ISVs and consultants. Future Paid Upgrades: Once developers and customers rely on InterBase, it becomes easier to justify upgrades to full Server or ToGo editions. Competitive Positioning: Competitors like Firebird and PostgreSQL are completely free. Without a similar entry-level offer, developers naturally default to them — even within Delphi. Brand Reinforcement: A “999-deployment free” edition would show goodwill and support toward indie developers — something that strengthens the overall perception of Delphi and Embarcadero as developer-friendly. ⚙️ Possible Implementation Edition: InterBase Desktop Community Limit: Up to 999 deployments or 50 concurrent users Restrictions: No clustering, no encryption, etc. Automatic upgrade path to paid license. -
Does anyone have an updated version of wuppdi Welcome Page for Delphi 11 Alexandria?
-
On my large screen, the menu font was very small after installation. So I increased the User Interface font size to 12: A restart of the IDE was needed to see the changes. But now the text size on the welcome screen is ridiculously large, while the menu text size is just right: Isn't there a way to set the font size of the menu separately? That would be what we call USER-FRIENDLY.
-
A simple Code Editor trick to quickly jump to predefined locations in a huge unit
PeterPanettone posted a topic in General Help
OK, here is another simple trick I often use to quickly jump to specific locations in very large units (e.g., 20,000 lines, like in my upcoming "Advanced Windows Start Menu"): We could use simple bookmarks for this purpose, but I often clear them all after finishing a specific short-term task. So we need something more persistent:* *Prerequisites: CnWizards 1. Create these kinds of comments on the locations you want to jump to quickly: implementation // toc_implementation public // toc_public // toc_PrivateVariables private // toc_private TForm1 = class(TForm) // toc_MainFormClass // etc. 2. Then put all these TOC items at the very top of your huge unit: {TOC: toc_implementation toc_public toc_PrivateVariables toc_private toc_MainFormClass } 3. Then, when you need to quickly jump to one of these locations in your huge unit: - Press CTRL+Home to jump to the top of the unit - Double-click one of the toc_ items to select it - Press F3 to quickly jump to this location This will save you a lot of search time! -
A simple Code Editor trick to quickly jump to predefined locations in a huge unit
PeterPanettone replied to PeterPanettone's topic in General Help
I've set it again to 255, and the error message didn't appear again. I will re-examine MMX settings, as it seems that new features have been added since my previous version. Thanks again for MMX! This is a great piece of software that adds features to the Delphi IDE that Embarcadero didn't have time to implement. BTW, a new feature coming to my mind: Create a table that lists how many times and where (link) each method is used. This would also allow the user to find methods not used at all. -
A simple Code Editor trick to quickly jump to predefined locations in a huge unit
PeterPanettone replied to PeterPanettone's topic in General Help
Thank you! However, when I set it to 255, I get this error message: So I have set it to 250, which gives me almost complete opacity. -
A simple Code Editor trick to quickly jump to predefined locations in a huge unit
PeterPanettone replied to PeterPanettone's topic in General Help
This is a very nice feature - thank you for that! The list showing the references is semi-transparent, which hinders readability. Is it possible to switch the list transparency off? -
New Delphi features in Delphi 13
PeterPanettone replied to David Heffernan's topic in RTL and Delphi Object Pascal
It is available from this URL: https://www.embarcadero.com/RADAICompanion -
Still angry with jokes? Please calm down.
-
In GetIt, the IPWorks component library is not explicitly marked as "TRIAL": Can it be used for free when downloading it from GetIt? At the IPWorks homepage, the IPWorks component library can be purchased for $999.
-
On the other hand, the Bonus KSVC 8.0.1 library, which is freely available to Delphi Subscription users, has not yet appeared in GetIt.
-
Someone said: "It can be considered unfair to offer a trial download of IPWorks in Embarcadero's GetIt Package Manager without explicitly marking it as a "Trial," primarily due to inconsistencies in labeling that may mislead developers about its licensing and usage restrictions."
-
A simple Code Editor trick to quickly jump to predefined locations in a huge unit
PeterPanettone replied to PeterPanettone's topic in General Help
CnWizards is a very helpful Delphi IDE plugin with many useful features, among them the above-mentioned F3 SEARCH feature: https://www.cnpack.org/index.php?lang=en Here is the option to activate this feature: -
A simple Code Editor trick to quickly jump to predefined locations in a huge unit
PeterPanettone replied to PeterPanettone's topic in General Help
I've found it: F3 automatically searches the next occurrence of the selected text only if CnWizards is installed. I've tested it by unloading CnWizards. When CnWizards is not loaded, then F3 on the selected text displays this message: And then, when clicking the "Yes" button after having checked "Wrap around without asking", this message is displayed: This could be a bug in the Delphi IDE that CnWizards resolves. -
A simple Code Editor trick to quickly jump to predefined locations in a huge unit
PeterPanettone replied to PeterPanettone's topic in General Help
It doesn't?? In my Delphi 12.2 and Delphi 13, it does! This is very strange! -
A simple Code Editor trick to quickly copy an entire procedure/function to the clipboard
PeterPanettone posted a topic in General Help
1. Collapse the procedure/function: 2. Click on the line number to select the entire (now hidden) code of the procedure/function. 3. Press CTRL+C to copy the entire code of the procedure/function. This is particularly useful for longer procedures/functions. It also works in Delphi 13. -
A simple Code Editor trick to quickly copy an entire procedure/function to the clipboard
PeterPanettone replied to PeterPanettone's topic in General Help
OK, here is another one: -
You are so right. That is exactly the right way to look at AI. Unfortunately, AI is also becoming a tool for political oppression. And thank you for the humorous part.
-
Do you think AI is becoming a new religion?
-
You are right, DOCUMENTATION is everything. AI-generated code without accompanying documentation is dangerous (SUPERGROK always links to documentation for anything it generates). However, I strongly reject "regulation" laws from a criminal organization as the so-called "EU" (EU ≠ Europe).