Archive

Archive for July, 2018

Automatically post #domain name ideas to #Twitter

Domain-Checker

This is a script in c# that runs a Twitter Bot that posts domain name ideas to https://twitter.com/dotcomideas 

First, I generate some random pronouncable words using this class

using System;

namespace words
{
class PasswordGenerator
{
//string vowels = “aeiou”;
//string consonants = “bcdfghjklmnprstvwxyz”;

/*
The reason for the duplicate letters is to add “weighting” to certain letters to allow them more chance
of being randomly selected. This is due to the fact that certain letters in the English language are more
frequently used than others.

The breakdown of usage is as follows (from most frequent to least frequent):
1. E (7)
2. T (6)
3. A, O, N, R, I, S (5)
4. H (4)
5. D, L, F, C, M, U (3)
6. G, Y, P, W, B (2)
7. V, K, X, J, Q, Z (1)
*/

string vowels = “aaaaaeeeeeeeiiiiiooooouuu”;
string consonants = “bbcccdddfffgghhhhjklllmmmnnnnnpprrrrrsssssttttttvwwxyyz”;

string[] vowelafter = { “th”, “ch”, “sh”, “qu” };
string[] consonantafter = { “oo”, “ee” };
Random rnd = new Random();

public string GeneratePassword(int length)
{
string pass = “”;
bool isvowel = false;

for (int i = 0; i < length; i++)
{
if (isvowel)
{
if (rnd.Next(0, 5) == 0 && i < (length – 1))
{
pass += consonantafter[rnd.Next(0, consonantafter.Length)];
}
else
{
pass += vowels.Substring(rnd.Next(0, vowels.Length), 1);
}
}
else
{
if (rnd.Next(0, 5) == 0 && i < (length – 1))
{
pass += vowelafter[rnd.Next(0, vowelafter.Length)];
}
else
{
pass += consonants.Substring(rnd.Next(0, consonants.Length), 1);
}
}
isvowel = !isvowel;
}
return pass;
}
}
}

Then I check that the domain ( word + .com ) is available using the WhoApi api and Newtwonsoft Json

var strUrl = “http://api.whoapi.com/?apikey=&#8230;..&r=taken&domain=” + word + “.com”;
WebClient wc = new WebClient();
var strJson = wc.DownloadString(strUrl);
var jResult = JObject.Parse(strJson);
var blnTaken = (jResult[“taken”].ToString() != “0”);

As part of the process, I want to post an image of the new domain name;

FontFamily fontFamily = new FontFamily(“Arial”);
Font font = new Font(
fontFamily,
45,
FontStyle.Regular,
GraphicsUnit.Pixel);
var img = DrawText( word + “.com”, font, Color.DarkOrchid, Color.Beige);
var strPath = Directory.GetCurrentDirectory();
var tempFile = strPath + @”\temp.jpg”;
img.Save(tempFile, ImageFormat.Jpeg);

Where drawtext is as follows

private static Image DrawText(String text, Font font, Color textColor, Color backColor)
{
//first, create a dummy bitmap just to get a graphics object
Image img = new Bitmap(1, 1);
Graphics drawing = Graphics.FromImage(img);

//measure the string to see how big the image needs to be
SizeF textSize = drawing.MeasureString(text, font);

//free up the dummy image and old graphics object
img.Dispose();
drawing.Dispose();

//create a new image of the right size
img = new Bitmap((int)textSize.Width, (int)textSize.Height);

drawing = Graphics.FromImage(img);

//paint the background
drawing.Clear(backColor);

//create a brush for the text
Brush textBrush = new SolidBrush(textColor);

drawing.DrawString(text, font, textBrush, 0, 0);

drawing.Save();

textBrush.Dispose();
drawing.Dispose();

return img;

}

Then it is posted to Twitter using code;

var twitter = new SendTweet(
ConsumerKey,
ConsumerKeySecret,
AccessToken,
AccessTokenSecret
);

string response = twitter.PublishToTwitter(word + “.com is available #” + word + ” – register it at https://www.namesilo.com/register.php?rid=c233459im&#8221; , tempFile);

Categories: Uncategorized

#API to retrieve vehicle information from #IOM registered number plates

uk-island-iom4

The Isle of man is a small island between UK and Ireland, with just over 65,000 registered vehicles. However, up to now, vehicles registered in the IOM fell outside the data returned by the API https://www.regcheck.org.uk 

Following a customer enquiry, we added a bespoke API to allow vehicle data to be determined from an IOM registered plate via the following endpoint;

https://www.regcheck.org.uk/api/bespokeapi.asmx?op=CheckIOM

This API returns data in the following format;

{
“Description”: “HONDA JAZZ”,
“RegistrationYear”: 2012,
“CarMake”: {
“CurrentTextValue”: “HONDA”
},
“CarModel”: {
“CurrentTextValue”: “JAZZ”
},
“EngineSize”: {
“CurrentTextValue”: “1339”
},
“FuelType”: {
“CurrentTextValue”: “PETROL”
},
“MakeDescription”: {
“CurrentTextValue”: “HONDA”
},
“ModelDescription”: {
“CurrentTextValue”: “JAZZ”
},
“Version”: “I-VTEC ES”,
“Colour”: “SILVER”,
“Co2”: “126”,
“RegistrationDate”: “06/07/2012”,
“WheelPlan”: “2-AXLE Rigid”,
“Taxed”: “Active”,
“TaxExpiry”: “31/07/2018”,
“ImageUrl”: “https://www.regcheck.org.uk/image.aspx/@SE9OREEgSkFaWg==
}

If the number plate matches one of the following patterns listed below, it will be returned in IOM format, rather than the standard UK format.

Pool Registration Number Example Notes
1 MN-(1-9999) MN-543
2 MAN-(1-9999) MAN-8947
3 MAN-(1-999)-X MAN-23-T Excluding x = I, O, Q, S, Z
4 xMN-(1-999) JMN-129 Excluding x = A, I, Q, S, Z
5 xMN-(1-999)-y GMN-423-K Excluding x = A, I, Q, S, Z and y = I, O, Q, S, Z
6 (1-999)-xMN 582-PMN Excluding x = A, I, Q, S, Z
7 (1-9999)-MN 39-MN
8 (1-9999)-MAN 284-MAN
9 X-(1-9999)-MAN F-3-MAN Excluding x = I, Q, S, Z
10 MANX-(1-999) MANX-471
11 (1-999)-MANX 471-MANX

 

Categories: Uncategorized