Rusty's Blog

Thoughts and musings of someone who's not sure what 'normal' is…

Tuesday, June 30, 2009

My first Android App/script…

Minor setup stuff. I use a G1 phone from T-Mobile and have very much enjoyed the experience. One of the things that I’ve been looing for since I started using it has been a way to post microblogs to http://identi.ca. There are a couple of apps out there for twitter users, and while I do use twitter, it’s had a few problems that make it unsutible in my view for ongoing use.

There really are several different ways of getting content out of identi.ca onto my phone. sms messages, e-mail, web browser, gtalk/xmpp, etc. However I really didn’t want to be reading messages from identi.ca, I’m a bit more interested in sending messages to there.

For me a critical point is that I have a jabber/xmpp server running on one of my own servers. As a matter of fact I had already linked my jabber account there. If you have a gmail account, you might prefer to use that. However a pointer there is that any time you receive an IM at your gmail gtalk account, it very well may be using an sms message to talk to your phone. That can get expensive. I recommend using a server of your own, or getting an account on jabber.org or a public server and use that resource for sending and receiving jabber to identi.ca messages.

Now getting a jabber message from a phone to a jabber server is not really difficult. I suspect that I could install a development package on my desktop, write a bit of code for the android environment, compile a package, put it on a server I have access to, install the package to my phone, test, and repeat the steps from write a bit of code on, until testing gives me the results I expect.

An alternative that has just recently shown up is the Android Scripting Environment. http://code.google.com/p/android-scripting/

With the Android Scripting Environment (ASE) you can write scripts in Bean Shell, Lua, or Python. By default Bean Shell is installed, but you will need to install the interpreters for Lua and Python. The Environment is a .8 code base, which means it is very functional, but may not be complete from the perspective of a general user.

I’ve personally never done well in Java, and Bean Shell really is a scripting environment for Java. If you happen to like Java, it may be all you need. I’ve also never worked with Lua, but from what I see in the collection of scripts that are available as examples, it appears to be a reasonable language as well. I have played around a bit with Python, and while the environment is hardly complete, it seems to be sufficient for what I need. For android, it does include xmpp support, as well as support for pulling down URLs, interpreting html, and a few other elements as well. All I needed this time was the Android support and the xmpp support.

I’ve liberally copied code from a couple of different resources. For an example of how to send a message to a jabber server, (which was not written for the android platform, but it’s python and all the referenced libraries are included in ASE) I used the tutorial at http://snippets.dzone.com/posts/show/618

Here’s the sample:

import android
import xmpp

droid = android.Android()

# User interaction stuff
message = droid.getInput('identi.ca update', "What's Up?")['result']
tag = droid.getInput('tags?',"What tags? (Prepend w/#)")['result']

# Varios Variables we will use
_SERER = 'jabber.server.you.use', 5223   # put in your own jabber server name and appropriate port
username = 'your.user.name'              # give it the user name you want to use
password = 'your.password'               # until I figure out how to store these credentials securely
fullmessage = tag + message              # build the message we're going to send. (could use improvement)
destid = 'somename@jabber.server'        # for identi.ca use 'update@identi.ca'

# send the message
cnx = xmpp.Client('jabber.server.you.use') # don't need the port so don't use when creating a connection instance to use
cnx.connect( server=(_SERVER) )          # establish a connection
cnx.auth(username,password, 'G1')        # authenticate yourself, and give a 'presence' (G1 in this case)
cnx.send( xmpp.Message( destid, fullmessage ) ) # Send the message

# exit 'cleanly'
quit = droid.exit()                      # we're done, time to go

And that pretty much summs it up. There are a few things I will be investigating over time. I suspect that using a dictionary, I can create a set of ‘tags’ that I want to use regularly (#cvg2009, #c25k, etc.) then feed that to some sort of a pick list, and hopefully I could enter the update and select the appropriate tag all in one dialog. Worst case, 2 dialogs sort of like what I’m doing now. This currently has a bit more flexibility, but in the end I would also like to be able to identify if this is to be a message to update, or to some other specific user.

What am I doing with this? Well, as a department co-head for the 2009 CONvergence convention, I wanted a way to update my facebook, twitter, identi.ca and planet pages with what I’m doing, and what’s happening now. I’m pretty sure that I can update twitter directly, and possibly through that facebook, and it looks like I could import from there to identi.ca, which also would propogate to my world page, but after seeing the problems that twitter has been going through with it’s growing pains, I didn’t think that was the best route. If it works for you, ok. The facebook app for Android has been having problems since facebook changed something recently, so that was out. And it’s been a while since I wrote anything I considered interesting like this, so here it is.

How things work from here. My jabber server accepts a connection and forwards the message to update@identi.ca, which then places the update in my stream. Through the facebook interface it posts an update to facebook. I also have my account configured so that all events are posted to twitter as well. My planet page pulls any updates I’ve made in the past couple of hourse every 2 hours from twitter and identi.ca. Hey it pulls an update that I’ve posted a blog as well. Handy little page at times.

I always seem to discover ‘issues’ that need to be corrected that have almost nothing to do with the specific project at hand, except that they got in the way. Today I discovered I had not punched a hole for tcp through my firewall for jabber clients. I had punched one for UDP, but since nothing is listening for that…

Have fun. If you find the app useful, and want to let me know about updates, I would appreciate hearing about them.

posted by Rusty at 12:15 am  

Tuesday, March 3, 2009

The CDC and Social Media.

For purposes of this entry, social media will be any resource that is suceptible to meme’s. The obvious ones are sites like Facebook, MySpace, Twitter, identi.ca,  and the tools that connect them with other systems, such as iPhone apps, etc. However we should not discard ‘mem’ related systems either. Where’s George for example, as they can provide independent corroberating evidence.

At one level or another the CDC already tracks communicable deseases such as HIV, Ebola, and variations on the Rhinovirus and Influencza. The standard means of tracking is to get reports from medical professionals regarding when the first symptoms of a communicable disease enters a community, and what the experience within that community is for propegation within the community. As best they can they try to determine the vector, but that is not always as simple as it seems. An example of a disese that we know is communicable, but do not know well how it enters into a ommunity is the Ebola virus. The last I read we had a strong suspicion that it exists and is innocuous within some animal, though we do not know well which one, and we only have theories as to how it first transitions to humans where it has a malevolent response.

As a result of the reporting that the CDC is already getting, we can see patterns in propegation, and hopefully get doctors and the medical communities prepared for the influx of paitents they will see, though accurately predicting when ior even if it will hit a community are still rather dicy.

The  big problem a tthe moment is that asside from self reporting of social contacts within a medical report, which is rarely going to give you useful information, knowing where a bug is only peripherally tells you where it is going. Will it arrive by plane tomorrow? On the train later this week? Or will it suddenly appera within one ethnic community and completely miss everyone else for a couple of weeks?

The Holy grail of prevention is being able to identify accurately the vectors. If you tried to explain how a disese got from one place to another based on medical reports, you would very likely see a pattern of early reports showing up first around clinics and hospitals, so those are ‘likely’ to be the vectors. Right? Maybe. What you would really like however is a way of tracking how a disese is propegating without it being bound to a single reporting mechnism. Ideally it would have a way of identifying relationships between people within the reporting system that already is in place. And that is where social media could come in.

You may have seen reports about, or even participated in ‘memes’ such as the ‘25 things about me’ or ‘1 word’ memes that have hit several social media platforms over the past few months. If you look at what happens, someone somewhere inserted the meme from one system into another. Perhaps they saw a blog entry on a blog agregator, and decided that it would be fun to try that on Facebook where they could tag their friends. And their friends tag others, and after a few itterations you litterally have millions of people posting inane facts about themselves, and a the meme dies away. Or perhaps someone from Facebook takes the meme over to MySpace, and it flares up again.

If you watch the pattern you see that the first one is extreamly virulent, and the ones following are less so. 25 things hits millions, one word hits hundreds of thousands, ‘alphabet’ may have gotten to tens of thousands. Which is also of interest in contemplation of how the various propegation mechanisms can adjust over time. There was no imunity to the first meme, but the second time around people were less interested, and by the third or fourth time around people were actively opposing the meme. A primary vector becomes identified and people either block that vector or filter it against similar events.

Chain letters are another example, as are other e-mail messages with images, etc. In fact it’s been used to actively propegate computer viruses, which are another example.

Those examples however are essentially models. And they provide useful information about how vectors can work, but don’t necesarily give us useful information about how to map that information onto medical situations. Our imune systems, both internal and external have gone through several very deadly propegations, such as a couple variations on Plague, the Spanish Flu, etc. We are not fully immune to those, as we have learned that each of these do change over time.

Given that we can model diseases, can we use that information to perhaps identify vectors for new disease outbreaks? This is where Social media sites get to be very interesting, and potentially very controversial. Interesting because if you can track a real disease across a social network, see who is reporting what sort of symptoms, and see how those symptoms then show up across various relationships, you can potentially identify the sorts of vectors those diseases use. This can be useful information in helping to prevent an outbreak in the first place. As an example, if you spot that the first people affected by salmanela food poisoning all are close to supermarkets, and it seems to take a few days before people around regular grocery stores are affected, you can look at what might sell first at supermarkets, then sells later at grocery stores. If you see that people on vacation to the Camen Islands are comming down sick a week later, but people who are there on business only trips there are mostly fine, you might consider looking at resort related activities.

Social media can be broken down into thre or four ‘types’ of relationships. First of all you have direct relationships. This might be work related social sites, company/vendor type sites, or sites that cater to families. While these are handy for looking at relationships that probably involve physical contact between the members, it’s less likely that someone like the CDC is going to be able to have access to the information, and also somewhat unlikely that such information will be available as they tend to discuss specific non health related information. If you do have access, you may see patterns of propegation in how people interact however. Bob usually responds immediately, but didn’t respond to anything on Monday or Tuesday this week. Turns out he called in sick. And so on.

Another variation is the ‘completely open’ social site. For some people these are the ‘best’ types. It gives someone like Robert Scoble, or Jason Calicanus the opportunity to market to litterally millions of people at a time. Friend the person and you immediately have a way to distribute information about your business, and you are more likely to end up with customers than by just advertising on a web site.

Between the two are ‘restricted’ social sites. In some way relationships are restricted here. You may have to identify how you are ‘related,’ (Family, work, hobby, neighbors, school chum, etc.) or you may only be allowed to have a certain number of friends (Friendster, Facebook)

For the moment we won’t get into other variations on the ‘restricted’ sites. There really are too many to mention. However another type of site to consider are the ‘dating’ sites. In most cases you are going to be looking here for either budding, or transient relationships, and in some cases there will be various levels of intimacy involved that may very well give you some very useful vector information.

As noted earlier the ‘closed’ relationship sites are of limited utility to someone like the CDC. I have to admit that I think the ‘completely open’ varieties are also of very limited utility. This because while they may provide a lot of relations, it is very likely that most of those relations do not provide a mechanism of transmitting communicable diseases. One could spend thousands of hours trying to figure out how to use a collection of MySpace or Twitter relationships, only to discover that the person you are ‘tracking’ with all those relationships only ever personally interacts with a very small subset of the collection.

Limited social media then are where you really would like to focus. Here however you run into other problems. Most of the limited sites do not have a means of looking at everyone’s updates. You very well may be albe to see that Bill is married to Marry, and works fro Walt, but if you can’t view their communications, you may never see how Walt was sick on Monday, Bill ended up taking a sick day Thursday, and Mary missed going to church on Sunday.

One thing you can ddo with such a site thour is develop an application where people ’share’ information with each other. Perhaps you build an ‘I’m feeling…’ app that allows you set a ‘health’ level with detailed information. Headache, blury vision, lethargic, sneezing, coughing, racing heart, feaver (potentially with temp) muscle ache, shivering, pins and needles in feet/fingers. and so on. You set that level, and you invite your friends to use the same app. Additionally you get a related app for your cell phone, so you can set this information wherever you hapen to be, and it tags the update with where you are. Perhaps a ‘nudge’ feature to get people to tell each other ‘Hey I feel great!’ and so on, again tracking where you are when you post the update.

Since we have gone ‘cross platform’ the information has to be maintained outside of the primary social media site. This can cause some very significant privacy concerns. Especially since we are dealing with health information. In fact the tracking of such information is very tightly regulated under law. I’ll leave HIPPA concerns out there, but they are very real, and need to be designed in from the get-go.

The big problem with the privacy concerns is that unless you have some way of distributing relationship information amoungst users, you simply have another means of tracking where a disease may have been. It’s important information, but in a way it puts you in no better of a position than you started out being.

In computer science there is a concept called a graph. This is not the plotting of stocks over time, or the charting of population growth, though both are variations or a graph. A graph consists of ‘nodes’ and ‘vectors’ Vectors connect nodes, and have various properties, such as distance, direction, flow, Nodes usually have location information, but may have other characeristics. Using that concept, you can show how money flows from one person to another, Or you could build a family tree and track how genetic problems progress.

The thing to consider for this situation is that if you can watch how vectors change, for relationships, and can find some way of gathering helpful information about the people involved in the relationship without tieing identifiable information to the node. you could gather a lot of useful information for watching how an illness propegates, and provide public service information specific to that illness.

The next problem is who should track that, and can they be trusted to not gather un-necessary information? Some would suggest that this is a ‘Homeland Security’ issue. We need to be albe to prevent and protect against diseases that may affect the safety of the country and our military forces. Perhaps, but history of late suggests that this might not be a very trusted situation. USAMRID and the CDC are much more likely to be able to properly handle the information, and already have means of distributing advisories to the medical community. I would like to think that at least the CDC is more trustworthy, but that is largely dependent upon who is in charge, and can also be variable based on internal policies. USAMRID has the perception problem of being the military, with all the legacy of Military Intelegence, and the fact that over the years it has come to light that they did non-consentual comunicble disease testing on large populations in several major cities.

That means that the CDC would have to be a customer of ’scrubbed’ information. They may get to know about what types of relationships are involved in the graph, and may get demographic information about the people, but someone else has to be trusted to convert the information from the raw social site data to something that the CDC can make use of without it being personally identifieable. Some people I would strongly oppose having this power would be any medical site related to insurance. I would recommend that insurance companies should not even be allowed to sponsor, much less advertise here. Yes being ahead of the game could help reduce medical expenses, however there is entirely too great a likelyhood that people will be rejected for coverage as a result. (or worse.)

I don’t know who would make the best resource for this. Commentary welcome.

posted by Rusty at 3:05 pm  

Powered by WordPress