January 19, 2012

Android 3D Font Example Source Code

As requested, I’m making the source to the 3D font example available. This code and hasn’t been optimised or even thoroughly checked, use at your own risk.

Get it HERE


Posted by under All,Android,Coding,Demos | Comments (7)

December 6, 2011

Rooting The Kindle Fire and Sideloading Google Apps

I picked up a Kindle Fire on my recent trip to the US. It’s a very nice bit of kit at a great price. However, as a UK based Amazon customer, I’m unable to download anything from the Amazon marketplace, so getting the Google market installed was a priority.

Rooting was very simple, SuperOneClick did the job in a flash. Getting the Google Apps sideloaded was a little more tricky. Most of the guides out there (I used this one) tell you to download RootExplorer to do the legwork of installing the APKs that provide the Google services, but as mentioned, UK Amazon accounts can’t get content from the US Amazon Marketplace. I did try to manually install the apps via ADB and later with a Terminal app that I managed to snag from GetJar, but all I got was crashes and error messages.

Eventually I went digging and managed to turn up an APK for Root Explorer on the web. After installing the tool I was able to get the GoogleFramework tools and Vending.apk (called com.amarket.apk in the package I found) installed. However, I still couldn’t get at the market, it force closed every time I logged in.

After a night’s sleep I re-read the guide and realised that my problem was a case of RTFM. I had installed vending.apk in /data/app (where normal apps live) instead of putting it in /system/app (there is a bold section in newer guides pointing this out). Now my Kindle has full access to the Market, I’ve downloaded a bunch of apps and even got rid of the Amazon launcher in favour of GO Launcher EX which gives a more familiar Android experience.

I’ve written up my experiences in the hope that they’ll help any non-US Kindle Fire users get their devices rooted and sideloaded with Googly goodness.


Posted by under All,Android | Comments (0)

November 11, 2011

Things I Learnt Today #3 – How To Configure Apache Properly

Recently my Ubuntu Apache server crashed during a busy period on the site, one of the last events logged was:

[error] server reached MaxClients setting, consider raising the MaxClients setting.

The default for MaxClients in apache2.conf is 100. The log suggested raising this value, many sites I Googled up suggested raising the value too. There’s also a fair amount of confusion about the correct setting for StartServers, MinSpareServers and MaxSpareServers values.

After raising MaxClients to 200, the server conitinued to fail at peak times. I raised it to 300 and got a message from Apache that the value exceeded the maximum value and had been rolled back to 256. Juggling the Min/Max values made little difference and the server continued to be unreliable.

I needed the server to be reliable, I sat down to work out the problem logically.

  • I determined the Multi-Processing Model (MPM) that my server was using. (“apache2 -l” lists the modules compiled into Apache, look for prefork or worker) which indicates which area of the config file to concentrate on.
  • Next I calculated the average and peak memory requirements of each client thread. “ps axo ‘size cmd’ | grep apache2 | grep -v grep” will list the current apache processes and the memory used by each. Running this command at regular intervals with Cron and piping the output off to file allowed me to calculate an average load of 10Mb per process, with a peak value of 35Mb.

Suddenly the reason for the crashes became clear, 256 theads of up to 35Mb works out to around 9Gb of allocated memory. My server only has 512Mb of RAM and a 1Gb swap partition.

Allowing 50Mb for MySQL and another 50Mb for the other system services, I set the MaxClients to 20. This means a maximum memory load of 700Mb from Apache. The server hasn’t crashed since, and although I get the MaxClients message in the logs, there’s no real slow down evident to visitors.

So there you go. If you’re running a site with MediaWiki or Drupal, PHP is generating heavy memory loads on your Apache processes. Even the default value of 100 for MaxClients will seriously overallocate most servers unless you’re got around 4Gb of memory available. My site gets reasonable traffic (~7000 page views a day) and runs quite happily in 512Mb now that Apache is properly configured.


Posted by under Linux,Things I Learnt Today | Comments (0)

April 22, 2011

Router Recovery

After getting all the bits together to build a JTag cable and saving a bunch of useful webpages on my laptop, I tried one last time to get my router to talk to me before opening the case up.

Due to some fat fingered typing when setting a static IP on my computer, I accidentally put the PC on a 192.168.1.0/24 network. However, the router responded to pings on that subnet and I was able to TFTP a copy of the firmware to the device. After a reboot, the thing came back to life like nothing had happened.

I was relived to say the least, but still don’t really understand why it wasn’t on the default 192.168.0.0/24 net. Still it’s working now and that’s the main thing.

So, do I dare try to upgrade the firmware again?

Posted by under All,Hardware | Comments (0)

April 20, 2011

Router Nightmare

I seem to be getting through routers at an unusually high rate. I’m on my fourth in three years.

The previous victims had all been D-Links, which expired with depressing regularity. However,  the latest is a NetGear DGN2200 purchased in Dec 2010 which has been until recently. Over the last couple of weeks it has started to randomly drop out, losing Internet connectivity for around 10mins at a time.

Last night I had two drop outs in quick succession and I decided to log on to the admin page to see if anything was causing the problem.

One of the nice things about the router is that it automatically checks for firmware updates when you log in to the admin page. However, one of the bad things is that it doesn’t tell you when the update process is complete. I reset the router after about 10 minutes of inactivity and the damn thing died completely.

All I’ve been able to get since is a red power LED at boot and two flashing green LEDs (Ethernet Port #1 and Ethernet Status)  after about 20 seconds. The router won’t give out a DHCP address and I can’t connect via a static 192.168.0.0/24 address either.

Digging around the web suggests that I might need to build a JTag cable to re-flash the board directly. That would be an interesting project if I was doing it for fun on hardware that I didn’t care about, but as I’m tethering my phone to get Internet at the moment and Mrs Codehead is getting fed up, there’s a high level of urgency to get it right first  time building up.

Posted by under All,Hardware | Comments (0)

March 13, 2011

Regular Quad Based Glyphs For The Android Text Renderer

Here’s a quick screen shot of the latest work on the Android GL font renderer.

The 3D font is now rendered using regular quads. This means that you can apply regular translations and rotations to the text and have much more flexibility than the original DrawTex rendered fonts.

The downside is that the output will probably look worse in most situations, and at the moment, the code is quite slow.

I’m not releasing this as an update just yet. I’ve had to hack the older code around alot and the 3D text needs optimising, but I thought I share it as eye candy.

Posted by under All,Android,Coding | Comments (8)

March 9, 2011

Android Bitmap Font Renderer Text Scaling Feature

After Matt’s question about text sizes and Bxm’s correction of my brainfart, I’ve added scaling to the Android text rendering code.

The new SetScale() function is overloaded to provide two scaling methods. The first uses a single float value which preserves the aspect ratio of the quad when scaling the text output, the second allows the width and height scales to be specified independently with two float values.

The default scale value is 1.0, this is set when the font is initalised. This value produces regular text with no scaling. Setting the value to 2.0 produces double size text and a value of 0.5 halves the output size.

Read more…

Posted by under All,Android,Coding | Comments (7)

March 5, 2011

Customer Service FTW!

I coudn’t put up with the stupid keyboard on the new HP laptop, so I took it back to Currys after a just one day of use. I was expecting them to turn me away as I had opened the box, trashed all the sticky plastic protectors and generally messed around with it. However, as I hadn’t registered it (does anyone ever use that free junk that comes pre-loaded?) and I’d run the restore wizard to return it to the OOBE state, they happily let me choose another laptop.

I settled on an Acer 5742 i5. It has pretty much the same spec as the G62 but it has a proper keyboard (including numeric pad), no softkeys and a touchpad that’s delineated by a tray. It’s so much better and has given me no stress at all so far. I should never have turned my back on Acer.

So, I’d like to thank the guys and gals at Currys for genuinely surprising me with their excellent customer service and I’d like to tell HP that they need to sack their designers and get some usability testers in.

 

Posted by under All,Hardware,Personal | Comments (0)

March 4, 2011

New Laptop, Stupid Design

I picked up my lovely shiney new HP G62 laptop yesterday. Although it’s much faster, smaller and lighter than my old Acer, there’s a couple of design issues that have me wondering if HP did any user testing before put the thing into production.

Firstly the touchpad is completely smooth and flush with the case. This means that you cannot find the edge of the pad by feel. This makes the edge scrolling feature far less intuitive. However, this is offset by the multi-touch feature that allows scrolling by using a two finger stoke. Not a huge problem, but it’s annoying and could have been easily avoided by sticking to accepted convention of having the touchpad in a tray or adding raised edges.

The second (and bigger) issue is the positioning of the soft keys for email, web, calculator, etc. I’ve never been a big fan of softkeys, but they’re normally out of the way above the keyboard. For some reason, HP have moved them down to form an extra column on the left side of the keyboard (the Insert, Delete, Home, End and  Page Up/Down keys form a matching column on the right side just to really throw you off). This means that when you type by feel, pressing ctrl opens the calculator, pressing shift invokes print, caps lock starts your browser and tab opens a media player. I had only been using the machine for a few minutes when I was ready to launch it across the room in frustration at the constant interruption of the calculator and printer dialogs popping up while typing.

The laptop does go to great lengths to look stylish and break the grey box/black box mould that laptops tend to conform to, but changing established design practices for purely aesthetic reasons is just plain stupid and has resulted in the product being close to unusable for me. I get the feeling they’re trying (a failing) to emulate a MacBook keyboard

I’ve had a dig around the Net and it seems I’m not alone in finding these design choices difficult to work with. There are a few hacks that work around the problem ranging from registry tweaks to custom hotkey scripts and even physical mods to the keyboard, but there is nothing that relieves the problem completely. The HP forum offers no hope of an offical fix and I’m beginning to wonder if I might be better off just returning the unit to the store before the ‘cool down’ period ends.

Posted by under All,Hardware,Personal | Comments (1)

February 18, 2011

Alternative Load Function for Android BFF Loader

In response to Luis’ problems with the Android port of CBFG’s Bitmap Font loader, I’ve re-written the loader to only use read() and provide a bit more feedback if things go wrong. The new load function is called LoadFontAlt() and as before, the BFF file should be placed in the Assets folder of your project.

The old LoadFont() function is still present although LoadFontAlt() will replace it once I’m happy that it is performing correctly.

Get the source HERE

Posted by under All,Android,Coding | Comments (25)

Next Page »