Archive

Archive for April, 2016

Google #BigQuery GoogleCredential json file based authentication

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

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.

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

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

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

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

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

How to export a list of domains from #namecheap

I wanted to check the IP address of all the domains I had registered with namecheap, so I wanted to write a batch file to ping them all, so first step, was to export a list from namecheap. I couldn’t find the option, so I asked namecheap support who said there wasn’t an option.

But that just got me to look harder!

So, I enabled their API under Profile-Tools-API Access, whitelisted my IP, and created an api key, and with a bit of research, I got this:

https://api.namecheap.com/xml.response?ApiUser=xxxx&ApiKey=xxxxx&UserName=xxxx&Command=namecheap.domains.getList&ClientIp=xxxxx&PageSize=100

Categories: Uncategorized

#Smalig #ISAPI url #rewrite in IIS 7/8

logo-w-manDuring an upgrade of my server from Windows 2008 / IIS 7 to Windows 2012 , one ISAPI url rewrite that I used did not work. The ISAPI filter appears to be obsolete and unmaintained, so I decided to try and write my own using IIS url rewrite rules, and it turned out to be really easy.

 

So, the premise of this url rewrite is to make a SEO unfriendly url like abc.aspx?id=10 into /web/id/10/abc.aspx – which is more SEO friendly. The smalig Url rewrite will work with any number of parameters, and this is designed to work with at most 2, but you can expand it, if you have more parameters in your url.

<system.webServer>
<security>
<requestFiltering allowDoubleEscaping=”true”/>
</security>
<rewrite>
<rules>
<rule name=”smalig1″>
<match url=”web/([^/]+)/([^/]+)/([^/]+).aspx” />
<action type=”Rewrite” url=”/{R:3}.aspx?{R:1}={R:2}” logRewrittenUrl=”true” />
</rule>
<rule name=”smalig2″>
<match url=”web/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+).aspx” />
<action type=”Rewrite” url=”/{R:5}.aspx?{R:1}={R:2}&amp;{R:3}={R:4}” logRewrittenUrl=”true” />
</rule>
</rules>
</rewrite>
</system.webServer>

The “Allow Double escaping” bit, allows for urls with a plus symbol in them, and if you don’t have this, then you can remove this security exception.

 

Categories: Uncategorized

Consuming a .NET webservice with #python

soap__largeTo consume a .NET SOAP ASMX webservice from Pyhon, you need to use a proxy class, which you can generate using Suds and a tool called wsdl2soaplib by fvieira .

You have to install Suds using

sudo python setup.py install

then generate the proxy class using

./wsdl2soaplib.py http://www.regcheck.org.uk/api/reg.asmx?wsdl > regcheck.py

And it generates a class such as

“””SOAP web services generated from:
http://www.regcheck.org.uk/api/reg.asmx?wsdl.
“””

from soaplib.core.model.primitive import (
Any, AnyAsDict, AnyUri, Boolean, Date, DateTime,
Decimal, Double, Duration, Integer, Float, Mandatory, String
)
from soaplib.core.model.clazz import Array, ClassModel

from soaplib.core.model.base import Null

from soaplib.core.service import soap, DefinitionBase
from soaplib.core.model.enum import Enum
class ArrayOfString(ClassModel):
“””SOAP complex type “{http://regcheck.org.uk}ArrayOfString“
“””
string = Array(String)
class ArrayOfArrayOfString(ClassModel):
“””SOAP complex type “{http://regcheck.org.uk}ArrayOfArrayOfString“
“””
ArrayOfString = Array(ArrayOfString)
class DataGrid(ClassModel):
“””SOAP complex type “{http://regcheck.org.uk}DataGrid“
“””
json = String
columnNames = ArrayOfString
data = ArrayOfArrayOfString
class UKTest(ClassModel):
“””SOAP complex type “{http://regcheck.org.uk}UKTest“
“””
TestDate = String
ExpiryDate = String
Result = String
Odometer = String
TestNumber = String
FailureReasons = ArrayOfString
class ArrayOfUKTest(ClassModel):
“””SOAP complex type “{http://regcheck.org.uk}ArrayOfUKTest“
“””
UKTest = Array(UKTest)
class UKMOTData(ClassModel):
“””SOAP complex type “{http://regcheck.org.uk}UKMOTData“
“””
Tests = ArrayOfUKTest
taxDate = String
Json = String
ExtendedInformation = ArrayOfArrayOfString
ExtendedInformationJson = String
class CarReg(DefinitionBase):
“””SOAP service “CarReg“ with target namespace http://regcheck.org.uk.
“””

@soap(String, String, Integer, _returns=CarSpecificationsResponse)
def CarSpecifications(self, make, model, year):
“””Parameters:

“make“ — string (optional)
“model“ — string (optional)
“year“ — int

Returns: CarSpecificationsResponse
“””
return None
@soap(String, String, _returns=CheckResponse)
def Check(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckResponse
“””
return None
@soap(String, String, String, _returns=CheckAustraliaResponse)
def CheckAustralia(self, RegistrationNumber, State, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“State“ — string (optional)
“username“ — string (optional)

Returns: CheckAustraliaResponse
“””
return None
@soap(String, String, _returns=CheckDenmarkResponse)
def CheckDenmark(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckDenmarkResponse
“””
return None
@soap(String, String, _returns=CheckFinlandResponse)
def CheckFinland(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckFinlandResponse
“””
return None
@soap(String, String, _returns=CheckFranceResponse)
def CheckFrance(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckFranceResponse
“””
return None
@soap(String, String, _returns=CheckIrelandResponse)
def CheckIreland(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckIrelandResponse
“””
return None
@soap(String, String, _returns=CheckItalyResponse)
def CheckItaly(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckItalyResponse
“””
return None
@soap(String, String, _returns=CheckNetherlandsResponse)
def CheckNetherlands(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckNetherlandsResponse
“””
return None
@soap(String, String, _returns=CheckNewZealandResponse)
def CheckNewZealand(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckNewZealandResponse
“””
return None
@soap(String, String, _returns=CheckNorwayResponse)
def CheckNorway(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckNorwayResponse
“””
return None
@soap(String, String, _returns=CheckPortugalResponse)
def CheckPortugal(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckPortugalResponse
“””
return None
@soap(String, String, _returns=CheckSpainResponse)
def CheckSpain(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckSpainResponse
“””
return None
@soap(String, String, _returns=CheckSwedenResponse)
def CheckSweden(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckSwedenResponse
“””
return None
@soap(String, String, String, _returns=CheckUSAResponse)
def CheckUSA(self, RegistrationNumber, State, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“State“ — string (optional)
“username“ — string (optional)

Returns: CheckUSAResponse
“””
return None
@soap(String, String, String, _returns=UKMOTResponse)
def UKMOT(self, RegistrationNumber, Model, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“Model“ — string (optional)
“username“ — string (optional)

Returns: UKMOTResponse
“””
return None

WSDL_TYPES = {
‘ArrayOfArrayOfString’: ArrayOfArrayOfString,
‘ArrayOfString’: ArrayOfString,
‘ArrayOfUKTest’: ArrayOfUKTest,
‘DataGrid’: DataGrid,
‘UKMOTData’: UKMOTData,
‘UKTest’: UKTest,
‘Vehicle’: Vehicle
}

Categories: Uncategorized