Archive
Getting started with Parse
Parse.com is a backend-service for mobile apps, or web apps. It allows you to create simple back ends for mobile apps, without requiring developing your own data-layer. I wanted to try it out, to see if I could get a simple “Hello World” app working, which stores a value in Parse, and then retrieves it via an ID later.
<html>
<head>
<script src=”http://www.parsecdn.com/js/parse-1.2.8.min.js”></script>
<script src=”http://code.jquery.com/jquery-1.10.1.min.js”></script>
<script language=”javascript”>
Parse.initialize(“…..”, “…..”);
var TestObject = Parse.Object.extend(“TestObject”);
$(init);
function init()
{
$(“#save”).bind(“click”,save_click);
$(“#load”).bind(“click”,load_click);
}
function save_click()
{
var testObject = new TestObject();
testObject.save({data: $(“#data”).val()}, {
success: function(object) {
alert(“stored as ” + object.id);
$(“#reference”).val(object.id);
}
});
}
function load_click()
{
$(“#data”).val(“”);
var reference = $(“#reference”).val();
var query = new Parse.Query(TestObject);
query.get(reference, {
success: function(obj) {
$(“#data”).val(obj.attributes.data);
},
error: function(object, error) {
// The object was not retrieved successfully.
// error is a Parse.Error with an error code and description.
alert(error);
}
});
}
</script>
</head>
<body>
<input type=”text” name=”data” id=”data” Value=”hello world”><br>
<input type=”button” value=”save” id=”save”><br>
<input type=”text” name=”reference” id=”reference” Value=””><br>
<input type=”button” value=”load” id=”load”><br>
</body>
</html>
Here, I initialise the Parse Library, then tie up events via JQuery, the Save and Load buttons to functions save_click and load_click. Save_click then stores a JSON object with property “data” and value as typed into the data text box, and sends this to Parse, all going well, an id is returned and displayed in the “reference” box. Load_click then requests this object again from Parse, using the ID previously provided, and displays the data property into the data text box.
The package version in your .bar manifest file for New Bundle must be greater than the previous version
When updating an App for BlackBerry 10 on the ISV portal, a new error appeared when trying to submit my updated BAR file,
The package version in your .bar manifest file for New Bundle must be greater than the previous version, but lower than any the next release version added to the vendor portal. . Your .bar manifest file package version must be greater than 4.0. Correct your .bar manifest file and try again to continue.
After a bit of research, I realised that the version number is composed of two values:
The version number in the Widget tag of the Config.xml;
<widget xmlns=”http://www.w3.org/ns/widgets” xmlns:rim=”http://www.blackberry.com/ns/widgets” version=”4.0.0.0″>
Combined with the buildId that is passed into the BBWP tool.
The combined version number must be unique, and as per this new requirement greater than the app version as published in the ISV portal.
ExecuteCore not called in ASP.NET MVC 4

If you want a function to be called before every page load in an MVC asp.net web application, then you could of course call that function from every action, or you can override the ExecuteCore method.
But no… It never gets called, what can you do?, well, I discovered on StackOverflow, that if you also override DisableAsyncSupport and return true, then the ExecuteCore method gets called
protected override void ExecuteCore()
{
// Modify current thread’s cultures
var strCulture = CurrentLocale();
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(strCulture);
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;base.ExecuteCore();
}/// <summary>
/// Ensures that ExecuteCore() is called.
/// </summary>
protected override bool DisableAsyncSupport
{
get { return true; }
}
This is how, I’ve created two code-identical sites, www.freesms.cat and www.kostenfreiesms.com with different resource files to handle two different locales
English Dictionary API served with MongoDB
![]()
As an exercise with the no-SQL database platform MongoDB, I created a free account on mongolabs, created a database called webtropy, and within this, created a collection with the name “dictionary”. I then downloaded a English dictionary in text format from http://www.isc.ro/en/commands/lists.html (TWL06), Importing this into Mongo was mongoimport, specifying fields as “word”.
They offer a REST API via their HTTP interface, such as:
https://api.mongolab.com/api/1/databases/webtropy/collections/dictionary?apiKey=5FdV2ICC_dTrXGyumdVcIaBB2xYztY_n&q={‘word’:’HELLO‘}
Where “HELLO” is the word being checked. If the word is missing, i.e. “HELLOY” then the result is an empty JSON array “[]”
For the full English dictionary in JSON format, you can download this from Box.com at https://www.box.com/s/dvvuv4d6kqet4xbu7nvw
NAX Advertising WP7 App

Sometimes you just realize that an app won’t sell on an app store. If you’ve had no sales on an app in 30 days, then, give up, and try a different business model…
There is a Windows Phone app for this blog, but, since the blog is very readable on a mobile device, I guess nobody would be willing to pay 0.99, so I tried using Nokia’s Ad Exchange, to add adverts to the app, so I could release the app for free. Instead. Also, it’s part of the DVLUP Challenges – So worth a T-shirt anyway!
I signed up to Nokia’s NAX program, added the details of my app, then downloaded the Windows Phone 7 SDK from Inneractive. Unfortunately the one-liner setup code didn’t work in the 10 second video didn’t work… probably because they never show the XAML!, I then checked out their sample, downgrading it from 7.1 to 7 by modifying the csproj, and the WMAppManifest – then copied (and simplified) their code as follows:
C# Code (In MainPage_Loaded):
var optionalParams = new Dictionary<InneractiveAd.IaOptionalParams, string>();
InneractiveAd iaBanner = new InneractiveAd(“OpenMerchantAccount_NetworkProgramming_WP”,
InneractiveAd.IaAdType.IaAdType_Banner, 60, optionalParams);
// Add the banner to the grid
Grid0.Children.Add(iaBanner);
XAML (Within panorama control)
<controls:PanoramaItem Header=”Ads” VerticalAlignment=”Top”>
<Grid x:Name=”Grid0″ Grid.Row=”0″ />
</controls:PanoramaItem>
There’s more you can do with the ads, but I’m just learning…
Load Cross Domain JSON via JSONP Proxy
A well known security constraint on modern browsers, is that AJAX requests can only be made to the server which served the page. To get around this, you can use CORS for modern browsers, or JSONP.
JSONP, however does require that the data provider wraps their JSON response in a function call, which they may not do. Therefore, an easy solution is to create a proxy that wraps JSON in a function call, such as:
public partial class JsonProxy : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string link = Request.QueryString[“url”];
if (link == null || link == “”)
{
Response.Write(“Requires url parameter”);
return;
}
WebClient wc = new WebClient();
string strJson = wc.DownloadString(link);
Response.Write(“jsonp_callback(” + strJson + “);”);
}
}
Then, on the client side, a this can be used as follows (JQuery version):
<html>
<head>
<script type=”text/javascript” src=”jquery.js”></script>
<script language=”javascript”>
$(init)
function init()
{
LoadJson(“http://www.bbc.co.uk/tv/programmes/genres/comedy/schedules/upcoming.json”);
}function jsonp_callback(data)
{
$(“body”).html(“Found ” + data.broadcasts.length + ” upcoming comedy shows”);
}function LoadJson(url)
{
var s = document.createElement(“script”);
s.type = “text/javascript”;
s.src = “http://www.yourwebsite.com/jsonproxy.aspx?url=” + url;
$(“head”).append(s);
}
</script>
</head>
<body>
Please Wait.
</body>
</html>
Hosting files on Adobe’s Cloud
Adobe’s creative cloud allows 2GB of free storage, which is handy for uploading large files for personal use. But you can also use these to serve images and files on websites, like the image above. With a little trick.
1. Upload your image or file to Adobe’s cloud
2. Click on the arrow, and select send link
3. Change the slider to public
4. Select Allow Download
5. Select the link icon, and copy the url.
Now, modify the URL as follows:
https://creative.adobe.com/share/GUID
https://d2.creative.adobe.com/api/assets/GUID
Where {GUID} will be different in your case.
Cordova/PhoneGap for WP7 in Windows XP
Normally, I develop my apps for WP7 natively using Silverlight for Windows Phone, but I thought that some of my apps would be easier to port, if I could use Phonegap (Cordova).
My home PC runs Windows XP, and VS 2010, which means that Windows Phone apps can’t be emulated, but can still be run on a real device (A better experience in any case). Unfortunately, the XNA framework for Windows Phone is not compatible with Windows XP, and Cordova / Phonegap relies heavily on this library.
So, I decided to take PhoneGap / Cordova version 2.4.0 for Windows Phone 7, take the standalone model, and then strip out all the code that relied on the XNA framework, or just anything that didn’t compile. I understand, that this does cripple many features, such as audio recording, video recording, some file operations, and perhaps other features. However, the code compiles and runs on a Windows Phone 7 device, and renders the HTML page.
You can download this library, from http://www.javatiger.com/downloads/wp7cordovaxp.zip – Should you want to develop Cordova / Phonegap Windows Phone 7 applications on Windows XP.
iOS6 support for PhoneGap 0.9.4

After 1st May 2013, Apple has begun enforcing iOS6 support, and effectively outlawed access to methods that access device UDID, for security reasons.
However, if your application is based on PhoneGap, and even if you do not access the device UDID via javascript, since the underlying PhoneGap library accesses the UDID, then Apple will reject the application. Now, the solution is to either upgrade to the latest version of PhoneGap – or a one line change 🙂
Double click on PhoneGapLib.xcodeProj then open the PhoneGapDelegate.m file, then scroll down to
– (NSDictionary*) deviceProperties
Then comment out the line
//[devProps setObject:[device uniqueIdentifier] forKey:@”uuid”];
Save the file, and then recompile your application. No more error!
Ajax HTTP status code 0 (zero)
I find that when I encounter a HTTP status code of 0 when using Ajax, it means there is some network error between the client and server, for example, a firewall issue, a network failure, or such forth.
The type of issue was spotted in code that looks like this;
$.get(“http://www.somedomain.com/yourajax.aspx”,function(data){
// Success case
}).fail(function(xhr,status){
if (xhr.status == 0)
{
// Network problem?
}
});
Of course, this is only likely to occur in cross-domain ajax, since it is unlikely for a server to serve a page, and then immediately become unreachable to ajax.