Archive

Archive for January, 2018

#KBA API for Germany based on #Kraftfahrt-Bundesamt data

GERMANY-AUTOMOBILE-VOLKSWAGEN-RECALL

We just launched KbaAPI.de this morning, which is an API that allows a lookup of the German KBA (“Kraftfahrt-Bundesamt”) data. Unlike other countries in the network, the German API accepts KBA numbers instead of number plates.

The data can be purchased as a CSV import for your own database here https://payhip.com/b/PqsL

A KBA number (“Kraftfahrt-Bundesamt”) is a unique number under which is registered with the Federal Motor Transport Authority. The KBA number can be found on the vehicle registration in boxes 2 and 3 or in the registration certificate Part 1 under 2.1.
and 2.2. This API is accessed via the /CheckGermany endpoint, where KBANumber is in the format HSN/TSN (Herstellerschlüsselnummer / Typschlüsselnummer), it returns the following data:
● Make & Model
● Engine Size in KW and HorsePower (PS)
● Engine Capacity
● Fuel type
● Representative image
Sample KBA Number:
4000/305
Sample Json:
{
“Description”: “ALFA GIULIETTA Spider 1.3 [196101 – 196212] (59kW 80hp Otto AR 00508)”,
“CarMake”: {
“CurrentTextValue”: “alfa romeo”
},
“CarModel”: {
“CurrentTextValue”: “GIULIETTA SPIDER”
},
“MakeDescription”: {
“CurrentTextValue”: “alfa romeo”
},
“ModelDescription”: {
“CurrentTextValue”: “GIULIETTA SPIDER”
},
“PowerKW”: 59,
79
“PowerHP”: 80,
“EngineSize”: 1281,
“Fuel”: “Benzin”,
“ImageUrl”:
http://www.kbaapi.de/image.aspx/@YWxmYSByb21lbyBHSVVMSUVUVEEgU1BJREVS”
}

Categories: Uncategorized

#Jquery #Ajax progress indicator

68747470733a2f2f7261772e6769746875622e636f6d2f4b656e616469612f63697263756c61722d70726f67726573732d696e64696361746f722f6d61737465722f73637265656e73686f742e706e67

If you are using JQuery Ajax to upload a file, or other large blob of data, you might want to show the user that something is happening, rather than just showing an animated gif.

Here’s a JQuery Plugin by Chad Engler which can extend the default $.ajax behavior to report progress updates as a percentage.

(function ($, window, undefined) {
//is onprogress supported by browser?
var hasOnProgress = (“onprogress” in $.ajaxSettings.xhr());

//If not supported, do nothing
if (!hasOnProgress) {
return;
}

//patch ajax settings to call a progress callback
var oldXHR = $.ajaxSettings.xhr;
$.ajaxSettings.xhr = function () {
var xhr = oldXHR.apply(this, arguments);
if (xhr instanceof window.XMLHttpRequest) {
xhr.addEventListener(‘progress’, this.progress, false);
}

if (xhr.upload) {
xhr.upload.addEventListener(‘progress’, this.progress, false);
}

return xhr;
};
})(jQuery, window);

To use it, you would write code allong the lines of:

Upload: function(data,  callback, progressCallback)
{
var strUrl = “/Upload.aspx”;
$.ajax({
method: ‘POST’,
url: strUrl,
dataType: ‘json’,
data: {
Data: data
},
success: function (result)
{
callback(result);
},
error: function () { },
progress: function (e) {
if (e.lengthComputable) {
progressCallback(Math.round(e.loaded / e.total * 100));
}
}
});
}

I’ve just used this on the upload feature of https://httpsimage.com

Categories: Uncategorized

Make an authenticated #Http Request with #Kotlin

kotlin_250x250

Kotlin is a superscript of Java, and the next big thing in Android programming, so it’s worth taking a little dabble in the language, to do something basic.

Beyond Hello World, I always see if I can use it to call an API, which of course, my example below is of RegCheck.org.uk – a car registration API. You’ll need to get your own username and password at the website to try out the below code.

Create a file called Http.kt as below;

import java.io.IOException
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Base64;

fun main(vararg args: String) {
val response = sendGet(“https://www.regcheck.org.uk/api/json.aspx/Check/LA15ECT”,”**username**”,”**password**”);
println(response);
}

 

private fun sendGet(url: String, username: String, password: String ) : String {
val connection = URL(url).openConnection() as HttpURLConnection
val auth = Base64.getEncoder().encode((username + “:” + password).toByteArray()).toString(Charsets.UTF_8)
connection.addRequestProperty(“Authorization”, “Basic $auth”)
connection.connect();
val text = connection.inputStream.use { it.reader().use { reader -> reader.readText() } }
return text;
}

Compile the JAR using the code;

kotlinc http.kt -include-runtime -d http.jar

Then run it by using;

java -jar http.jar

and you should get the output

“ABICode”:”21057867″,”Description”:”2015 Honda Civic Type R Gt, 1996CC Petrol, 5DR, Manual”,”RegistrationYear”:”2015″,”CarMake”:{“CurrentTextValue”:”Honda”},”CarModel”:{“CurrentTextValue”:”Civic”},”EngineSize”:{“CurrentTextValue”:”1996CC”},”FuelType”:{“CurrentTextValue”:”Petrol”},”MakeDescription”:”Honda”,”ModelDescription”:”Civic”,”Immobiliser”:{“CurrentTextValue”:””},”NumberOfSeats”:{“CurrentTextValue”:4},”IndicativeValue”:{“CurrentTextValue”:””},”DriverSide”:{“CurrentTextValue”:”RHD”},”Transmission”:{“CurrentTextValue”:”Manual”},”NumberOfDoors”:{“CurrentTextValue”:”5″},”ImageUrl”:”http://www.regcheck.org.uk/image.aspx/@SG9uZGEgQ2l2aWM=”,”VehicleInsuranceGroup”:”21″}

Categories: Uncategorized

#Backup #AWS #Route53 DNS Zones in C#

route53

If you host your DNS on Amazon Route53, and it’s reasonably complex, it’s worthwhile taking a backup of it, so that future errors can be undone quickly. There are some tools to do it, however, you can also write a script yourself in C# to do it.

First off, get the NUGET package

Install-Package AWSSDK

Create an IAM user within AWS with programmatic access, and get it’s Access Key and Secret ID. – I’ve given it Administrator access, but you should limit the scope to the minimum.

Then I output all the zones to the console here;

var client = AWSClientFactory.CreateAmazonRoute53Client(“***”, “***”, RegionEndpoint.USEast1);

var strOutput = @”route53backup.json”;

var req = new ListHostedZonesRequest();
for (; ; )
{
var zones = client.ListHostedZones(req);
foreach (HostedZone zone in zones.HostedZones)
{

Console.WriteLine(zone.Name);

var recordSets = client.ListResourceRecordSets(new ListResourceRecordSetsRequest() { HostedZoneId = zone.Id });

foreach (var record in recordSets.ResourceRecordSets)
{
Console.WriteLine(“\t” + record.Name + ” (” + record.Type + “)”);

foreach (var resource in record.ResourceRecords)
{
Console.WriteLine(“\t\t” + resource.Value);

}
}
}
req.Marker = zones.NextMarker;
if (req.Marker == null)
{
break;
}
}

Note that the ListHostedZones call only returns 100 domains at a time, you have to set the “marker” parameter to the value of the NextMarker property that was returned on the previous call to get all records.

 

Categories: Uncategorized

Free HTTPS image hosting – website revamp

Categories: Uncategorized

Access an #Oracle 11g Database via an #iOS app.

Categories: Uncategorized