adobe air: detect mounted storage volume

I’m building an adobe air app using html/javascript…
this is what it does:
1. reads a config file
2. gets a lists of filenames to search for (some of the names have a wildcard) from the config
3. searches all mounted (usb) drives for the file names specified in the config
4. if it matches a file, it will upload that file to a server
5. if the config specifies to delete the file from the usb, it does so, otherwise it leaves it alone
6. when all the files are uploaded, call one more script to process the files on the webserver.


so everything else is relatively cake to accomplish (NOT)

I’ve been pulling my hair out trying to detect if someone had previously inserted a usb drive, and also have a listener for when they insert one. (I have no hair…)

One more thing I must add, the app was built using version 1.5x runtime of adobe AIR. I saw this demo [ http://blogs.adobe.com/cantrell/archives/2009/11/storage_volume_detection_api_demo.html ] of the new storage volume api in adobe AIR 2 and I knew it would MASSIVELY simplify my life – so i decided to try it out.


the only reason I am posting this is so that if you are trying to use this API feature on AIR 2, and you have an AIR 1.5x app, this is what you should do:

1. get the new sdk and extract the new libraries [/AdobeAIRSDK/frameworks/libs/air] into your project folder

2. MAKE SURE YOU INCLUDE <script src=”lib/aircore.swf” type=”application/x-shockwave-flash”/> in your html

3. In your application.xml you have to specify the new version: <application xmlns=”http://ns.adobe.com/air/application/2.0″>

this is how you use the code:

var StorageVolumeInfo = window.runtime.flash.filesystem.StorageVolumeInfo.storageVolumeInfo;
StorageVolumeInfo.addEventListener(window.runtime.flash.events.StorageVolumeChangeEvent.STORAGE_VOLUME_MOUNT, onVolumeMount);
StorageVolumeInfo.addEventListener(window.runtime.flash.events.StorageVolumeChangeEvent.STORAGE_VOLUME_UNMOUNT, onVolumeUnmount);

var volumes = window.runtime.flash.filesystem.StorageVolumeInfo.storageVolumeInfo.getStorageVolumes();
for (var i = 0; i < volumes.length; i++)
{

directory = new air.File(volumes[i].rootDirectory.nativePath); // directory is a global variable
if (volumes[i].isRemovable) {
air.trace(volumes[i].name, volumes[i].rootDirectory.nativePath);
doSelectUpload(directory);
}
}

ENJOY & good luck!

it’s alive…

after much hard work, we have a clear vision of where we want to take mad monkey.

check out the website: http://madmonkeyinc.com. PLEASE send your feedback, it is sooo vital.

i love me some pomodoro

I like to share things that I find valuable and helpful, and The Pomodoro Technique by Francesco Cirillo absolutely falls into this category. I’ve steadily practiced his methodology for the past 6 months, and the results are remarkable.

I do not claim to have ADHD, but I have the tendency to jump from task to task, without spending any substancial time accomplishing anything. This is especially prevalent when my todo list is massive and I feel a bit overwhelmed.

As I write now, I am under the guidance of a pomodoro.

The idea is simple, make a list of tasks that need to be accomplished, you then get a kitchen timer, set it to 25 minutes and focus on a SINGLE task (and NOTHING else) for that duration. At the end of 25 minutes, you take a 5 minute break to do what ever (preferably something constructive) and then you do it again. After 4 consecutive pomodoros (each interval is referred to as a pomodoro) you take a 10 minute break.

see:

This technique is great because it prevents you from email anxiety and instills discipline. This discipline has been tremendous, especially while working on my graduate classes.

I do not use a physical timer. I have something better. I use a widget on my mac that allows keeps track of my pomodoros.

It is excellent because it actually mimics the ticking sound, and feels authentic. The ticking sound bothers at first, but after a while, it’s like marching to a beat, a subliminal keep-it-up reminder… here is a list of software timers

A great by-product of the pomodoro technique is the task log. As a freelancer, it is indispensable! I use it as my informal timesheet because I know exactly what I worked on, and when, and how many pomodoros it took.

The technique encourages you to break down tasks into manageable 25 minute increments. If something will take more than 25 minutes to accomplish, then you need to break it down. This does wonders for the mind, it also makes things seem less overwhelming.

I would love to see this in practice in a team environment… it could be wicked!

So I encourage you, give it a try… read this, and let me know how it works for you.

lipstick on a pig

…yeah, so as soon as I saw the business card, I knew we had to go BOLD!

and the result: RemodelingBerksCounty.com

Seriously, if you meet Eric Schultz and hear his story, you will be amazed – and he does incredible work too.

So we started out by finding a domain name that fits, and I was surprised to find that remodelingberkscounty.com was available. This was an early win for us and it set the tone for the rest of the project. We sat and talked – and talked and talked – he showed me his portfolio, explained how he works – he actually told me the best way to put up the child-gate so as not to damage the plaster in my old house. Tolu (my son) hates the gate!

Once we had a rapport going, he literally left everything else to me.

I was “lucky” that he LOVED the design after the first round – that usually never happens, actually, that has never happened to me.

Eric came to me through a referral from a buddy at church (thank you Eddie) and I knew I couldn’t let him down. The good thing about referrals is that, there is already a level of trust there and you don’t have to do a “dog-and-pony” show to gain some credibility.

I like Eric because he likes to keep things simple, and he knows what he wants.

The funnest part of this project was writing all the copy for the site.
Check out the WORKS page.
A line that I am particularly proud of is:

If your house is a pig, and you need some lipstick, I’m your man.

I can help you too… say whaaa…

appengine and python…

I once read that “…simplicity is king” . This cannot be more true when applied to programming. There are a LOT of different categories of programming languages out there and I find myself attracted to programming languages that offer a higher level of abstraction. Not because I am lazy, but because it is simpler to work with.

Let me explain…

high-level of abstraction = high-level programming language = more legible code = easier. example: Visual Basic

low-level of abstraction = low-level programming language = not so legible code = looks like machine code = more difficult = super efficient and generally faster. example: assembly language

There is a place and time for the different types of languages, although, the introduction of some high-level languages (Visual Basic) has drawn the scorn of many purists. They argue that because the coding syntax is more semantic and easier to understand, un-qualified people are now flocking into the field of programming. Some go to the extent of blaming part of the dot com crash of the 90′s to poor VBScript developers. The claim is that easier = lazier.

I definitely do not think that programming is for everyone. But imagine an excellent programmer that is equipped with the benefits that come with high-level (easier) languages. A programmer that is not hindered by difficult syntax and complex programming structures.

This is why I think that formal training in the art of computer science is so essential. I am grateful that in college, my resolve to be a programmer was put to the test with courses that required the use of low-level languages like assembly language and data-structured (functional) language like Common Lisp, and (not so low-level like) C++ and Java. This was before we were ever introduced to Visual Basic and PHP. Going through the grueling process of understanding data sections and data structures and pointers and inheritance and constructors and destructors… has made me a better programmer. And I’ve come to appreciate the higher-level languages like PHP and C# that help me get work done fast and efficiently in the real world.

NOW to Python and appengine…

I have to say that Python is a beautiful (high-level) language. And Google’s appengine platform is crazy responsive (surprised?). I tried developing on salesforce.com’s offering of a platform as a service (PAAS) and I was not impressed. Using the eclipse IDE to build on salesforce.com’s cloud was not responsive and seemed bloated – IMHO.

So I decided to use my latest pet project to try out Python and Google’s PAAS offering. In anticipation of a sucky PAAS experience, I started out using the Django framework on my local server.

My initial perception is that Python just seems to get out of the way, and allows you to get to work. There are many benefits to Python, one of my favorites right now is:

Maintainable Python: Python’s elegant simplicity yields code that is not only readable, but also easy to redesign and modify. Because Python’s syntax uses indentation to define program structure, code is easy to move around, making it a snap to split up modules or restructure classes. Less time is spent understanding and rewriting code, which leads to faster bug fixes, faster development and integration of new features, and a better-designed code base.
from: http://www.wingware.com/python/benefits

for example, this is how you would query the zillow api to get the zestimate of a property and the high and low valuation;


...
        rpc = urlfetch.create_rpc()
        urlfetch.make_fetch_call(rpc, zillowurl)
        try:
            result = rpc.get_result()
            if result.status_code == 200:
            	dom = minidom.parseString(result.content)

            	#message
            	msg = dom.getElementsByTagName("message")[0]
            	result_node = dom.getElementsByTagName("result")[0]

            	message = msg.getElementsByTagName("text")[0].firstChild.data

            	if msg.getElementsByTagName("code")[0].firstChild.data == '0':
            		zesti = result_node.getElementsByTagName("zestimate")[0]

            		zestimate = zesti.getElementsByTagName("amount")[0].firstChild.data
            		zvaluation = zesti.getElementsByTagName("valuationRange")[0]
            		lowvaluation = zvaluation.getElementsByTagName("low")[0].firstChild.data
            		highvaluation = zvaluation.getElementsByTagName("high")[0].firstChild.data

            		zproperty = ({'zestimate':zestimate,
            					'lowvaluation':lowvaluation,
            					'highvaluation':highvaluation})

            	#self.response.out.write(zamount[0].firstChild.data)

        except urlfetch.DownloadError:
            message = 'There was an error retrieving the Zestimate, please try again later.'

	template_values = {
            'zproperty': zproperty,
            'message':message,
            }

		path = os.path.join(os.path.dirname(__file__), 'index.html')
		self.response.out.write(template.render(path, template_values))

...

SO:
Python ROCKS
Django ROCKS
Appengine ROCKS

I just need to find projects where I can apply this stuff!!!

ps: some people are experiencing similar ecstasy with Ruby (on Rails), more power to you, lets change the world with code…