Archive for category Programming

On Marmalade and PlayBook development

So… The Marmalade promotion is ending in a few hours. I’m still waiting for my app to get approved through QA, so we’ll see what happens. Cutting it a bit close, but that’s life.

Mainly because my workaround for Marmalade Web not working was to use WebWorks, which… I was only recently told didn’t actually satisfy the T&C of the promotion. So one ‘quick’ app in Marmalade Quick/Lua later, and I hoping to be able to keep the PlayBook.

But OH MY GOD, Marmalade. If you were trying to get me to use your stuff for anything, you have utterly failed at it.

First off, the SDK itself. Er… WTF? I was under the impression that Marmalade Web was part of the SDK. But it doesn’t support the cross-platform nature of the actual SDK, despite BB10 probably having the best HTML5 development toolkit out there? (I know of nothing on Android/iOS that allows you to take a bunch of HTML files, and throw them up as a full app.) Sketchy at best, considering I would have thought there’d be at least some half baked support.

Which leads me to my second point – really crappy code. One example: The publisher in Quick doesn’t sign packages that you request to be published. (leaving aside that yhat hotfix fixes… what, exactly? And how do I download it?)

The inability to sign stuff is really strange, because you’ve got the Test deployment down to a science, requiring author IDs and stuff I had to extract from the debug token bar file. I didn’t have to enter my author ID when publishing stuff from WebWorks. Why can’t you handle this stuff? YOu’ve chained together umpteen dozen other programs, surely you can handle this one.

(For the record, I ended up manually signing the generated unsigned bar file. After correcting the fact that it still set the dev mode flag to ‘true’ in the application manifest.)

My third point is really my second point rehashed – strange error messages:

C:\Marmalade\6.2\s3e\makefile_builder\ --use-temp-extension --verbose=1 C:\Users\kyl191\Documents\testcards\Testcards Lua.mkb_temp --non-interactive --no-make --no-ide --buildenv=WEB --builddir publish_build --use-prebuilt --deploy-only
error: Specified input file not found: c:/Users/kyl191/Documents/testcards/Testcards Lua.mkb_temp
FAILED (error code=2)

I got this when trying the recommended workaround of ‘use the full marmalade 6.2 to sign packages’. As you can see, they have very enlightening error messages. Trivia: That mkb filename was autogenerated. I didn’t select it. The actual filename was Testcards Lua.mkb. Copy and pasting the mkb file and appending _temp like it expected ended up with M6.2 just hitting a folder not found error this time.

Another example: The default project file hits a a file not found error when you try to run it in the simulator. I fixed it by commenting out, of all things, a Facebook library for Android. I ticked the QNX box in the deployment screen, Quick. WTF are you including a Facebook library for a completely different platform?! (Yes. They have an actual Facebook library. Thank you very much for giving us all of 3 methods. You get a half-star because you’re in beta, I’d expect more later, but I’m looking forward to leaving you altogether.)

And fourthly, the docs don’t match what’s actually done. Small things I can understand. But stuff like the contents section referencing node.h, only for the main text of the page to have an entry node.height instead? Mhmm. Fun stuff.

And finally, some of the decisions are TDWTF worthy. The main one that I butted heads with? Guess where the (0,0) pixel actually is.

Most programmers would think upper left, since that’s pretty much the standard. Not in Quick. Oh, no. Here, we have the bottom-left corner be (0,0). Why?

I don’t know, and I don’t care. As soon as my app passes QA, their admin people sort out what’s happening with the PlayBook and everything looks good, I’m done.

That uninstall button has never looked so tempting.

No Comments

Silly Access-Control-Allow-Origin Workarounds

“Origin null is not allowed by Access-Control-Allow-Origin” was the error I was getting when looking at a local html/JS powered page on my desktop, and I tried to do a getJSON request in jQuery.

It’s a well known problem – but also quite annoying, mainly because the fixes were generally of the form “change your endpoint to have a callback”, or “modify your code so it does X, even though that means you have to change Y and Z too”.

So I looked around, and was about to default back to my old plan of dumping everything into an array when I realised that because my JSON is constant, I can just have it as an excessively long string, and use parseJSON to parse it.

And so I ended up with something like this:

data.js consisted solely of var json="[{...}]";

logic.js called $.parseJSON(json)

And my main file had

<script type="text/javascript" src="mathcards.js"></script>
<script type="text/javascript" src="data.js"></script>

But it worked. And with only an extra line (the extra script/data.js line – possibly even a net drop since I got rid of the success function), I’m calling it a success.

Then again, it’s 12:30 in the morning after the facebook hackathon (which was pretty awesome, even if MathJax broke during my demo because I forgot to include the $ signs for inline math).

Also, JSONLint is my new favorite utility – not only does it validate your JSON, but it also pretty-print formats the long string into a form that looks a lot nicer to save.

, ,

No Comments

Compiling & publishing BlackBerry WebWorks apps

As part of the Blackberry Playbook promo, I have to publish an app on the BlackBerry App World store.

Ripple was somewhat easy to get up and running. Except for the fact that it didn’t like the launch on Playbook option – it was checking some variable that wasn’t set, so it ended up trying to push C:\path\to\bar\file\ It really concat-ed the term ‘undefined’ into the file path.

So I had to manually install it using the blackberry deploy tool. BlackBerry has a dedicated page, but in short:

PS C:\Program Files\Research In Motion\BlackBerry WebWorks SDK for TabletOS\bbwp\blackberry-tablet-sdk\bin> .\blackberry-deploy -installApp -password password -device ip.address.of.playbook C:\path\to\bar\file

Another interesting/odd thing is that I had to sign the app to get it to install on the Playbook. Simply packaging it wasn’t enough – it rejected it with a “app author doesn’t match debug token author” error. (And the other interesting thing I found out was that it appears to upload your app to the BlackBerry servers to get signed. At least, when my connection dropped out for a bit, I got a “” error.)

, ,

No Comments

Pushing an existing repo to github

Because I’ve had to do it a number of times, and had to look it up each time:

  1. Create the repo on github
  2. On the desktop/laptop/whatever, in Git Bash, change to the folder with the repo
  3. Run:

git remote add origin [email protected]:username/repo.git, then
git branch --set-upstream master origin/master and finally
git pull

And done.


No Comments

A grab bag of half-finished posts

Because I’ve started a bunch of posts, haven’t finished them, don’t really want to delete them but stuff looks potentially useful, and I’m clearing stuff out.

Read the rest of this entry »


1 Comment


The bulk of this was written on Nov 16th before I finished CS137 at UW. Most of this stuff still stands.


(Also, why I’m glad I’m using Git, why I love Stack overflow, and frak yes Valgrind) Read the rest of this entry »

, , ,

No Comments

I has a new shiny

Still in the box!

Thanks to the Made with Marmalade offer, I now have a tablet. I couldn’t (and still can’t) justify spending money on a tablet beyond “it looks cool, and it’d be funky to have one”, but the offer for a free tablet neatly solved that.

Now to write an app for it and submit it, so I get to keep the tablet.

Go go first time at actual proper mobile app development, not just a wrapper around a site or just prototyping apps.

, , ,

1 Comment

My Git for CS137 setup

I’ve been using Git and GitHub for all of my CS137 assignments, in part to keep the files in sync between my desktop and laptop, as well as the UW server that I use for testing. The keeping everything in source control is a bonus, but one that comes in handy, especially branching when I discover that actually my code can be rewritten in a better way.

The primary impetus for this post is that I’ve been creating a branch for each assignment, but I still have yet to get the branching push/pull commands down pat, so I always end up searching Google for the appropriate commands. After 6 branches (and counting), I’ve gotten tired of that, so I shall centralise it in one place:

Pushing a new branch: git push origin new_branch

Pulling a new branch: or git pull && git checkout --track origin/new_branch or git checkout new_branch

Read the rest of this entry »

, ,

No Comments

ssh-agent messiness & solving it

I’ve known about ssh-agent for a while, but as I was practically permanently using PuTTY (on Windows), I only bothered with learning about Pageant.

But Git uses ssh to connect to github, and I was getting tired of typing in my password with every push. I got annoyed with InteliJ for making me type in my password in with every push, and this was no different. Because git uses bash as its’ command line on both Windows and Linux, I decided to get started with using ssh-agent.

The first time I ran ssh-agent expecting it to work automagically. Instead it dumped what looked like two environment variables to the screen and quit. Not too helpful, but I manually copied, formatted & pasted the variables, and got it working.

But doing that manually, while awesome when pushing from one system and pulling on another, was also annoying with having to do it every time I logged in. So I looked into automating it. I knew of eval and backticks in bash. So I tried `ssh-agent`.

$ `ssh-agent`
sh.exe": SSH_AUTH_SOCK=/tmp/ssh-myYvgp1404/agent.1404;: No such file or directory

Hmm. No joy. Ok, let’s try eval ssh-agent. Maybe that’ll make a difference?

$ eval ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-zIQZKN6080/agent.6080; export SSH_AUTH_SOCK;
echo Agent pid 1092;

Nope, back to manually editing it. Hmm. Google search time.

Which led me to a uni helpdesk page. Which told me that I had to use both eval and backticks. Huh. How ingenious.

$ eval `ssh-agent`
Agent pid 4288


So I gleefully ran it on the uni’s servers. And then discovered I had to run it in every bash shell. Hmm. Sounds kind of unoptimal. Fixed my original problem, which was having to type in my password each and every time I pushed or pulled from github. And using eval and backticks meant it was easier than copy & pasting the output. But I didn’t like having to run ssh-add and ssh-agent in every new session, or that ssh-agent wouldn’t auto-terminate when I closed bash. (Which led to a surprise when I ran ps u and saw at least 8 ssh-agent processes running with my username.)

So I just ran it in a screen session. And just have to use that one window everytime. Fairly straightforward.

The alternative was add to the commands to my .bashrc. But the uni servers seem to do something to bash such that it doesn’t execute a user’s bashrc when they login, only after they run bash. So running it in screen works just as well, since I’d need to run a command anyway.

As an alternative alternative, I also found a script that should work for keeping track of ssh-agent and can be run from .bashrc, so I’ll be looking into that too.

, , ,

No Comments

Getting a Python dev environment setup on Windows

I’ll be doing a fair amount of work in Python in the next few months, so I decided to sit down and get a good dev environment going. First on my laptop (32 bit is easier to deal with), then on my desktop.

So I’ll be doing 3 things:

  1. Getting Git setup
  2. Getting Git working with GitHub
  3. Getting Python and pip installed

First of all, started off with Git. Downloaded from, and installed it following GitHub’s Windows setup guide. (As a side note, I’m not dealing with GitHub’s native app because when I last used it, you couldn’t select individual blocks of code to be committed. I know Git philosophy is to commit often, but I just commit when I’ve got something working, and I’d have touched a few different files and done more than one thing.)

They’ve improved the installer since I last used it, so it was deceptively simple. No more messing around with config files, whee!

Second thing was integration with Github. SSH keys allow password-less authentication (I hate InteliJ’s Github integration because it uses the HTTPS repo, which requires me to enter my github password). Once again, easiest thing to do was to follow Github’s guide on generating ssh keys. Another side note: It’s ssh -T [email protected]. I was trying ssh -T and was wondering why it was failing. =|

And onto the third and final thing, which is also the most difficult: Getting Python up and running with pip installed & working. I’ll split this into two parts: getting Python, and getting pip working.

Getting Python is trivial – I downloaded it from I chose 2.7.3, but could have gone with 3.2.3. (In fact, probably should have, but modules are still coded to 2.7 compatibility, so that’s what I’ll use.)

Getting pip on is a bit more complicated – you have to install easy_install, then use that to install pip. So, I used the lovely directions at StackOverflow for inspiration:

  1. Grab setuptools from – make sure the version you get matches the version of Python installed – in my case, 2.7
  2. Install setuptools. You can follow the defaults, just make sure you install to the correct directory – where you installed Python. This should be auto-detected though.
  3. Open Powershell (I’m running Win 7; if you aren’t, you should be. And if you can’t run W7, open up command prompt instead.)
  4. In the shell, change to the directory where you installed Python, and then to the Scripts directory in that folder – ie. cd C:\Python27\Scripts
  5. Type ./easy_install pip – this works because setuptools added an executable called easy_install.exe to the Scripts/ folder
  6. Pip is now installed. If you want to install something with Pip (i.e. ), open up Powershell again if it’s not already open, change to that directory, and run ./pip install requests

For bonus points, and to get Python to run without having to prepend the directory where Python is installed to every command you run with Python, append the Python directory to your environment PATH variable.

How do you do this? On Win 7, type “Path” into the search bar in the start menu. It should get you something like this:

Select the “Edit system environment variables” option. Not the one with “Your account”.

That will take you to this screen. See the button close to the bottom labeled “Environment Variables”? That’s the one you want to click. And when you do that, you’ll get this:

I’ve skipped a bit, but you want to scroll though the box on the bottom to find the Path variable. When you’ve found it, either double click on it, and single click to select it, and press Edit.

When the screen comes up, hit “End” on your keyboard to jump to the end of the line, then add a semi-colon (which is the ; symbol, if you don’t know), and paste the directory where you installed Python. Or type it. Copy & Pasting directly from an Explorer window is less error prone, so that’s what I do.

Because it’s a system variable, it’ll only take global effect when you restart your computer. If you just want to use Python in Powershell though, just open a new Powershell instance. You can verify that Python’s present in your Path by typing $env:Path and looking at the end of the line that gets printed.


, , ,

1 Comment