More G1 Multitouch progress

January 25, 2009

Luke Hutch has improved on his modified Java stack method and has provided a full G1 image that has multitouch support built into the kernel.  It’s a little rough around the edges, lacking OpenGL support on the zoom features, but the idea is there.  Somebody just needs to come forward and do the necessary work on the hacked applications to make them run smoother.

I posted recently to show that working multi-touch input is available on the T-Mobile G1 phone. Now the necessary changes to the Android software stack are finally in good shape, and the software is easily installable on your own phone. (”Easily” being a relative term of course — you have to re-flash your phone’s firmware, and that may void the warranty…)


A Plague of Tics

January 22, 2009

From David Sedaris’ Naked:

When the teacher asked if she might visit with my mother, I touched my nose eight times to the surface of my desk. “May I take that as a ‘yes’?” she asked. 

According to her calculations, I had left my chair twenty-eight times that day. “You’re up and down like a flea. I turn my back for two minutes and there you are with your tongue pressed against that light switch. Maybe they do that where you come from, but here in my classroom, we don’t leave our seats and lick things whenever we please. That is Miss Chestnut’s light switch and she likes to keep it dry. Would you like me to come over to your house and put my tongue on your light switches? Well, would you?”

I tried to picture her in action, but my shoe was calling. Take me off, it whispered. Tap my my heel against you’re forehead three times. Do it now, quick, no one will notice. 

“Well?” Miss Chestnut raised her faint, penciled eyebrows. “I’m asking you a question. Would you or would you not want me licking the light switches in your house?”

I slipped off my shoe, pretending to examine the imprint on the heel.

“You’re going to hit yourself over the head with that shoe, aren’t you?”

It wasn’t “hitting” it was tapping; but still how had she known what I was about to do?

“Heel marks all over your forehead,” she said, answering my silent question. “You should take a look in the mirror sometime. Shoes are dirty things. We wear them on our feet to protect ourselves against the soil. It’s not healthy to hit ourselves over the head with shoes, is it?”

I guessed that it was not.


Battlestar Galactic-hotty

January 19, 2009

I came across this article in my RSS feed today.

As a huge fan of the re-imagined series I gave the original a shot (it’s on instant Netflix for anybody who’s feeling masochistic) and just couldn’t sit through an episode.  The character I couldn’t tolerate on the original show was Starbuck, ironically.  He was obnoxious, cheesy, and annoying.  This article just proves that I’ve got one hell of an eye for awful acting.

This guy seriously has the balls to ramble for way too long about how he invented Starbuck, and how his cigar smoking, womanizing, elitist pilot was the man Starbuck should have been.  Yet in this diatribe where he spends all of his time trying to justify why the new Battlestar Galactica sucks, he still can’t hide the fact that he’s a bitter, sexist old man who’s just pissed off that a couple of hot babes turned his failed show (and failed character) into a runaway success.

But who am I kidding?  Just click the link for the images of Tricia Helfer.


Jailbreaking is for little girls

January 17, 2009

The main difference between nerds who jailbreak their iPhones, and geeks who root their G1 is that the iPhone users jailbreak so that they can have access to new MMS applications, or trivial options like themes (note that a real keyboard or user-changable battery isn’t going to come from a jailbreak).  For us G1 owners, we root our devices so that we have even more access to the hardware.  Can I already do barcode scanning, install multiple web browsers, change my background (and battery), and extend the functionality of every app installed on my device?  Yeah, I can do that the minute I walk out of the T-Mobile store.

The purpose of rooting a G1 is to bring it to the freedom of an Android Dev Phone that you would purchase from Google.  It removes those last threads of cell-provider nonsense.  Even with the G1 RC30 image installed (I could have opted for an ADP1 image if I wanted) I still have the total freedom I want, and access to the Amazon Mp3 store.  Now I’ve got a device that is truly open.

So what’s on the horizon?  Probably tweaking of low level functionality, like custom app install locations, tethering, virtualization, etc.

Why do I do this?  Simple.  Because I can.


Am I blind?

January 15, 2009

This is less of a blog post and more of a note so that I never forget this in the future, but has anybody ever had trouble configuring PEAR on a XAMPP installation on Windows?  For whatever reason I couldn’t find the damn setup utility and by a fluke while configuring FirePHP I came across it today. 

So Scott, next time remember to run: xampp\php\go-pear.bat

Thank you.


Whoppinated

January 14, 2009

Last Friday, Lifehacker blogged about this piece of Burger King marketing:

Whoppinator

That’s right.  Sacrifice 10 friends and Burger King will give you a free Whopper.  Is that not fantastic?

Unfortunately if you try to Whoppinate any more of your Hanson-loving loser vegan Scientologist friends, you will now see this:

WhoppinatedIt’s a damn shame.  Here’s what Facebook had to say about their decision:

We encourage creativity from developers and brands using Facebook Platform, but we also must ensure that applications follow users’ expectations of privacy. This application facilitated activity that ran counter to user privacy by notifying people when a user removes a friend. We have reached out to the developer with suggested solutions. In the meantime, we are taking the necessary steps to assure the trust users have established on Facebook is maintained.

I’ve only got one thing to say to you, Facebook.  Fuck you.


Practical multi-touch on the G1

January 12, 2009

Head on over to Luke Hutch’s blog to check out his G1 multi-touch demo. Unlike the previous proof-of-concept video from November, Luke has demonstrated multi-touch on a recompiled Android Java stack as opposed to a hacked kernel.


e^(2πi) is the loneliest number

January 10, 2009

Adobe Flex is cool and all, but why settle for one framework when you can make it more powerful with a second?  Recently I developed an application which was using all PHP on the backend, and all Javascript on the frontend.  I developed the PHP interface so that all interactions from the frontend occurred via AJAX calls to a gateway class which was just a list of entry functions that would in turn call library functions and then echo out a JSON encoded result.

Since all of the frontend functionality was focused on the gateway, and nothing past that, I figured I could really test this library by developing a second frontend with a second gateway.  Within about 2 hours I had a working frontend for the application running on Adobe AIR using AMFPHP as an interface for remoting calls to the PHP backend.  Here’s a run down of how I set this up.

You can grab AMFPHP from the developer’s homepage.  AMF is a binary serialization format for Action Script objects to all messages to be sent to server-side services, and AMFPHP is just a PHP implementation of that format.

Installation is quick and easy, just drop the amfphp/ root folder into the htdocs directory of your web server.  To test out the installation, go to http://localhost/amfphp/browser/.  If all goes well, you should be presented with a Flex application.

For the PHP code, we can keep it simple.  Create a file with a matching classname.  I named my class AirDemo and saved it as AirDemo.php:

class AirDemo {
    public function helloWorld( $a_name )
    {
        return "Hello, " . $a_name;
    }
}

Now stick that PHP file into a folder, let’s call it airdemo_library, and then stick the folder in the amfphp/services directory.  Restart the amfphp/browser/ application and you’ll now see airdemo_library in the left hand tree.  Expanding that will give you the AirDemo class, and then you will be able to test out communication by sending requests manually.

Setting up the Flex side is a little more involved.  First, create a services-config.xml file under your src/ directory:

<services-config>
     <services>
          <service id="amfphp-flashremoting-service" class="flex.messaging.services.RemotingService" messageTypes="flex.messaging.messages.RemotingMessage">
          <destination id="amfphp">
          <channels>
              <channel ref="my-amfphp"/>
          </channels>
          <properties>
               <source>*</source>
          </properties>
          </destination>
          </service>
     </services>
     <channels>
     <channel-definition id="my-amfphp" class="mx.messaging.channels.AMFChannel">
          <endpoint uri="http://localhost/amfphp/gateway.php" class="flex.messaging.endpoints.AMFEndpoint"/>
     </channel-definition>
     </channels>
</services-config>

The only thing to pay attention to here is the endpoint uri argument needs to point to your AMFPHP installation.  This essentially tells Flex where to find the remoting gateway.  We then tell Eclipse to look for this remoting gateway by adding a line to the Flex compiler options:

config_options

Now we’ve got Eclipse configured to compile your Flex/AIR application so that it’s aware of AMFPHP, all that’s left is to actually use it.  This is the easiest part.  I’ve created a simple application that provides a text box and a button, and when you click the button it calls the helloWorld( ) function that I’ve already declared on the PHP backend.  So the user will type in a name, click the button, and get a message back from the server.

To hook up the remoting methods, add this to the top of your MXML document:

<mx:RemoteObject id="airdemo_service" fault="faultHandler( event )" showBusyCursor="true" source="airdemo.AirDemo" destination="amfphp">
     <mx:method name="helloWorld" result="resultHandler( event )" />
</mx:RemoteObject>

The RemoteObject id is whatever you’d like to refer to your remote library as within your ActionScript, and the source is the library.class you are defining remote methods for.  Each mx:Method you declare uses a literal string to identify a remote function, as well as a local ActionScript function that will handle the result.  To call the function, just call it like you would any ActionScript function:

airdemo_service.helloWorld( txtName.text );

And that’s that.  Here’s a screenshot of the end result:

app_demo


(Insert Windows pun here)

January 9, 2009

Hold on a moment while I pour another beer.

I decided to be persistent tonight. Rather than copy my 80 some gigs of music and additional 60+ gigs of code, documents, pictures, etc I opted to try out a full OS upgrade. I haven’t done it in ages, and I wanted to see how it would turn out.

I think it’s my anal-retentive side that’s saying I’ll be doing a full re-install tomorrow when I get my beta key. This just doesn’t feel right.

That bit aside, I’m really enjoying this. I tend to be a Windows sympathizer rather than a Windows fan, but this totally kicks ass. My first impression was simply “It’s quick.” There’s just something more there which probably stems from taking the Vista formula and washing/rinsing/repeating for the last 3 years to optimize the hell out of the core system. I know Microsoft has been doing heavy research into lightweight kernels, but last I checked none of those were making it into Windows 7. It seems something made it in, because this is damn fast.

Aside from the gentle flow that everything seems to have, most of the new features (multi-touch not included) appear to add to the simplicity of the interface. Gadgets are no longer shackled to a sidebar, and the screen resolution is accessible by a simple right click on the desktop. You can customize every single system tray icon to tell it which ones you want to hear from, and which ones you don’t.  It’s not form over function, but it’s not vice versa either.  The designers have struck a balance and it works.

It’s not all fun, it’s still a beta after all.  I had to work a little command-line black magic to get Chrome to run on the 64-bit version, and it appears as though Songbird wants to hijack my network connection.  I’ll have to work on some development this weekend to see how it handles under some level of stress, but I’m not holding my breath on any epic failures.

Edit: The Chrome tweak required that I add ‘ –in-process-plugins’ to the end of the target in Chrome’s shortcut.  There’s two dashes in that first dash, not one.  Type the argument in, don’t copy and paste it.  Otherwise it won’t work.


Stubborn objects

January 7, 2009

When I think about persistent data the first idea that always pops into my head is, “singleton.” It’s simple, it’s elegant, and it works. It’s not difficult to implement a singleton in PHP. Set a private constructor, private static member and instantiate the object by calling some public function (usually instance( ) ).  Like so:

<?php
class Singleton {
     private static $singleton;  

     private function __construct( ) { }

     public static function instance( ) 
     {
          if ( ! isset( self::$singleton ) ) {
              $class = __CLASS__;
              self::$singleton = new $class;
          }

          return self::$singleton;
     }
}

$object = Singleton::instance( );
?>

The problem with using a singleton in a server-side language like PHP is scope.  Scope in PHP is based upon requests, which rules out using a singleton pattern if your application is trying to access the persistent data via an AJAX call or something of that sort.  In developing an application that used no PHP on the frontend and relied on all of it’s data by making AJAX calls to a PHP library, I wasn’t able to maintain state on my database with each request.

The goal of this application was to minimize database calls in order to speed up the operation.  We were using an older version of the app at the time which ran on EWD and essentially used a mixture of AJAX and direct database calls for every single operation.  It was slow.  My new design synchronized the database whenever needed and stored it on the PHP backend.  Lets call this class Database.

Database is a class which needed to behave like a singleton.  After all, this library was developed to be portable and therefore all communication was occurring through a series of gateway classes that acted as an interface for AJAX, AMFPHP, or whatever other framework one could dream up.  All of the operations happened during AJAX requests, and therefore a singleton implementation wouldn’t suffice for Database.  The class holds a replica of the existing database so that queries are made to the object rather than the database itself.  This eliminates calls assuming the data we have in the Database object is correct.  There was just no way to use a singleton pattern to keep this object alive and kicking from one request to the next.

Fortunately, PHP provides the tools necessary to handle this. Sessions are a persistent environment where you can store necessary data, and that’s exactly what I did.  Utilizing a tool built into PHP I was able to handle keeping my database object “alive” in the background while the Javascript on the frontend formatted and displayed whatever data I was sending back.  PHP has built-in object serialization (as most modern languages do).  Serializing encodes a custom object into a bytecode string which can then be transformed at any time back to it’s original data type and state. A typical call originating from my gateway would look like this:

public function someFunc( ) { 

    // Fetch the database from the session
    $database = unserialize( $_SESSION['database'] );

    // Query or tweak the database, letting the database
    // object handle any direct DBMS queries if the
    // database was altered. 

    // When finished, store the database back into the
    // session
    $_SESSION['database'] = serialize( $database );
}

So there we have it.  A custom database object that needs to remain persistent across requests stays alive in the session by using built-in serialization.


Follow

Get every new post delivered to your Inbox.