Categories
Programming

Flex and Google App Engine are working together for me !

After using Flex for a bit, and blogging here that the backend is not so extensive, I discovered that Google has brought out the Google App Engine (GAE) sometime this year. It allows you to write the backend in Python and the frontend in html or ajax or even flex ! It even comes with a templating engine, is currently in beta, and is free !

It should be the best of both worlds, if I can get it work together.

There’s actually not that many examples floating on the net that go into much detail into how to set this up. Lots of references to PyAMF (Python with Action Messaging Format so that it can talk Flash), but I find the examples are almost all from people in the know, and for a ‘script’ programmer like me I sure could use some (very) detailed explanations !

I finally found a good example of a simple Flex client that connected to a python Google App Engine on this site. After two nights of puttering around, I finally got my modified example to work and understood what was happening (I’m still learning flex, actionscript3 and now GAE – it’s a bit much sometimes). I actually write the xml back via a python hack where I do a loop and write the tags one by one… tss, I’m sure there’s a better way (pyAMF ?).

Now I still need to get my head around what PyAMF actually does and how it integrates between Flex and GAE. This seems to be a nice example from the PyAMF wiki.

Categories
Programming

Just finished my first flex application !

I just made a demo form entry in Flex to show to some mates of mine.

They are receiving emails and take their work orders from them, but I find this rather insecure, so the demo form is to show them what is possible with a form to be filled in on a website, in order to avoid all the hassles that happen with mail (arriving late or never, not all information filled in, etcetera).

The original demo page has been ready for about a week, but I had gotten stuck on some combo box controls where I couldn’t retrieve the data from when entered – I finally sussed it out by going to the online help instead of reading the flex3 book, and sure enough, an example was given how to retrieve the data. I have to admit that the flexbuilder documentation is topnotch.

I’m quite happy with that proof of concept page. Enough to finally go to bed now and get some sleep…

Categories
Programming

Busy learning flex3 and actionscript

Quite busy learning howto program using flex builder 3 in mxml and actionscript3.
It’s like learning 2 languages at the same time! Add to that that you can deploy your app to both the web and the desktop (which has its own specific API’s to access the local filesystem) and it starts getting complicated.
Mxml is quite cool and the help in FB3 is quite good. Still haven’t written a decent application though. Although I have some good ideas already, my knowledge of the languages is not yet sufficient… Grrr.

Categories
Programming

Flex and Python and PHP : a first comparison

After two weeks of so of looking into Flex, MXML and ActionScript, the key differences between the two languages are for me that Flex is first most oriented to the ‘front’ as opposed to python, that is more oriented to the ‘backend’.

With front I mean that everything so far that I discovered in Flex is oriented to presentation to the web client. There’s heaps of stuff in Flex that you can use to easily develop and present quality stuff to the web visitor (or even to the desktop, if you develop in Flex for AIR, Adobe’s desktop runtime solution that uses the same code as your web application).

But to get to the data from the backend, you cannot simply write an SQL query in your code; since flex code is compiled to flash, anybody with a flash decompiler could read the credentials you are using (as opposed to php or python code on a webserver, which is executed and where only the results are shown to the client; code is never shown).

So that means that to connect to a database, you need an intermediary solution; a php script to talk to or a coldfusion server, or a java scriptlet thingey; anything else really that can talk to a data server without giving away the keys to the kingdom aka the credentials to the db server.

Python on the other hand is very good at connecting to just about anything : from csv files to xml to SQL in Oracle, Access or Mysql database servers : it all works. However, presentation wise, there is a lack of an easy presentation framework that works as in Flex. There are several ways to present your results in Python, but they are not baked in; you have to go and search them. QT, PythonCard, Tkinter and others are all there, but all have differences. All require an extended time to learn.

PHP is a mixture of both : it can connect to just about everything, but my personal opinion is that development is slightly more convoluted than Flex, plus you really need to take care not to mix code and presentation.

Using the various MVC frameworks around (Symphony is nice, but biiiiig to learn as it involves writing parts in YAML, yet another (markup) language) you can do this, but my personal opinion is that it’s a lot to learn if you just develop a few web pages. There’s Django for the pythonistas, which I’m partial to and keep returning to, but haven’t actually made anything usefull with.

It’s all good and well to have ‘flash and bang’ for your web customer, but you need to show them your data as well – unless it’s an arty type, he’s there  on your site for a reason : to get informed about something.

My hope is that the next flash version or flex version will have data binding implemented via another easier way; Adobe wants to make this big, it’s the reason why they open sourced flex in the first place…

Categories
Programming

Adobe Flex Builder 3

I went a bit out on a limb last weekend and purchased Adobe Flex Builder (standard edition). It lets you create in an easy way a layout for your flash-based application and then add some code to your elements using the open-source eclipse editor it’s based on.

Of course, it means learning a whole new programming language, actually two : ‘mxml’ for the layout and ‘Actionscript’ for the more codey bits. If you don’t see me or hear from me, that’s what I’m currently trying to do…
🙂

Actionscript and mxml are as much class and object oriented as Python, and where I could get away in Python with just writing some functions and calling them, here I definitely need to use classes, extend them, etc… something I never until now had to get my brain around. Ouch. Sometimes it hurts.

Another difference is that the language is much more strongly typed, you need to identify as much as possible the type of variable you are defining, while Python is much more loose about that.

Still, my first essay so far is a generic form page for telenet in Flash, and works fine. Now busy adding a captcha to it, for which I reused an actionscript component on the intaaaarrrnet.

Categories
Apple Programming

Moving Python on your iphone.

Moving your Applications directory to your /private/var/root partition (aka your MEDIA partition) is all well and good, but when you install python on your iphone, it’s installed in both /usr/bin where the main executable resides and the library modules are installed in /usr/lib/Python2.5 .

So they still consume a lot of space on your root partition. In fact, I finally checked my hard disk space on the root partition of the iphone, and there was a pityfull 4.2 Megabytes left over.

So I moved python over to the media partition using the following commands : I first created a python directory on my MEDIA partition, then I moved the python library directory over there and finally I created a symbolic link from there to where it is expected to be.

mkdir /private/var/root/python
mv /usr/lib/Python2.5 /private/var/root/python
ln -s /private/var/root/python/Python2.5 /usr/lib/Python2.5

After that, ‘df -h’ gave the message that 27 Megabyte was free on the root partition !

Excellent 🙂

Categories
Apple Programming

Iphone out of disk space ? Move your application directory to /var !

[I notice in my logs that lots of people still visit this link – you should no longer need to do this. Simply BlackRa1n your iPhone and install Cydia or Rock. They normally do this for you – I certainly no longer muck about with version 3.x of the iPhone OS. Plus with the fact that there is a virus out there for jailbroken iPhones… Be Carefull !!]

Any user who has logged into his iPhone via ssh (and has installed the bsd subsystem) or has used the installer.app terminal application can do the “df -h” command to get a human-readable output of his iphone partition setup.

It’s basically set up in two partitions : one root (/) partition and one /private/var partition which is mounted afterwards and tacked on to the root partition. It’s actually this /private/var/ partition that contains (under another subfolder ‘root’) all your music, videos and other media.

The root partition contains your installed applications (under the folder ‘Applications’, and since Apple locked the phone down and didn’t think anybody else would add stuff to it, it only provided a minimum of space for the root partition – 300 Megabytes or so. And your /private/var partition has close to 7+ Gigabytes !

With all the applications that I installed via Installer.App, I’ve recently gotten the message that the iPhone has low disk space on its root partition. I’ve got about 13 Megs free, and I dread adding other applications for fear of running out of disk space. Lots of bad things happen when your root partition runs out of diskspace…

So I’ve stumbled over another link that documents how to move your Applications folder to the /var folder so you can install all that you want.

You basically need to do the same thing that you do when you need space on another unix/linux machine :

  • modify your fstab file (which contains the list of partitions to boot) and remove the noexec option from the media partition so that it can execute programs. You can edit the file by copying it over to your computer and editing it there and saving it back (ALWAYS MAKE A BACKUP !) or by editing it directly via the Editor program you can install via installer.app.
  • move over your /Applications folder to /private/var/root
  • and then delete /Applications and create a symlink to the /private/var/root/Applications residing on the media partitition.

I haven’t tried this out yet, but my guess is that you can be much more selective by doing this one level deeper : installer.app for example, should be able to add all the new programs to the the /private/var/root/Applications partition, and then put a symlink to it in the original /Applications folder.

The advantage would be that

  1. you don’t mess with moving the Apple programs and applications
  2. your installer.app applications get backed up (I’ll need to verify if that’s actually true or not)
  3. your root partition will be able to function, even without a media partition (this won’t normally happen, but then I’m paranoid about things like this)

I’ll probably give it a test for installing python on the media partition, I’ll let you know.

Categories
Apple Programming

Dashalytics

I’ve set up Google Analytics for a website recently, to keep track of the visitor statictics. Free is hard to beat, after all.

What is even better is for mac users is a free widget called Dashalytics that allows you to keep track of the Google analytic reports, without you requiring to log in to the site ! So, by glimpsing your dashboard you can get an instant view of how your monitored website is doing, how many visitors, etc.

Real cool !

Categories
Apple Pictures Programming

A simple workflow for processing pictures

About a year ago I bought myself a new camera (a Sony DSLRA100) and it’s been a joy to use.

I had my sights on it for a few months, but it took me a long time to really convince myself to actually buy the camera. It’s not exactly cheap, but with a special price (100 euros cashback) and Fnac’s member day 10%, I managed to pick it up for quite a bit less than it was listed. Together with a 2GB Sandisk Extreme III Compact Flash card, I can snap away to my hearts content. Even with a 10 megapixel CCD it’s hard to fill up a card like that in a few goes. If you use RAW ofcourse, it’ll fill up easely !

As I said, the camera delivers great pictures, but each picture is 10 megapixels, jpeg fine (I keep away from RAW for the moment) and between 2 and 3 MB big. While this is fine, I want to keep my iPhoto collection snappy and use my hard disk for more than just my photo-collection. But at the same time I want to keep those originals stored away safely in case I want to edit them or print a huge poster of my children.

Aperture was out of the question, too expensive. So for now I’m using my own little manual workflow, using

  • Image Capture to get the picture from my camera and store them in a To-Process directory,
  • launch a bash script file that resizes each picture to 50% original and move the resulting files to another directory
  • and I then insert them in iPhoto.

The batch script file works wonderful, using ImageMagick, but I’ve been trying to use Automator to string the workflow together, but I can’t seem to get it to launch the bash script file correctly.

For now, I’m continuing doing this manually, until I either find out how to do this or give in and buy Aperture…

Categories
Apple Programming

Nike+ Ipod : what do you do when you forget it ?

It’s great to take your personal trainer and motivator along, but it’s less great if something happens.

What do you do when you forget to take along your nike+ iPod on your run, or heaven forbid, what happened to me, your latest and greatest run of almost 5 kilometers doesn’t get saved because you mucked around with your music after finishing your run ?

You yell. You shout damnation. And then you google around and hack the darn thing of course !

DISCLAIMER. You muck around with YOUR iPod at YOUR OWN RISK. Nothing is guaranteed to work, this is a hack so I could get my run up there. I am not doing this cheat, I want to keep a log of my runs.

With googling, I found my first reference to hacking the iPod sport kit – it’s simple really. You first need to configure your iPod in diskmode, otherwise you won’t be able to access it. Then you can find the files you need. They are in xml, so you can open them in textmate or smultron or textedit. Go to the following directory (I used midnight commander, a port installed unix utility, you could use XFolders) :

/Volumes/<name of your ipod nano>/iPod_Control/Device/Trainer/Workouts/Empeds/<hexfilename of your linkmodule>

You’ll find, beside a bunch of other files that you don’t need to touch, two directories : ‘latest‘ and ‘synched‘. Any files that are in the ‘latest’ directory are not yet synced with the nikeplus website.

So what I did was to browse the xml files in the’synched’ directory, find one where the distance and time where close to what I needed, and copied that file to my desktop.

I then edited it in textmate, and changed the time and distance to reflect my most recent run, to the best of my recollection. I roughly calculated the duration by multiplying the minutes and seconds in the duration string by 60 000. My guess is that the durationString and distanceString are the voice items that your iPod speaks to you, with the more correct variables in the duration and distance properties.

<time>2007-05-29T20:10:38+02:00</time>
<duration>1947280</duration>
<durationString>32:12</durationString>
<distance unit="km">4.8906</distance>
<distanceString>4.89 km</distanceString>

I also modified the start time lower down and deleted everything between the snapShotList property (this is when you press the center button to hear your status, it saves this as well) :

<startTime>2007-05-29T20:10:38+02:00</startTime>
<snapShotList snapShotType="userClick"></snapShotList>

I also renamed the file correctly to the current date and start time to run, and then copied the modified file back to ‘latest‘ directory. Then I ‘trashed’ the iPod to remove it, restarted iTunes and waited with my fingers crossed to see if the sync would happen. It did, and it uploaded it just fine to nikeplus !

My guess is that somebody with a bit more time and more inclination could easily whip up a website or program that would allow you to fill in a form and construct for you the correct xml file to import… It would be really handy for when you forget your iPod or lose oh so precious run data from your last run.