iPhone O2 – how to fix the image compression

O2 in the UK butcher images while using GPRS/3G/EDGE – seriously effecting the iPhone. Images are recompressed to horrendous levels – look at the App Store here:

photo.jpg

As you can see, the Facebook and Super Monkey Ball banners have been recompressed. This effects webpages aswell – meaning downloading new wallpapers or browsing Flickr is a waste of time. However, if you change the username for the O2 access point under Settings > General > Network > Cellular Data Network to “bypass” from the default “vertigo” like so:

photo.jpg

The compression is now turned off! Now the “whole internet in your pocket” is actually the whole internet in your pocket.

photo.jpg

Symfony in Enterprise – Tips and Experiences

200807021841.jpg

At work I am currently tasked with redeveloping an intranet application used to track customers, products owned, support contracts, support records and all sorts of other CRM-esqué functions. The version used at the moment is a very fast Perl/MySQL/Mod_perl/Apache setup built over a few years. Its got to the point where the company needs more functionality and hacking extra functions into the current code is getting more and more difficult.

Why Symfony? Why PHP?

The current trend for “rich internet applications” is Ruby on Rails. Ruby has very powerful Object Role Modelling features that completely abstract the database from your code – no more writing SQL queries once the initial database has been set up. Database tables become class generators and rows become class references, free to be instantiated, updated and saved. Symfony is probably the closest PHP Framework to Ruby, as it utilises the Propel ORM layer (so can use almost any RDMS) and has a full Model View Controller structure. PHP runs on the vast majority of Apache installations and requires no extra software installed on the server – in addition finding skilled PHP programmers is far easier (although this might change). Symfony is also probably one of the most well documented Open Source web framework projects that I have come across, featuring a whole book written by a member of the community very close to the development team, an expansive Wiki on the project homepage and hundreds of plugins to simplify everything from AJAX to RSS feed generation.

Symfony can be used in two ways – through config files (text files defined using YAML, a simple markup language) which are passed to Generators to create the final scripts, or by manually coding the actions and pages. In reality, a combination of the two will be used. Tweaking the included Administration Generator will yield respectable results for the standard CRUD (Create, Read, Update, Delete) functions and it is extremely simple to create modules and actions with the included command-line tool that creates skeleton templates for you to use.

No longer do you have to plug in debugging tools (such as the Xdebug php extension) to get decent errors and stack traces when your application fails – Symfony provides a development view of your application that will output extremely useful information (such as execution time, a list of all SQL queries made and globals) right in the page outputted to your browser. Debugging the application I’ve been working has been as easy as that of a desktop app (coming from my experience of Visual Studio) – Symfony will work in conjunction with many PHP debugging extensions for further information if you need it (I haven’t).

Plus, Symfony is good enough for Yahoo to use it for a 20 Million user app, Yahoo Bookmarks!

Results

I’ve been working alone for a month on the project and what strikes me is the huge amount of already achieved with no prior experience of Symfony:

  • A complete database redesign using the excellent MySQL Workbench. Adding many-to-many relationships where there were none before requires a good deal of thought but the results when the ORM classes are generated by Propel in Symfony are well worth the effort
  • Database migration handled by the CLI features of Symfony. One command will generate a .php file you can run at the command line (or cron job) with automatic access to all the features of your main application. Where the database had been vastly redesigned to support relationships, custom migration code had to be written (but where tables have not changed, you can copy table data directly in one line of manual SQL). The migration script takes about half an hour to run (approx. 3,000,000 records).
  • User security and session support, timeouts etc
  • Full creation and editing of all the major record types with administration control panels
  • AJAX views and manipulation of information with per-user rearrangeable panels ala iGoogle
  • Full filtering functions for searches with auto-paginated results (soon with Excel export)
  • Global per-user filters that effect all searches
  • …and lots of other actions specific to the application

Tips

Some advice to newcomers to Symfony from my experience:

  • Don’t rewrite the wheel. Use the plugins available and tweak them if necessary.
  • Use the Admin Generator, don’t fight it. Instead of writing custom create/edit/list actions when the Administration Generator does not meet your requirements (or altering the CSS won’t help), override templates with per-module versions of your own. Even better is creating a new Generator all together (although it is a headache writing PHP code that writes PHP code!) – check out the sfAdvancedAdminGenerator plugin for inspiration.
  • Don’t worry too much about performance especially if your application is running a bit sluggish on your local machine. On a proper server with a production installation of Apache and MySQL, the application I thought was a bit slow flew given the chance. You can optimise later.
  • Don’t be scared of upgrading – I went up a symfony version during production without a hitch and without a change in my code (from 1.0 to 1.1 this will be different)
  • Use a decent IDE. I use PDT Eclipse and it definitely speeds up development. You will frequently have to edit several files at once so at least use a text editor with tabs.
  • Read the book! I can’t stress this one enough. It is extremely well written and is available for free on the website.

I’ll post some more impressions and a brief postmortem when the project is finished.

Vista net problems? Disable auto-tuning

I have been having a problem where I would get “This page cannot be displayed” errors the first time I tried to access a website. The odd thing was that hitting Refresh would solve the problem and I would get through to the site immediately. At first, I thought it was a DNS problem due to the Internet Connection Sharing setup, but turns out it is Vista messing around with the net connection with a process called “Receive Window Auto-Tuning” (this alters the size of the packets on your network based on network conditions).

To turn this off, fire up an elevated command prompt window and type in “netsh interface tcp set global autotuninglevel=disabled” without the quotes. This solved all the problems I was having with my net connection in Vista SP1. Strange.

image

XNA2.0 Dependency checking

After a lot of trial and error using Process Monitor and Virtual PC, I have finally sussed out exactly what XNA2.0 games on Windows need to run. The requirements are slightly different to XNA 1 games.

Direct X runtimes

There are four files that need to be installed in the system32 folder for XNA to initialise properly. They are:

  • xinput1_3.dll
  • x3daudio1_3.dll
  • d3dx9_31.dll, and
  • xactengine2_9.dll

The first three can be placed alongside the application exe and then load fine, but xactengine2_9.dll does not load this way for some reason, and has to be present in the system directory. Distributing these files alongside the application breaks the DirectX EULA, so they have to be installed using dxsetup.exe.

To check the presence in your XNA game, just put this code in Program.cs before game.Run() is called:

bool HasAllPrereqs = true;
// check all the required files, if any missing, return false
if (!System.IO.File.Exists(System.Environment.SystemDirectory 
    + "\\xactengine2_9.dll")) HasAllPrereqs = false;
if (!System.IO.File.Exists(System.Environment.SystemDirectory 
    + "\\d3dx9_31.dll")) HasAllPrereqs = false;
if (!System.IO.File.Exists(System.Environment.SystemDirectory 
    + "\\x3daudio1_2.dll")) HasAllPrereqs = false;
if (!System.IO.File.Exists(System.Environment.SystemDirectory 
    + "\\xinput1_3.dll")) HasAllPrereqs = false;

If HasAllPrereqs is false after those lines, exit the application before it crashes horribly when XNA tries to initialise.

Visual C++ 2005 SP1 runtimes

Even a fresh Vista install doesn’t have these. They are provided when updating Visual Studio 2005 to SP1, or installing SP1 of the .Net Framework 2.0. However, Vista comes with SP0 of .Net 2.0, meaning 99% of machines you come across will be lacking what XNA 2.0 needs. There is a 2.5MB standalone installer on the MS download site here which installs what you need even on .Net 2.0 SP0 machines. .Net 3.5 installs Net 2.0 SP1.

So if any of the following are installed, we safely have the right Visual C++ 2005 runtimes:

  • .NET Framework 2.0 SP1
  • .NET Framework 3.5
  • Visual C++ 2005 SP1 Redistributable

By looking up the product codes in the registry, we can also check at runtime if we have the runtimes (again, before game.Run()):

[DllImport("msi.dll")]
public static extern Int32 MsiQueryProductState(string szProduct);

…goes before the main application entry point, and

bool vccOK = false;
// check for VC++ 2005 SP1 redist (very rare in the wild)
if (MsiQueryProductState(
"{7299052b-02a4-4627-81f2-1818da5d550d}") == 5) vccOK = true;
// check for .NET Framework 2.0 SP1
if (MsiQueryProductState(
"{2FC099BD-AC9B-33EB-809C-D332E1B27C40}") == 5) vccOK = true;
// check for .NET Framework 3.5 (includes 2.0 SP1)
if (MsiQueryProductState(
"{B508B3F1-A24A-32C0-B310-85786919EF28}") == 5) vccOK = true;

If vccOK is still false, exit the application before you call game.Run().

Free pro Microsoft tools for students

image

Wow. Microsoft has just launched “DreamSpark” – a programme that lets higher education students download pro Microsoft development tools – not the cut-down Express versions of Visual Studio, but the full Professional editions. UK Microsoft student champ Ed Dunhill sums it up the best on his blog here.

You get access to:

  • Visual Studio 2008 Pro
  • The whole Expression suite
  • SQL Server 2005 Developer edition
  • Windows Server 2003 Standard (and hopefully soon 2008)
  • The best bit is a whole years XNA Creators Club subscription FREE! This costs £65 normally with no real free alternative to get games running on the Xbox.

This is evidently a battle against pirated versions of the above products and this is the perfect way to do it. To enroll in the programme, your University needs to provide a Single Sign On authentication system to verify you or you need a ISIC card or NUS Extra card. Unfortunately, Oxford Brookes doesnt have a SSO Auth system (and I doubt they ever will – Oxford Uni does though) so I have had to order an NUS Extra card for a tenner to get in. Your status as a higher education student needs to be verified once a year, so students leaving Uni soon should sign up quick. Other than the XNA Creators Club subscription, I don’t think the products have time limits.

Expect Adobe to follow suit soon with their products if they want to get students hooked – although the academic discounts on Adobe CS3 stuff are great (only £400 for the Master Suite, down from £2500…) students will still pirate. Give students free access to professional tools and they’ll get hooked on them and buy them when they are earning a living.

iPhone improvements for the UK and Japan

El Reg is reporting that O2 has been told by Apple not to release sales figures until Apple say so.

UK carrier O2 has confirmed that Apple has placed it under a gagging order to prevent it from publicly revealing how many iPhone handsets it’s sold to date.

The company’s head of media relations, Simon Lloyd, told Register Hardware that it’s a stipulation within the company’s sales agreement with Apple that O2 can’t release any such details until the Mac maker says so.

Lloyd would only say that O2’s UK iPhone sales in the two weeks up to Christmas period were “in line” with its expectations.

This is because the iPhone is completely bombing in the UK. Being in a University environment (where students always like tech gadgets), the only iPhone I have seen in the wild is an unlocked hacked-to-bits US model. The iPod Touch is undoubtedly a sound investment at just shy of £200 if you want a taste of “next gen” touchscreen interfaces and you are far better off buying an iPod Touch for the fancy new iPod bits and getting a free phone on a cheaper contract. You would have to be a complete mug (or rich fashionista) to buy an iPhone at £269 and be locked into an 18-month contract with O2 at £35 a month.

If the iPhone actually did half the things standard UK mobiles have done for years, it would maybe be an acceptable high-end phone model, but its not. The US mobile industry is a couple of years behind ours (people import our Nokia N95s for instance) so the iPhone looks like a fantastic bit of kit in the US.

The funniest thing is that the iPhone will be on DoCoMo in Japan soon – and it will need a complete feature overhaul to be even classed as a ケイタイ (keitai, mobile phone) out there, let alone here. To work in the Japanese market, Apple need to add:

  • 3G support. GSM/EDGE/GPRS do not exist there.
  • MMS support for their mobile email with emoticons (絵文字, emoji). Without emoticons, users will get gibberish when recieving mails from “proper” mobile phones in Japan.
  • Java application downloads for iAppli
  • Flash Lite for the on-demand games that are springing up on the Japanese mobile internet
  • QR barcodes. Apple should be pioneering these in the rest of the world already with their clout, but aren’t. The possibility is enormous here – in a music magazine, a QR code could be next to a new album review: the user scans it and can buy it from iTunes immediately over the air, no text input required. This happens in Japan already for all sorts of mobile content – Apple could be making this popular everywhere.

The Japanese text input is already programmed and is damn good on the iPod Touch, so that doesn’t need doing. Stuff like IC chips aren’t required, so its only those five points that I cannot see Apple surviving without. Windows Mobile phones released in Japan on Softbank now get an application for MMS with emoticons because the original models were seen as pretty basic without it.

Sort it out Apple!

Taskbar invisible over Remote Desktop

I frequently use Remote Desktop (RDP/Terminal Services) to access my machines running Vista SP1 RTM. 90% of the time, after connecting, I get this annoying problem with the Start bar:

image

Only the Start button itself is visible.

  • This happens on all my Vista machines, both SP0 and SP1
  • This happens no matter what version of Remote Desktop I am using, the XP version or the “new” Vista one
  • It only appears to happen when the computer was originally using the Aero DWM composition engine and originally in a different resolution to what I am asking the Remote Desktop session to render
  • It happens wether or not the taskbar is at the top or bottom of the screen

So far the only way to get the taskbar back I have found is to click the lonely Start button, click Windows Security, choose Start Task Manager, kill the explorer.exe process and start it again in the Task Manager from File > Run.

Subsequent Remote Desktop connections are then fine, but logging back into the machine from the console then back into Remote Desktop makes it disappear again. A bit frustrating, to say the least.

Microsoft Inspiration Tour

IMAGE_113 Oxford Brookes hosted one leg of the Microsoft Inspiration Tour today, where Ed Dunhill and Busted-lookalike Ben Coley sent out the marketing message to Brookes students about the latest MS tech: Silverlight, Popfly, Windows Embedded, XNA etc. I had to leave halfway to get to work, but it was very interesting.

Unfortunately there was nothing new for people who already follow Microsoft news and tech such as myself, and the demos I had all seen before. This is the second time I have sat through the Fantastic Four Silver Surfer trailer on the Silverlight Fox movies demo site at a Microsoft event. Interestingly they had to bring a Xenon 360 devkit in for the XNA demos since they couldn’t definitely get an Xbox Live connection at the events they visit – which is required to run XNA stuff on a retail box. The presentation was a tiny bit out of date, for instance Silverlight 1.1 is now 2.0.

Around 70 people had signed up for the event, but just about 30 turned up. This isn’t the fault of the marketing or the presentation itself (although Wheatley campus no doubt had something to do with it), but because simply Oxford Brookes is not a Microsoft shop. They mentioned that all the technology they were showing has one thing in common – the .NET Framework powers all of it. However, try finding a computer in the Brookes computer labs even capable of running a simple .NET Framework app (seemingly none of them have any version of the runtime installed). Furthermore, despite having excellent fully-functional versions of Visual Studio now available completely free as Express editons, these are not on lab computers and no C# or .NET content is taught on any Brookes courses that I know of. Introductory programming classes are still taught in Pascal using Delphi – leaving students scrabbling around to try and find a free version of Delphi 6 every year. Brookes isn’t allergic to .NET though (my final year project uses it extensively for ASP.NET and XNA) and will let you use it when a programming language isn’t specified.

Maybe Microsoft should be giving an “Inspiration Tour” to the lecturers at the university instead, they could call it “Teach your students something relevant! Tour”. When the question “Who has heard of the .NET Framework?” was asked, 5 people put their hands up out of 30. These are meant to be computing students with an interest in technology – even my friend who is an Apple disciple knows about .NET.

Tomoyo 0.5 theme for WordPress

UPDATE! This version is out of date, please see the latest verson on the main theme page here: //www.edandersen.com/projects/tomoyo-wordpress-theme/

 

EdAndersen.com - Windows Internet ExplorerI toiled away for quite a while to create this WordPress theme which I think is pretty unique. I’m offering it up to the WordPress-using world. Just unzip into your themes directory.

Download Tomoyo theme for WordPress (303kb zip)

Features include:

  • Sexy Flash-based headings using sIFR, for post and page titles and sidebar headings (degrades gracefully when no Flash or Javascript available)
  • Full WordPress Widget support with three sidebars to customise (the one on the right, and two in the footer)
  • No horizontal scrolling on a 800-wide screen (perfect for eeepc users!)
  • Uses the new Meiryo Vista font if available for seamless latin and japanese mixed text
  • Tested with WordPress 2.3

I still need to style the comment system and there are a few rough edges, but I thought I’d release it anyway. All you need to do it change the header image from my ugly mug and its pretty much your theme!

Windows Live ID Return URL banned words

UPDATE: No need to do this now, its fixed!

For edngames.com I use Facebook, Yahoo! and Windows Live as sign on solutions. However, Windows Live is the only system with a restriction on the domain names you can register. For instance, because of the word “games” in my domain, I get the error message “The Return URL field contains a forbidden word or domain. Please use a different Return URL and enter the HIP solution again.”

image

Facebook and Yahoo, competing single sign on solutions, do not have this restriction, which the word “game” I assume is to block gambling sites from the authentication.

To get around this, I have had to set up a dummy domain (edslife.co.uk) without the banned words and perform authentication on that – you cannot simply do a redirect because the signature returned by the Windows Live server will be invalid because its a different return URL. I then have to create my own authentication (I use a hash function based on the time and a secret word) to move between the dummy domain to the real one securely.

image 

Although this works, and is just as secure as authenticating on the target site I reckon, it provides a pretty shoddy user experience because I have to explain that there is another domain name involved. You also cannot use this method to get data from the Windows Live server such as contact information because from a different domain, the authentication is invalid.