Matthew Hipkin

[2017-01-10] Random Name Generator

Creates an XML file containing a list of random names and ages up to the value specified in TOTALCOUNT (line 10).

Requires FreePascal to build and for both firstnames.txt and surnames.txt to be in the same directory.

Building

After installing FreePascal, simply run the following command to build:

# fpc createnameslist.pas

Then execute the created createnameslist[.exe] binary.

Example output (TOTALCOUNT = 3):

<?xml version="1.0" encoding="UTF-8" ?>
<people>
  <person>
    <firstname>Leonard</firstname>
    <surname>Walker</surname>
    <age>68</age>
  </person>
  <person>
    <firstname>Lisa</firstname>
    <surname>Paterson</surname>
    <age>51</age>
  </person>
  <person>
    <firstname>Christopher</firstname>
    <surname>Harris</surname>
    <age>7</age>
  </person>
</people>

For the latest version of the source and the required text files, visit github.

[2017-01-09] Follow HTTP redirects using Ararat Synapse

Here is a nice and simple way to follow HTTP redirects using the Ararat Synapse THTTPSend class.

program followredirect;
{$mode objfpc}{$H+}
uses Classes, SysUtils, httpsend;

function HTTPGet(URL: String; UserAgent: String): String;
var
  HTTP: THTTPSend;
  l: TStrings;
  i: Integer;
  realurl: String;
begin
  // Setup
  HTTP := THTTPSend.Create;
  HTTP.UserAgent := UserAgent;
  realurl := '';
  l := TStringList.Create;
  // Perform HTTP request
  if HTTP.HTTPMethod('GET', URL) then
  begin
    // If its a 301 or 302 we need to do more processing
    if (HTTP.ResultCode = 301) or (HTTP.ResultCode = 302) then
    begin
      // Check the headers for the Location header
      for i := 0 to HTTP.Headers.Count -1 do
      begin
        // Extract the URL
        if Copy(HTTP.Headers[i], 1, 8) = 'Location' then
          realurl := Copy(HTTP.Headers[i], 11, Length(HTTP.Headers[i]) - 11);
      end;
      writeln('Redirecting to ', realurl);
      // If we have a URL, run it through the same function
      if Length(realurl) > 1 then l.Text := HTTPGet(realurl, UserAgent);
    end
    else l.LoadFromStream(Http.Document);
  end;
  // Return result
  Result := l.Text;
  // Clean up
  HTTP.Free;
  l.Free;
end;

procedure main;
var
  response: String;
  url: String;
begin
  url := 'http://matthewhipkin.co.uk';
  writeln('Checking ', url);
  response := HTTPGet(url, 'Mozilla/5.0 (X11; FreeBSD amd64; rv:50.0) Gecko/20100101 Firefox/50.0');
  //writeln(response);
end;

begin
  main;
end.

Tested with FreePascal 3.0.0 but should work fine on Delphi.

[2017-01-04] Simple Sitemap Creator 1.3.2 released

Changelog
---------
1.3.2   Fixed blank useragent
        Added XiControls to about dialog
        Rewrote multithreading so it's done properly
        Fixed parsing issues with links starting ./
1.3.1   Added List tab which displays found links as a simple list
        Improved overall UI responsiveness and crawl speed
1.2.1   Improved speed related issues caused by 404 checking
1.2     Fixed update notification click
        Stopped 404s being parsed and listed
        Resolved issue with parsing of root links with filenames
1.1     Fixed saving of useragent history
        Fixed saving of URL history
        Attached return key to URL textbox
1.0     Recreated project files based on Lazarus 1.5 format
        Added option to set useragent
        Added option to disable custom theme
        Added option to change editor font
        Added option to customise filetypes to be ignored
        Changed ReadMe to DOS format
0.1.9   Fixed HTTPS bug
0.1.8   More improvements to HTML parsing
        Added CSV output
        Fixed issues with anchor links
	Resolved some issues with relative links 
0.1.7   Fixed problem of parsing links that contain anchors
        Added ignore for skype: links
        Added simple sort
0.1.6   Fixed inclusion of lone anchors in output
        Fixed last known HTML parsing bugs
        Removed alpha status
0.1.5   Improved HTML parsing again
0.1.4   Added XML output
0.1.3   General bug fixes
0.1.2   UI improvements
0.1.1   Improved HTML parsing
0.1     First release

[2017-01-01] At it again

Well, as it's a new year I thought I'd have a go at this blogging lark.

Every so often I might have a thought or two about some random subject, and who knows I might even manage to post about it here!

I'm still fiddling with the system - I always liked having the latest application releases on the home page so need to decide how I'm going to integrate those into the blog.

Flag Counter