#Jquery #Ajax progress indicator

January 22, 2018 Leave a comment


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) {

//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”;
method: ‘POST’,
url: strUrl,
dataType: ‘json’,
data: {
Data: data
success: function (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

January 19, 2018 Leave a comment


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**”);


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”)
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#

January 16, 2018 1 comment


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)


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)

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

January 10, 2018 Leave a comment


If you need to host an image via HTTPS (SSL), because it is going to be embedded into a secure website, such as paypal, ebay, or an email footer. Then this website httpsimage.com is a really easy and free way to upload a single image for hosting online via HTTPS.

The website just got revamped, with the new Responsive MaterializeCSS framework, and Stripe to handle the payments.

Over the next few days, there are going to be new features added, like bulk uploads, better logging, and more…


Categories: Uncategorized

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

January 10, 2018 Leave a comment

This is a short video demoing the iOS App “”MsSQL,MySQL,Oracle & Postgre” available via https://itunes.apple.com/gb/app/mssql… It shows how to add an Oracle Database server, view tables, and query them, all under 30 seconds!

Categories: Uncategorized

Connecting to #PostgreSQL via C#

December 19, 2017 1 comment


As a planned expansion to the Mobile SQL client app (https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=1325541368&mt=8) for iOS, – soon support for Oracle and Postgre will be added.

The back-end to the app is some C# middleware, and the code it uses to connect to Postgre is as follows;

private static DataTable ExecutePostgre(string strDataSource, string databaseName, string strUsername, string strPassword, string strSQL)
const string strDsnTemplate = @”Server={0};User Id={1}; Password={2};Database={3};”;
var sqlConnection = string.Format(strDsnTemplate, strDataSource, strUsername, strPassword, databaseName);
var adapter = new NpgsqlDataAdapter(strSQL, sqlConnection) { SelectCommand = { CommandTimeout = 0 } };
var dataSet = new DataSet();
adapter.Fill(dataSet, “sql”);
return dataSet.Tables[“sql”];

Where NpgsqlDataAdapter comes from the Nuget Package Npgsql, which is installed using

Install-Package Npgsql

Categories: Uncategorized

Connect to an #Oracle #Database from C#

December 18, 2017 1 comment


Connecting to an Oracle Database in c# is just as easy as MySQL or SQL server, it just requires it’s own library and a different connection string.

First, you need the following Nuget Package

Install-Package Oracle.ManagedDataAccess

Then import it using:

using Oracle.ManagedDataAccess.Client;

Here’s a code example –

public static DataTable PopulateDataTable(string command)
var sqlConnection = @”Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=XE)));user id=system;Password=xyz123″;
var adapter = new OracleDataAdapter(command, sqlConnection) { SelectCommand = { CommandTimeout = 0 } };
var dataSet = new DataSet();
adapter.Fill(dataSet, “sql”);
return dataSet.Tables[“sql”];

Here, the default service is “XE”, the TNS port is 1521, the  username is system, and password is xyx123 – and the oracle server is on the same PC (localhost)

It’s used as follows;

var strSQL = “select * from someTable”;
var dt = PopulateDataTable(strSQL);
foreach(var dr in dt.Rows.Cast<DataRow>())


Categories: Uncategorized