Archive

Archive for April, 2016

Google #BigQuery GoogleCredential json file based authentication

April 29, 2016 Leave a comment

google-bigquery

Google’s big query is a very cost effective means of storing structured data, and it has c# support. Following the quick start example, I didn’t like the way it required the use of the GOOGLE_APPLICATION_CREDENTIALS environment variable to connect to the service. That would be a deployment headache.

So, after downloading the JSON credentials file, which looked like this:

{
“type”: “service_account”,
“project_id”: “xxxxx”,
“private_key_id”: “xxxx”,
“private_key”: “—–BEGIN PRIVATE KEY—– xxx —–END PRIVATE KEY—–\n”,
“client_email”: “xxxxx.gserviceaccount.com”,
“client_id”: “xxxxxxx”,
“auth_uri”: “https://accounts.google.com/o/oauth2/auth”,
“token_uri”: “https://accounts.google.com/o/oauth2/token”,
“auth_provider_x509_cert_url”: “https://www.googleapis.com/oauth2/v1/certs”,
“client_x509_cert_url”: “https://www.googleapis.com/robot/v1/metadata/x509/xxxxxx%40developer.gserviceaccount.com”
}

I then modified the code in CreateAuthorizedClient as follows:

var fs = new FileStream(@”C:\..your-credentials.json”,FileMode.Open);
GoogleCredential credential = GoogleCredential.FromStream(fs);

Which worked a charm. I then had to import my own data into bigQuery, and see if I could query it, and that worked fine too – although I had to enable billing on the account *and project* before I could add my own data.

 

Categories: Uncategorized

ITMS-90282 Invalid Provisioning Profile signature

April 28, 2016 Leave a comment

Screen Shot 2016-04-27 at 18.51.28

When trying to package and submit a Mac OSX app from Xamarin, I got this error “ITMS-90282 Invalid provisioning profile Signature”, the only single mention on the internet was this tweet: https://twitter.com/jabakobob/status/704277502445928448

Also, in case anyone runs into ERROR ITMS-90282, apparently it means that you need to create a new provisioning profile

The root cause of the problem was, when I logged into developer.apple.com -> Certificates, Identifiers & Profiles -> Changed the drop-down to OSX -> Provisioning Profiles -> Distribution, I saw that my provisioning profile was marked “Invalid” (I still don’t know why)Screen Shot 2016-04-28 at 11.39.57

So, what I did was, created a new provisioning profile *with a memorable name*, Mac OSX Distribution, for the correct App ID, and then downloaded the profile by going into Xcode -> Preferences -> Accounts -> Select Company Account -> Select View Details, select the new profile, and download.

Then back into Xamarin, I selected the project -> Options -> Mac Signing -> Changed the identity drop down, until I saw the new provisioning profile. I then selected Build -> Archive for publishing.

Going back into Xcode, I opened Organiser, and saw my new package, and I pressed Upload to App Store … Yes!

 

Categories: Uncategorized

Visualising a #Hypercube, ps: the earth is flat.

April 28, 2016 Leave a comment

S_Arch

The arch in la defense, Paris is designed to match the shadow cast by a shape called a hypercube. Unfortunately for mere mortals, a hypercube is a shape that is very hard to visualise, because it stretches into an additional dimension.

So, what is a hypercube, and why did I say the earth was flat?

Well, a cube is to a square what a hypercube is to a cube.

A Square has 2 dimensions, a cube has 3 dimensions, and a hypercube has 4 dimensions. Unfortunately, we have no perception of a 4th dimension, so it’s really hard to imagine a hypercube, but it can be described easily.

Dimension Descriptor Points Edges
0 Singularity 1 0
1 Line 2 1
2 Square 4 4
3 Cube 8 12
4 Hypercube 16 32

Now, lets take things back, and think of a simpler shape, a bit closer to home, – actually, earth.

A circle has 2 dimensions, a sphere has 3 dimensions, and a hypersphere has 4 dimensions.

For most of us, – and I’m excluding any astronauts among us, then the earth is effectively a 2 dimensional plane. If you travel north from Canada, you end up in Russia. If you travel south from Argentina, you end up in Australia, so, to take a ptolemaic view of the world, then the map of the earth is as follows:

flat earth

And that map extends outwards in all directions, to infinity.

But what’s wrong with this map?, If you travel north from Canada, you end up in Russia. If you travel south from Argentina, you end up in Australia?, that’s exactly what happens. If you wanted to travel by land, then this map is perfectly accurate.

The issue is perspective, in the same way that Ptolemy’s map of the solar system was observationally correct, but from an incorrect perspective. (Thanks to the church)
AT02FG06

So, to take this analogy further, to the hypersphere, an astronaut travelling in any direction, up, down, left, right, for long enough, would reach his starting point again.

Like if you left London by boat, travelled to America, Asia, Middle East, Europe, then back to London again. In the same way, a space ship on a hypersphere could travel past our galaxy, through another few million galaxies, then arrive home again, without changing direction.

The effect of light travelling from one side of the universe and arriving at the other has been observed, which has led astronomers to believe that is a suggested shape of our universe is a hypersphere (*actually a hypertorus, like a giant 4D doughnut).

Since the sphere of the earth is so big in our perception, it appears two dimensional, so the 3D curvature of the earth is not perceivable, to the average person. In the same way, the universe is so large, that the 4D curvature of the universe is not perceivable to humans. Even if the universe were smaller, the curvature would still be beyond our comprehension, but the effects of which would be visible. If the universe were the size of our solar system, then we’d look out, and see our own sun on a starry night (many times over)

So, taking it back to the Hypercube.

If you were an ant, walking around a dice, and wanted to map the surface of your new world, then you’d get a map like this:

ant-on-a-dice

Notice, that the pattern repeats for ever, and that this little ant, can never escape his home. every corner he turns, either forward, back, left or right, there is just another face with a number on it.

It doesn’t bode well for the actors in the movie “Hypercube” who also, would not be able to escape their 4D prison, when restricted to three dimensions of movement.

inside a hypercube

And it’s important to mention that this pattern repeats for ever in all directions, up, down, left, right, forwards, and backwards. The same map would apply for waking on the inside or outside of a hypercube.

Although this is effectively a ptolemaic view of a hypercube, it’s the best our 3D minds can visualise at the moment.

 

 

 

Categories: Uncategorized

Resolve a url after a #302 redirect #Xamarin.MAC

April 27, 2016 Leave a comment

Say you have a url, like bit.ly/whatever – then you might want to know what the final url of that url leads to – I wanted to do that using Xamarin.MAC -although I assume that Xamarin.IOS would be the same.

NSUrl url = new NSUrl (strUrl);

NSUrlRequest request = new NSUrlRequest(url);
NSUrlResponse response = null;
NSError error = null;
NSUrlConnection.SendSynchronousRequest(request,out response,out error);
if (error != null)
{
  UITools.MessageBox(error.ToString());
}
url = response.Url;
UITools.MessageBox(url.ToString());

The Objective C code that I copied this from was as follows:


NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:orinigalURL 
* cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0];
[request setHTTPMethod:@HEAD];
NSURLResponse *response = nil;
[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:nil];
NSURL *finalURL = response.URL;

As it turned out, the error was actually that I had to add this to my info.plist

<key>NSAppTransportSecurity</key>

<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>

Categories: Uncategorized

#India Car registration #API lookup

April 26, 2016 Leave a comment

map-of-india-with-tricolor_1017-1592

India Car registration API 

Today, we just launched in.carregistrationapi.com ; an API that allows developers determine the make, model, age, VIN number, and location of Indian registered cars from their number plate.

Unlike many European countries, not all cars in India are digitally registered, and in order for a car to be returned by this API it must be registered with VAHAN (http://vahan.nic.in), of which there are almost 200 million vehicles registered. Furthermore, some imported cars from non-Indian manufacturers may have very limited technical information about the car.

In order to call the API you should call the /CheckIndia endpoint, and you can expect the following information back in the JSON

 

  • Make
  • Model
  • Engine Size
  • Year of first registration
  • VIN (Chassis Number)
  • Location

 

Sample JSON:
{“Description”:”HONDA CIVIC 1.8V MT”,”RegistrationYear”:”2007″,”CarMake”:{“CurrentTextValue”:”HONDA”},”CarModel”:{“CurrentTextValue”:”CIVIC”},”EngineSize”:{“CurrentTextValue”:”1.8V MT”},”MakeDescription”:{“CurrentTextValue”:”HONDA”},”ModelDescription”:{“CurrentTextValue”:”CIVIC”},”VechileIdentificationNumber”:”MAKFD153K7N 103531″,”Location”:”RTO, BANGALORE EAST , KARNATAKA”}

Categories: Uncategorized

Chassis Number #API (VIN) available

April 26, 2016 Leave a comment

9840280_orig

A chassis number, or VIN number is etched into the chassis of all cars, and is unique to the car. The format of the number describes different aspects of the car, and this format varies from manufacturer to manufacturer. Without a manufacturer specific search, you can’t get much information, apart from the make, model, and age.

We’re offering a beta service on http://www.regcheck.org.uk/api/reg.asmx?op=VinCheck  that allows a lookup of VIN numbers across several manufacturers. You’ll need a free account with regcheck.org.uk to get access.

Vin Check

As a beta feature, we also offer a VIN (Chassis number) check, where it is possible to return some basic information from a Chassis number.

  • Make
  • Model
  • Registration year
  • Engine Size

It returns XML only, in this format

<Vehicle xmlns:xsd=”http://www.w3.org/2001/XMLSchema&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xmlns=”http://regcheck.org.uk”&gt;

<vehicleData>

<Description>HONDA CIVIC 1.8V MT</Description>

<RegistrationYear>2007</RegistrationYear>

<CarMake>

<CurrentTextValue>HONDA</CurrentTextValue>

</CarMake>

<CarModel>CIVIC</CarModel>

<EngineSize>

<CurrentTextValue>1.8V MT</CurrentTextValue>

</EngineSize>

</vehicleData>

</Vehicle>

Categories: Uncategorized

Funky new dashboard for RegCheck websites

April 21, 2016 Leave a comment

Dashboard

Not really a technical post, but this is the new dashboard that I’ve just created for my RegCheck websites. It’s developed using Bootstrap, Google Charts, icomoon for the icons, and mustache.js to provide a data binding between the JSON representation of the user and the HTML.

 

 

Categories: Uncategorized