SL4A, Python, webViewShow – a faster dev mode

 Android, Python  Comments Off on SL4A, Python, webViewShow – a faster dev mode
Nov 262011
 

While I was playing around with Python for Andoid, I was using the webViewShow method to load an interactive html page and set up message passing both from

html/js -> python

and from

python -> html/js

Part of this requires that I knock out and hack some html/js code. However, I am using the Remote method with a public server on my android device, since I am too lazy to set up eclipse and a full blown android dev env. The example code they show, uses an html file located on the sdcard of the device. Of course this brings its own problems, since now I have to mount, edit, unmount between each hack cycle. Ick. Well I could just tell it to load the html from an off device server, but being lazy ( I think I mentioned that already. ) I didn’t want to rsync back and forth to my remote server, set up directories, etc. Also, I didn’t want to set up a Django install just to serve a hacky html script.

So I think to myself, man there has to be some light-weight way to serve this up locally while I’m hacking. So I think, hey CherryPy, but then I remember Edna and it hits me, I can serve static pages out of a directory with just python. A little google-fu and this page appears, giving just the needed incantation.

 python -m SimpleHTTPServer 8080

Which happily serves everything out of the directories below it on the specified port (8080 in this case). I make a little adjustment in to my webViewShow and change it from file:/// to http://my-dev-ip:8080/thefile.html and all is good with the world. As I hack, changes to the html are pulled and served immediately.

Did I mention, Python Rocks!

 Posted by at 1:13 am

Obituary for netbooks off the mark

 Business, netbook  Comments Off on Obituary for netbooks off the mark
Nov 232008
 

InRe: Jason Chen on why the netbook market is dead in three years | T3 magazine

Jason’s reasons for netbook’s demise, underpowered for Windows and underoutfitted for Windows, while true to a degree, are not going to be the reasons for any so called demise of the netbook market.  What he is really talking about is a failure of Windows, both XP and Vista.  Netbooks are not small laptops just as miniature golf is not golf in miniature.  They are a different class of device, bigger than a phone but smaller than a laptop.  Trying to run windows on a netbook is as frustrating as a phone with windows mobile.  Microsoft is becoming less relevant in the fastest growing market segment.

While I agree that what we now call netbooks (screen < 10 inches) may dissappear in three years it won’t be because of consumer apathy but because the device platform will become wildly popular and manufacturers will struggle to differentiate themselves.  Jason goes on to compare netbooks with tablet PCs but that analogy is false.  There have only been a handful of tablet PC platforms, where as the market is exploding with netbook devices.

His closing statement about price and weight is exactly what will sustain the market.  At a price of 1/3 to 1/4 of a full featured light weight laptop, more people can afford to have both a laptop and a netbook.  If they were to buy the MacBook Air or X360 they would have to live with the tradeoffs they bring.  A netbook/laptop combo comes in 1/4 less the cost.

CrossOver Chromium vs. Firefox 3 – Javascript performance results

 Business, Firefox, Google, Ubuntu  Comments Off on CrossOver Chromium vs. Firefox 3 – Javascript performance results
Sep 152008
 

An interesting thing happened on my way to the web today. While reading through my rss feeds, I came across a story about CrossOver doing a Proof of Concept port of Chromium to CX. Interesting since the mighty “g” can’t seem to get it together for Linux. I’ve already downloaded and played with Chromium at work on my XP box and was impressed with the speed. It seemed much snappier than FF3.

So being an overly curious bugger, I downloaded the deb pkg for Ubuntu32. Yeah, it looks pretty rough — but what the hey, it’s a PoC right? So, I thought maybe a little speed test is called for, so I googled “javascript test” and my cloud brain returned, “Sunspider JavaScript Benchmark“.

So I fired it up in the cxChromium port and then it the standard FF3 on Ubuntu. Here is what I saw for cxChromium. I then swing over with FF3 and get these results.   Javascript in FF3 is 2.44x slower than cxChromium.  Man oh Man, is the v8 javascript engine a hummer.

Google App Engine — Auto-Increment vs. UUIDs

 Google App Engine, Python  Comments Off on Google App Engine — Auto-Increment vs. UUIDs
Apr 272008
 

App Engine is a pretty dramatic thought departure for lots of programmers who are used to writing an app that runs on a single server and access a single database.  Case in point, there has been a recurring topic of auto-increment fields on the  App Engine list — people trying to implement their own version of it since it is not a native datastore type.

Using an auto-increment field is not the way to go.  It is viable when you only have 1 database but the datastore for your app is going to/can be replicated out to other machines.  This would mean that their exists times, when datastore’ != datastore” — over time datastore’ would be sync’d with datastore” so that datastore’ == datastore”   — this would lead one to believe that there will be times when the idea of an auto-increment field will not be synchronizable or that the result of the synchronization would be less than satisfactory.  My belief that auto-increment fields are the wrong idea in this environment is strengthened by the fact that they are not offered as an intrinsic datatype.

The way to go, in my opinion, is to use UUIDs. (see links below)
  http://docs.python.org/lib/module-uuid.html
  http://www.faqs.org/rfcs/rfc4122.html

Other Thoughts on the topic:

  • data access is very expensive, using a UUID should be faster
  • UUID1 or UUID4 would be the types to consider
  • UUID1 is preferable as it would introduce some machine significance which should make the chances for a collision to be even more remote than for a UUID4 (random)
 Posted by at 10:45 am

Greedy Coin Changer

 Python  Comments Off on Greedy Coin Changer
Apr 262008
 

Noah Gift over on O’Reilly OnLamp Blog has an article on building a greedy coin changer. That is, given a value, say 71 cents, calculate the fewest coins needed to make the amount. He had listed a number of solutions, but I felt I could do it a bit more pythonic. 😉

#!/usr/bin/env python
"""implement a greedy coin changer, returning the
fewest coins to make the change requested."""
#coin_list can be expanded to include silver dollars 
# and 50 cent pieces by just expanding the coin list
# to [100,50,25,10,5,1] the reulting answer 
#structure will modify itself to reflect 

coin_list = [25,10,5,1]
change_requested = .71
remaining = change_requested * 100 
change_returned = []    #result structure

for coin in coin_list:
    num_coins,remaining =  divmod(remaining,coin)
    change_returned.append(int(num_coins))
    
print change_returned
print remaining

The benefits of this version, are no conditional logic is needed, the coin structure can be modified and the answer will modify itself accordingly.

Google App Engine — Runs on Python

 Business, Google, Python  Comments Off on Google App Engine — Runs on Python
Apr 082008
 

Now this is truly an interesting development. Google’s just announced App Engine is sure to super-charge the Python community and convert a number of disillusioned developers of other languages in to Pythonistas. There have been lots of interesting comments floating in the blogosphere about what this could mean.

I think it is a great opportunity on a smaller scale than anyone might imagine. Sure, this could serve as the platform for the next YouTube type social-2.x site, but what I think this really means, is that Google is rounding out the Google Apps for Domains by giving the ability to create something more than a brochure-ware style site offered by their current Sites for Google Apps.

Many are looking for Google to use this as an opportunity to expand advertising revenue, and that is certainly possible for widely popular webX.x sites but what they really needed is another tool/knife to hold to the competition’s throats. Looking at the tea leaves in the bottom of my glass, I see something more akin to a SharePoint attack; Going after the S in SMB market.

App Engine allows for authenticating users via Google system, how much longer until we can interact with other Google services in a similar fashion?? Calendaring, GTalk, etc — I’m not talking mashups, something much more refined.

 Posted by at 10:23 pm

Automating Checklists with nose

 Business  Comments Off on Automating Checklists with nose
Jan 222008
 

Grig has an interesting post today about enforcing checklists via nose, Agile Testing: Joel on checklists  Now that is an interesting idea.  I do lots of PCI compliance testing and documenting the tests and procedures is par for the course.  Automating those procedures goes a long way in helping out in this regard. Dora, handles scheduling, running and reporting which makes life nice, but I’ve got a variety of scripts and it would be nice to unify them in overall architecture.  Using nose could do just that.

Interesting things/thoughts happen when your programmers are sys-admins too.  This idea of translating the framework we use for testing code to testing systems has a number of interesting dimensions to it.  Just like Alton Brown, I insist that my tools multi-task too.

 Posted by at 9:29 pm

Acknowledging the Elephant in Development

 Python  Comments Off on Acknowledging the Elephant in Development
Jan 222008
 

There is a great article over on SnapLogic,  SnapLogic Blog Squishy design with Python: Designing in code

The gist of the article is that when developing APIs are never as complete as we want them when we are developing a new system and if you are using a static language you’ve got lots of ramifications to consider and code to rework when you have to expand an API.  However, dynamic languages have a real advantage here and they go on to give a very real example and how they dealt with it.

 Posted by at 12:41 am

Plugin Framework/Architecture

 Business, Python  Comments Off on Plugin Framework/Architecture
Jan 222008
 

There is an interesting write up on plugin architecture — g :: A Simple Plugin Framework

A project that I’m working on is going to require a plugin framework for a number of things: Logic, Data Storage, Reporting and I’ve been keeping my eyes open for papers/articles on plugin frameworks.  Do you know of any resources/articles?

 Posted by at 12:08 am

More Blogging, Faster?

 Business  Comments Off on More Blogging, Faster?
Jan 212008
 

ScribeFire has been installed again.  After a tumultuous summer, fitful fall we are in to the Winter.  Time to get back on the post wagon.  There will be more to follow now.

Powered by ScribeFire.

 Posted by at 11:26 pm

Python in the Browser – brought to you by Microsoft?

 Microsoft, Python  Comments Off on Python in the Browser – brought to you by Microsoft?
May 012007
 

Who would have guessed that MS would be the first to really put python in the browser? I know you can jump through hoops to make a browser support python but it was not something you could do for a public website.

There have been a bunch of announcements in the past couple of days about IronPython and SilverLight — will they beat firefox?
Personally, I’m giddy about the prospect of using Python instead of javascript.  John Udell’s blog entry tonight specifically mentions
that exact combination.
http://blog.jonudell.net/2007/05/01/watching-anders-hejlsberg-reinvent-the-relationship-between-programs-and-data/

Finally, things are starting to get exciting again.

 Posted by at 9:51 pm

ubuntu: Using xdmcp in the Term Server Client

 Ubuntu  Comments Off on ubuntu: Using xdmcp in the Term Server Client
Mar 252007
 

To enable xdmcp in the terminal server client for Ubuntu (edgy). By default the
terminal server client program has xdmcp disabled. To fix this just
install xnest:
# apt-get install xnest

 Posted by at 8:48 am

PyCon: Talk to people.

 pycon, Python  Comments Off on PyCon: Talk to people.
Feb 272007
 

Ned Batchelder blogged some good PyCon advice tonight, “Talk to people.” I completely agree with him on that point.

This was my second PyCon and I spoke to a vastly larger group of people than I did when I attend PyCon 2002. While I did say Hello to a number, the one real conversation I had was with Tim Peters. This year I wasn’t the least bit shy about introducing myself and talking to others. I met a number of great people who just happen to be excellent pythonistas. There was Chris and Ted from ChiPy, Alvin from San Francisco, Christian Tismer, Mark Ramm, Michael Foord, Alex, Ben, Doug (nice job on the pycon schedule) and many, many more. I’ll be blogging about a number of these conversations as time goes on.

 Posted by at 12:20 am

ExoTagging with SQLAlchemy

 pycon, Python, SQLAlchemy, TurboGears  Comments Off on ExoTagging with SQLAlchemy
Feb 242007
 

ExoTagging
After listening to the wonderful things being said about SQLAlchemy at PyCon, I wondered if the following idiom could be implemented as a Domain Object with SQLAlchemy.

Often we have legacy data that we have read only access, to which we need to associate additional meta information. Before this has always meant that the application had to be aware of the relationship of the meta data record in the ExoTagging DB and how to map it to the legacy read-only data. If we could map the two into a single Domain Object it would make are apps a lot cleaner. I spoke to Mark Ramm and he believed that it would be possible and in fact it might even be easy although he hadn’t attempted it before.

I call the idiom ExoTagging because it is logically quite like the idea of Tags, except that tags are kept in a table that resides in a database that is separate from the data that is being tagged. Hence Exo-Tag.

Has anyone else already implemented something like this with SQLAlchemy, if so would you mind sharing your experiences?

 Posted by at 4:15 pm

Omaha Python Users Group

 Business, pycon, Python  Comments Off on Omaha Python Users Group
Feb 242007
 

I believe that it is time to resurrect the Omaha Python Users Group. I attended that Python Advocacy meeting on Day 1 of PyCon and listened to Jeff Rush and then talked to the leader of ChiPy, Chris McAvoy. There is an advocacy open session tonight @9pm after the OLPC show and tell session. I am hoping to work with others there to set up a system to share web resources, mailing list, website, etc between users groups. People should be able to go to the python site and “Find a local users Group”. The users groups could video tape speakers, and then share those videos for use at other user group meetings and for advocacy in general. A central point for available speakers and a centralized place for companies like O’Reilly, to offer products, books, and other give-aways that could be requested and used by the different users groups.

 Posted by at 10:50 am