Archive for November, 2021

Remove the background from an Image using C#

Instead of manually processing images, and cutting out the subject from the background, you can use an API to do this, as long as the image is publicly accessible via a URL – Even temporarily accessible, you could upload to S3, then delete it again afterwards.

Here’s the code – in C#

var url = "";

var oReq = new { url = "" };

var strReq = JsonConvert.SerializeObject(oReq);

using var web = new WebClient();
web.Headers.Add("x-rapidapi-key", "xxxxxx");
var response = web.UploadData(url, "POST", Encoding.UTF8.GetBytes(strReq));
var b64Response = Convert.FromBase64String(Encoding.UTF8.GetString(response));
File.WriteAllBytes("result3.png", b64Response);

Where the API Key can be found here:

Categories: Uncategorized

Extract a License Plate from an Image #ALPR

ALPR – Or Automatic License Plate Recognition is the process of extracting the textual elements of a License Plate from an image. For example, reading the text FL802FJ from the image shown above.

Here is an API on Rapid API that offers a simple API that reads the license plate from an image of a car when provided via a URL:

You make a HTTP POST request to the following endpoint:

With the JSON Body;


And the x-rapidapi-key set in the HTTP Headers.

Which results in the following:

    "processing_time": 147.311,
    "results": [
            "box": {
                "xmin": 896,
                "ymin": 307,
                "xmax": 1067,
                "ymax": 411
            "plate": "fl802fj",
            "region": {
                "code": "fr",
                "score": 0.621
            "score": 0.898,
            "candidates": [
                    "score": 0.898,
                    "plate": "fl802fj"
                    "score": 0.897,
                    "plate": "fl8o2fj"
                    "score": 0.777,
                    "plate": "flb02fj"
                    "score": 0.775,
                    "plate": "flbo2fj"
            "dscore": 0.729,
            "vehicle": {
                "score": 0.759,
                "type": "Sedan",
                "box": {
                    "xmin": 130,
                    "ymin": 3,
                    "xmax": 1148,
                    "ymax": 690
    "filename": "1214_OkT6R_93b5bdbc-09af-47c4-b1a7-14109ed988ae.jpg",
    "version": 1,
    "camera_id": null,
    "timestamp": "2021-11-25T12:14:00.429055Z"
Categories: Uncategorized

Saying goodbye to old websites

It’s probably hard to believe for certain people, but you do generally get attached to websites, something that you’ve created, and perhaps has paid you back a thousand fold, but some day, it no longer becomes relevant, and it’s time to say goodbye to it.

Some parting words for some of my websites that meant something to me ..

My very first domain, which I thought, at the time, was a cool mix between “Web” and “Entropy”. It made no sense to anyone else. But It was back in 2002, I was just out of University, and the £20 investment in a domain was a lot to me back then. It paid me back a hundred fold, once earning as much as $5,000 a month in advertisement (yes, it was spammy and ugly). But, it didn’t last long, and I guess about 2005 it slipped out of relevance, and was never revisited again.

My first really successful business, I remember it used to bring in 10,000 people a day, peaking on new-years-eve. It used to make a steady £10K a month, with sources from all over the world. Mostly the UK, but I remember selling as far afield as Serbia. One day, a google update killed my SEO position across the board, and the business was over, I think around 2010. It never recovered, and the whole concept of communicating via SMS is only for 2FA and grandmothers who never got a smartphone.

But, it’s time to say goodbye, adieu, and so long and thanks for all the fish.

Categories: Uncategorized

Using HTTP/2 from #AWS Lambda in .NET Core

If you need to make an outbound HTTP request using HTTP/2 instead of HTTP/1.1 then you will need to modify your HTTP request in C# to do so, since it is not the default. If you are working in a windows environment, then you may have used code such as the following to perform a HTTP/2 request;

public class Http2CustomHandler : WinHttpHandler
{ // PM> Install-Package System.Net.Http.WinHttpHandler - REQ .NET 4.6.2 +
	protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
		request.Version = new Version("2.0");
		return base.SendAsync(request, cancellationToken);

Which requires the System.Net.Http.WinHttpHandler NUGET package.

However, if you try to use this code in .NET core, and run it on a non-Windows platform, such as AWS Lambda, then you get an error such as;

System.PlatformNotSupportedException: WinHttpHandler is only supported on .NET Framework and .NET runtimes on Windows. It is not supported for Windows Store Applications (UWP) or Unix platforms.
at System.Net.Http.WinHttpHandler..ctor()

There is a workaround, in .NET Core 3 (Which is supported by AWS Lambda), where you can simply specify the HTTP Version in the HTTPRequest object

var initialRequest = new HttpRequestMessage(HttpMethod.Get, strUrl)
	Version = new Version(2, 0)

var homepage = httpClient.SendAsync(initialRequest ).Result.Content.ReadAsStringAsync().Result;

Much simpler!

Categories: Uncategorized

License Plate #API available in #Canada with

Canada has a population of 38 million, with a car ownership ratio of 87%, meaning an estimated 33 million cars drive on Canada’s streets, and we’ve just launched an API that will allow business users determine the Make, Model, VIN , Fuel, Transmission, and other technical details from the license plate of the vehicle.

This API can be used for many different scenarios such as;

  • Auto Insurance: Faster and externally verified customer onboarding. Less customer-drop off while entering their vehicle data. Customers are more likely to know their own license plate, than their own VIN number. Plus you can be sure that the customer is not entering misleading information about their vehicle.
  • Car parts: Less mis-ordered parts, and added confidence in the order process for consumers. Customers can get their vehicle details incorrect, or ask you to order parts that are not suitable for their vehicle. Instead of wasting time and money returning incorrect parts to suppliers, using a vehicle license plate lookup can help ensure you are buying the correct parts, first time round. It also helps boost consumer confidence in the order process, they know they are buying a part specifically for THEIR car, not just a part that hopefully will fit!
  • Second hand car sales: Make it easy for sellers to quickly add their vehicle to your sales portal. If you are tracking more visitors to your “sell your car” page, than actually list a car for sale, then you have a customer drop off. A few percentage points is always unavoidable, but if you’re loosing 10%, 20%, 50% of potential sellers because you are not capturing information from them in an engaging way?, use this API to engage with sellers, and be the first to list their vehicle for sale and earn your commission.

Go to to read more.

Car registration plates in Canada use the /CheckCanada  endpoint and return the following information:

  • Make / Model
  • VIN Number
  • Body / Trim
  • Transmission 
  • Fuel

Both a License plate and a State are required, where the state is a two letter code as follows;

British ColumbiaBC
New BrunswickNB
Newfoundland and LabradorNL
Nova ScotiaNS
Northwest TerritoriesNT
Prince Edward IslandPE

Sample Registration Number: 

CKST441 (ON)

Sample Json:


  “Description”: “Toyota C-HR”,

  “RegistrationYear”: “2020”,

  “CarMake”: {

    “CurrentTextValue”: “Toyota”


  “CarModel”: {

    “CurrentTextValue”: “C-HR”


  “MakeDescription”: {

    “CurrentTextValue”: “Toyota”


  “ModelDescription”: {

    “CurrentTextValue”: “C-HR”


  “ImageUrl”: “;,

  “Body”: “Sport Utility”,

  “Transmission”: “Automatic CVT”,

  “Drive”: “FWD”,

  “Trim”: “”,

  “VIN”: “JTNKHMBX8L1063053”,

  “Engine”: “2.0L L4 DOHC 16V”,

  “Fuel”: “Gasoline”


Categories: Uncategorized

#OpenSource list of disposable temporary email providers.

We’ve just compiled a list of 35,000 temporary email domains, with their associated MX-Records (Mail Exchange servers) and IP addresses associated with the MX-Records. This should allow users to not only block known temporary email address domains, but to discover future domains. It’s easier to register a new domain than to get a new IP address and Mail Exchanger.

You can download this file at GITHUB here;


A CSV of temporary email domains with their associated MX Records, in the format

DomainMX RecordIP

Where Domain is a domain name associated with a temporary email address such as the MX record is a Mail-exchange server associated with that domain, and the IP is the IP of the Mail-exchange server.

Blocking user registrations if temporary email addresses are used can be risky, you can end up blocking a legitimate user.

If you block emails using the domain listed in the domain column, then it is very likely the email is temporary, but fresh “disposable” domains will not be discovered.

If you block emails using a domain that uses the same mail exchanger as the mx-record listed in the “MX column” then this is highly risky, since many legitimate russian users use “”, (yandex being the russian equivalent of Google). However patterns of dispostable emails can be discovered and blocked on a case by case basis.

This is an open-source list and we do invite users to contribute by raising pull requests. Please give credit to our work, if you use it.

Categories: Uncategorized

Open Source multilingual #CookieBanner script for #Bootstrap

Under Article 5 Paragraph 3 of the EU ePrivacy Directive (Directive 2009/136/EC) and respective implementations of the Directive into national law of the EU member states, the setting of individual cookies on the user’s terminal equipment that are not strictly necessary for the functioning of the website is only allowed if the user has given his or her prior consent.

Which translated into normal-speak, is that you should ask your users to consent to cookies before you place them on your user’s browser.

While we develop this for our own website, we’ve open-sourced the work, to invite others to perfect, what we’re working on.

Please feel free to Fork, or submit a pull request at if you want to suggest changes or improvements.

Supports the following languages;

English, Czech, Danish, German, Greek, Spanish, Estonian, Finnish, French, Hebrew, Croatian, Hungarian, Islandic, Italian, Latvian, Norwegiam, Dutch, Portuguese, Russian, Slovak, Slovenian, and Ukrainian

With automatic browser-language detection.

Categories: Uncategorized

Automatically translate RESX Resource files using #Azure Cognitive Translator in C#

You should always have your RESX files manually translated by a professional translator, but if you’re in a hurry and quality is less important than speed, then you can use an automated translator. But be warned, you could be saying silly text on your website.

So, given a source, English text Resx, and an output file, we’ll say in Russian, we can define our main method as follows;

static void Main(string[] args)
	var inputFile = @"C:\Users\fiach\Desktop\Strings.en-NZ.resx";
	var outputFile = @"C:\Users\fiach\Desktop\";
	var inputXml = File.ReadAllText(inputFile);
	var xDoc = new XmlDocument();
	var dataNodes = xDoc.SelectNodes("//data");
	foreach (XmlNode dataNode in dataNodes)
		var english = dataNode.SelectSingleNode("value").InnerText;
		var russian = Translate(english, "en", "ru");
		dataNode.SelectSingleNode("value").InnerText = russian;
	File.WriteAllText(outputFile, xDoc.InnerXml);

Then, we implement the Translate method as follows;

public static string Translate(string text, string fromLanguage, string toLanguage)
		const string strKey = "**************";
		ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 |
											   SecurityProtocolType.Tls |
											   SecurityProtocolType.Tls11 |
		var url = string.Format("{0}&from={1}", toLanguage, fromLanguage);
		var wc = new WebClient();
		wc.Headers["Ocp-Apim-Subscription-Key"] = strKey;
		wc.Headers["Ocp-Apim-Subscription-Region"] = "westeurope";
		wc.Encoding = Encoding.UTF8;
		var jPost = new[] { new { Text = text } };
		var post = JsonConvert.SerializeObject(jPost, Newtonsoft.Json.Formatting.Indented);
		wc.Headers[HttpRequestHeader.ContentType] = "application/json";
		var json = "";
			json = wc.UploadString(url, "POST", post);
		catch (WebException exception)
			string strResult = "";
			if (exception.Response != null)
				var responseStream = exception.Response.GetResponseStream();
				if (responseStream != null)
					using (var reader = new StreamReader(responseStream))
						strResult = reader.ReadToEnd();
			throw new Exception(strResult);
		var jResponse = JArray.Parse(json);
		var translation = jResponse.First["translations"].First["text"].ToString();
		return translation;
		return text;

You also need the Newtonsoft.JSON Nuget package for this, and an API key too!

Categories: Uncategorized

Automatically add #Sedo verification to a batch of domain names using #NameCheap #API

If you are listing domains on Sedo, it’s likely that you have a number of domains, and perhaps instead of going through the process of manually adding the CNAME record to every domain, you can use NameCheap’s API in C# to automatically add CNAME records.

This is a follow-on to the previous blog post, shown below; Classes mentioned in this post will not be repeated, so you should follow this first;

Given a list of domains in a text file (one domain per line), add this to the project with the build action “copy always”.

var domains = File.ReadAllLines("domainList.txt");
foreach (var domain in domains)
	var domainTld = Regex.Match(domain, @"\.\w+$").Value;
	var domainWithoutTld = domain.Replace(domainTld, "");
	domainTld = domainTld.Substring(1);
	var hosts = GetHostsFromDomain(domainWithoutTld, domainTld);
	hosts.Add(new HostRecord { Name = "***ID***", Type = "CNAME", Value = "" });
	SetHostRecords(domainWithoutTld, domainTld, hosts);

Where evidently ***ID*** is replaced with your own personal ID from Sedo. The one second delays are to help prevent throttling, which the NameCheap API uses to prevent abuse.

And, if you’re interested, this is the list of domains that is going on sale;

Categories: Uncategorized
%d bloggers like this: