Archive

Author Archive

Our new #JobSearch #App, powered by @reedcouk #API

Categories: Uncategorized

Book Searcher App for #IOS, new version released

Categories: Uncategorized

#Visual #Transliteration from Russian in C#

1200x630bb

Transliteration is where you convert one alphabet into another while maintaining the phonetics in as much as possible.

Visual Transliteration is much more niche, and it about maintaining the visual representation of one alphabet in another, for example  “Н” in Russian is pronounced “N”, but looks visually identical to a Latin “H”.

This code is for VISUAL transliteration, and NOT audible transliteration.

private static string VisualTransliterate(string russian)
{
var map = new Dictionary<string, string>
{
{“а”, “a”},
{“б”, “b”},
{“в”, “B”},
{“г”, “r”},
{“д”, “A”},
{“е”, “e”},
{“ё”, “e”},
{“ж”, “x”},
{“з”, “3”},
{“и”, “N”},
{“й”, “N”},
{“к”, “k”},
{“л”, “n”},
{“м”, “M”},
{“н”, “H”},
{“о”, “o”},
{“п”, “n”},
{“р”, “p”},
{“с”, “c”},
{“т”, “T”},
{“у”, “y”},
{“ф”, “o”},
{“х”, “x”},
{“ц”, “u”},
{“ч”, “u”},
{“ш”, “w”},
{“щ”, “w”},
{“ъ”, “b”},
{“ы”, “b”},
{“ь”, “b”},
{“э”, “3”},
{“ю”, “H”},
{“я”, “R”},
{“А”, “A”},
{“Б”, “B”},
{“В”, “B”},
{“Г”, “R”},
{“Д”, “A”},
{“Е”, “E”},
{“Ё”, “E”},
{“Ж”, “X”},
{“З”, “3”},
{“И”, “N”},
{“Й”, “N”},
{“К”, “K”},
{“Л”, “N”},
{“М”, “M”},
{“Н”, “H”},
{“О”, “O”},
{“П”, “N”},
{“Р”, “P”},
{“С”, “C”},
{“Т”, “T”},
{“У”, “Y”},
{“Ф”, “O”},
{“Х”, “X”},
{“Ц”, “U”},
{“Ч”, “Y”},
{“Ш”, “W”},
{“Щ”, “W”},
{“Ъ”, “b”},
{“Ы”, “b”},
{“Ь”, “b”},
{“Э”, “3”},
{“Ю”, “H”},
{“Я”, “R”}
};
var strOutput = “”;
foreach (var c in russian)
{
if (map.ContainsKey(c.ToString()))
{
strOutput += map[c.ToString()];
}
else
{
strOutput += c.ToString();
}
}
return strOutput;
}

Categories: Uncategorized

#SMTP JS now supports non standard ports

Categories: Uncategorized

Using a #Cors #Proxy to call #API s from #Javascript

proxy-png

Javascript has always limited the ability to make arbitrary web requests to third parties, this has generally meant that projects required a server side component, even if its only purpose was to ferry data from a third party to the client.

CORS changed this somewhat, it allowed API service providers indicate to Javascript clients that it was OK for arbitrary web requests to be made to them, and the fact that any related security concerns were unimportant. – After all, any statically authenticated API would have the api key exposed in client code.

However some API providers don’t declare a CORS header. This can be down to security concerns, ignorance of Javascript clients, or just misconfiguration. That’s where a CORS proxy comes in. This is where a third party will do the connection for you, and it will declare the CORS header saying it’s OK to connect to them.

You can always develop this yourself, but a free public service is  https://cors-anywhere.herokuapp.com – which is open source on github here- https://github.com/Rob–W/cors-anywhere/

All you need to do it call https://cors-anywhere.herokuapp.com/<url> where <url> is the third party API. It passes basic authentication headers through, but you need to call it via AJAX, you can’t just paste it into a browser. This is to prevent service abuse.

Thanks Rob-W, whoever you are 🙂

Categories: Uncategorized

Comparison of Dedicated Windows Servers; for me @easyspace wins

dedicated-hosting-usa-image

A B C D E F G
1
Supplier Ref Memory Speed Disk Price / month (after 1st year, ex VAT) / GBP Url / notes
2
1and1 XL32 32 3.8 2TB 124.99
3
Ovh SP-32 32 4.2 2TB 60+17 = 77
4
coreix SC512L 16 3.5 1TB 144
5
Kimsufi KS-5 16 2 2TB 38 – NOT WINDOWS
6
easy

space

X5650 32 ? 4TB 79.99

Going to move server shortly, after a RAID failure in our 1&1 server, which we’ve had for just under 2 years. So I was looking for something similar, but a little better, than the 24GB 3.4 GHZ quad code 2TB server that (l4i) that we currently pay £80 ex VAT for each month.

Initially, I was just going to go for an upgrade with the same hosting company, but the jump from £80 to £125 seemed too much, even if it had more memory.

So, I hunted around. OVH had a very good deal alt £77, but for VAT reasons, I wanted to be billed from a UK company against our Irish VAT, so it could be zero rated. OVH had an Irish company, which was not what I wanted.

Kimsufi was very cheap, and uses OVH infrastructure, but it only offers Linux, which is no good.

IBM, Amazon, and Azure were way off the mark in terms of price so I didn’t include them.

Eventually I went with EasySpace, even though their online form didn’t work very well, and they take 48 hours to set up when OVH could set up in 2. – but I’m not in a huge rush.

Categories: Uncategorized

Car Registration #API now available on #Cocoapods #Swift

Screen Shot 2017-08-27 at 11.44.59

We’ve just packaged our Swift Module as a Cocoapod, and listed it on Cocoapods.org, you can access the GIT repo here https://github.com/infiniteloopltd/CarRegistrationPod

CarRegistrationPod

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

A wrapper for the Car Registration API in Swift. You will require a username and password from http://www.vehicleregistrationapi.com This API returns car details from a car number plate in many countries worldwide, including the UK, USA, Australia, India. A full list is shown below.

Installation

CarRegistrationPod is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "CarRegistrationPod"

Usage

import CarRegistrationPod
...
let dict = australia_lookup(registrationNumber: "YHC14Y", state: "NSW", username:"***your username***", password:"*** password ***")

label.text = dict["Description"] as? String

Other members of the car_registration package are

  • australia_lookup
  • usa_lookup
  • europe_lookup

Both australia and usa accept four parameters, registrationNumber, state, username and password, and returns a [String: Any] europe_lookup does not require the state parameter, but instead, requires a endpoint parameter, which can be one of the following strings;

  • Check (UK)
  • CheckBelgium
  • CheckCroatia
  • CheckCzechRepublic
  • CheckDenmark
  • CheckEstonia
  • CheckFinland
  • CheckFrance
  • CheckHungary
  • CheckIndia
  • CheckIreland
  • CheckItaly
  • CheckNetherlands
  • CheckNewZealand
  • CheckNigeria
  • CheckNorway
  • CheckPortugal
  • CheckRussia
  • CheckSlovakia
  • CheckSouthAfrica
  • CheckSpain
  • CheckSriLanka
  • CheckSweden
  • CheckUAE
  • CheckUSA
  • CheckAustralia

Author

Infinite loop Development ltd, http://www.infiniteloop.ie

License

CarRegistrationPod is available under the MIT license. See the LICENSE file for more info.

Categories: Uncategorized

Enable Remote access on #SQL server named instance

named-instance

You can install two instances of SQL server on the same machine, for example if you really needed to have two different versions of SQL server, or wanted to create a logically separated database where you could keep a near-identical copy of your main database.

Anyway, for whatever reason, if you do install two instances of SQL server on one server, you will quickly find that the default port number 1433 is occupied by the first SQL server, for local connections this doesn’t cause a problem, but for remote connections it does.

First, you have to pick a new port for the named instance. Open SQL server configuration manager, then select SQL Server Network Configuration, then SQLExpress (Or whatever you named your second instance), select TCP/IP, enable it, if it isn’t already. Then right click properties. Select the IP Addresses tab, and scroll to the IP (ALL) heading, remove the 0 from TCP Dynamic ports, and enter a number such as 1444 into the TCP port box. Open up services, and restart the service associated with the SQLExpress instance.

You may now need to open up TCP port 1444 on your firewall, and adjust your connection strings to <IP Address>\<Instance Name>,1444

 

 

Categories: Uncategorized

New #Swift3 Package published on #swiftModules @corydmc

swift

To help Swift developers integrate our API easily into their app, with just two lines of code, we’ve just published a wrapper for our Car Registration API on SwiftModules here

https://swiftmodules.com/infiniteloopltd/swiftcarregistrationapi

SwiftCarRegistrationAPI

A wrapper for the Car Registration API in Swift. You will require a username and password from http://www.vehicleregistrationapi.com This API returns car details from a car number plate in many countries worldwide, including the UK, USA, Australia, India. A full list is shown below.

Usage

Package.swift

import PackageDescription

let package = Package(
    name: "MyApp",
    targets: [],
    dependencies: [
        .Package(url: "https://github.com/infiniteloopltd/SwiftCarRegistrationAPI.git",
                  "1.0.1")
    ]
)

main.swift

import car_registration

let dict = australia_lookup(registrationNumber: "YHC14Y", state: "NSW", username:"***your username***", password:"*** password ***")

print(dict["Description"] ?? "error");

Other members of the car_registration package are

  • australia_lookup
  • usa_lookup
  • europe_lookup

Both australia and usa accept four parameters, registrationNumber, state, username and password, and returns a [String: Any] europe_lookup does not require the state parameter, but instead, requires a endpoint parameter, which can be one of the following strings;

  • Check (UK)
  • CheckBelgium
  • CheckCroatia
  • CheckCzechRepublic
  • CheckDenmark
  • CheckEstonia
  • CheckFinland
  • CheckFrance
  • CheckHungary
  • CheckIndia
  • CheckIreland
  • CheckItaly
  • CheckNetherlands
  • CheckNewZealand
  • CheckNigeria
  • CheckNorway
  • CheckPortugal
  • CheckRussia
  • CheckSlovakia
  • CheckSouthAfrica
  • CheckSpain
  • CheckSriLanka
  • CheckSweden
  • CheckUAE
  • CheckUSA
  • CheckAustralia

 

Categories: Uncategorized

Using basic #HTTP authentication with a #REST #API in Perl

perl-camel-source-code-1024-postbit-98365.jpg

Another language in the series, is Perl, where I’ve written some code to call the CarRegistrationAPI.com API – which is a JSON based REST API. Using Perl.

So, here is the perl module

package InfiniteLoop::CarRegistration;

use LWP::UserAgent;
use MIME::Base64;
use JSON;

use Exporter qw(import);

our @EXPORT_OK = qw(usa_lookup australia_lookup europe_lookup);

sub usa_lookup
{
my (%params) = @_;
my $server_endpoint = “https://www.regcheck.org.uk/api/json.aspx/CheckUSA/&#8221; . %params{‘registration_number’} . “/” . %params{‘state’};
%arguments = ( ‘url’ => $server_endpoint,
‘username’ => “” . %params{‘username’},
‘password’ => “” . %params{‘password’});
lookup(%arguments);
}

sub australia_lookup
{
my (%params) = @_;
my $server_endpoint = “https://www.regcheck.org.uk/api/json.aspx/CheckAustralia/&#8221; . %params{‘registration_number’} . “/” . %params{‘state’};
%arguments = ( ‘url’ => $server_endpoint,
‘username’ => “” . %params{‘username’},
‘password’ => “” . %params{‘password’});
lookup(%arguments);
}

sub europe_lookup
{
my (%params) = @_;
my $server_endpoint = “https://www.regcheck.org.uk/api/json.aspx/&#8221; . %params{‘endpoint’} . “/” . %params{‘registration_number’};
%arguments = ( ‘url’ => $server_endpoint,
‘username’ => “” . %params{‘username’},
‘password’ => “” . %params{‘password’});
lookup(%arguments);
}

sub lookup
{
my (%params) = @_;
my $ua = LWP::UserAgent->new;
my $encoded = encode_base64(%params{‘username’} . ‘:’ . %params{‘password’});
my $req = HTTP::Request->new(GET => “” . %params{‘url’});
$req->header(‘Authorization’ => ‘Basic ‘ . $encoded);
my $resp = $ua->request($req);
if ($resp->is_success) {
my $message = $resp->decoded_content;
my $json = JSON->new;
my $data = $json->decode($message);
return $data;
}
else {
print “HTTP GET error code: “, $resp->code, “\n”;
print “HTTP GET error message: “, $resp->message, “\n”;
}
}

Copy that perl module to perl/vendor

And here is a perl script to call it:

 

use InfiniteLoop::CarRegistration qw(usa_lookup australia_lookup europe_lookup);

### code examples

%params = ( ‘endpoint’ => ‘Check’,
‘registration_number’ => ‘Po14ryh’,
‘username’ => ‘** your username **’,
‘password’ => ‘** your password **’);

$data = europe_lookup(%params);
print $data->{Description} . “\n”;

%params2 = ( ‘registration_number’ => ‘hij934’,
‘state’ => ‘pr’,
‘username’ => ‘** your username **’,
‘password’ => ‘** your password **’);

$data2 = usa_lookup(%params2);
print $data2->{Description} . “\n”;

%params3 = ( ‘registration_number’ => ‘490JLN’,
‘state’ => ‘QLD’,
‘username’ => ‘** your username **’,
‘password’ => ‘** your password **’);

$data3 = australia_lookup(%params3);
print $data3->{Description}. “\n”;

You’ll obviously need your own username and password to call this 🙂

This code will hopefully shortly be up on Github and CPan.
 

Categories: Uncategorized