SectorFej

My tiny corner of the internet

First Anniversary

No Gravatar

No technical post from me today, everyone! I get a free pass this week. Courtney and I are celebrating our first anniversary—one year of absolutely excellent marriage. Exactly one year ago, we were standing at Salt Creek Beach in Dana Point, CA in front of family and friends pledging our love for each other. This last year has been exciting in all of the best ways, and without any significant negative experiences. I don’t think I could have asked for a better first year.

Thanks for all that you are, Courtney! I love you.

The Importance of Multiple Options

No Gravatar

I recently finished up an article summarizing the differences between a few of the mobile application development frameworks that are in existence today. I covered three major players, two individual platform-specific tools, one per-device shortcut approach, and my own fledgling project, AML. After researching and writing, here’s what I concluded:

  1. There are a lot of people trying to accomplish the same goal in different ways.
  2. That’s really great.

Now, honestly, the first point was already assumed. Anyone who’s done a simple web search on the topic would realize that. But what about the second point? More directly relevant in my case, what about my AML project, which is entering a field that already has a lot of competition and projects which have a great big head start over mine? Why would it be great for my project to have a lot of competition?

Well, first of all, I didn’t look at the playing field and think, “How can I do what they are doing, only better?” No, I started with a specific personal need. I have a problem that I need to solve, and I thought up what I believe is a great way to solve it. Then I searched for something that did what I needed, and came up empty. There were some things that were similar, of course, but nothing that did exactly what I wanted. So, I decided to build my own tool. Even if it ends up being similar to the other ones, I am still going to build it because it will solve my problem perfectly, and there are probably other developers out there who will need to solve the same kind of problem who will benefit from my project.

That is why having all of those different options is so great. If I were trying to solve a slightly different problem, I could use an existing tool, because somebody else already did the same thing I did, only they had a different problem to solve. Instead of everyone needing to bend a universal tool to fit their criteria, we have a multitude of choices, each with its own strengths and weaknesses.

In the case of mobile platform development frameworks, this is excellent. I wouldn’t want to have only one of them to choose from, since I can easily come up with a problem for each framework that would be a pain to solve completely if that was the only one available. Everyone has their own idea of what is best, and this creates a competitive arena. They each build what they need or want, taking inspiration from other designs, and come up with a solution. Sometimes the products converge into a single product, and sometimes they remain separate, but they continue to give developers different options to choose from.

This is really just the principle of the free market applied to software development, which explains why I appreciate it so much.

Rapid Android Development with AML

No Gravatar

7/13/2010 update:

Thanks to the great response (and many hundreds of visits to this page over the last two days), I’ve gone ahead and created a real project website for AML at http://www.amlcode.com, as well as the @amlcode Twitter account. If you’re interested in more updates, check those out. Thanks for all the comments and ideas! Keep them coming!

This post still has some good info and some great comments, so don’t neglect it completely. It might get lonely.

I gave myself a crash course in Android development over the last few days. I’d officially been part of an Android team as part of a project management class in my last quarter at Cal Poly Pomona, but some of the other members on the team ended up doing most of the actual development, so my instructive coding experience was pretty minimal. I knew enough to get the Android SDK installed in Eclipse (which is painfully slow, by the way!), but that was all. Everything else was new to me.

Now, I am very familiar with C, C++, and Java, even though most of my coding for my job is done in PHP, so picking up the Android vocabulary within Java was much easier for me than it would have been if I had no programming experience at all.

I don’t have a specifically defined project to work on yet, but I do have some general requirements for the Android app(s) I’m sure I will be developing in the near future. Specifically, I know I will need these features:

  1. Native implementation (Android UI, not HTML5)
  2. Dynamic externally generated content and navigation

Both of those two features together are, I believe, not an common combination. It’s simple to have dynamic externally generated content and navigation, if you use HTML and a browser. It’s also simple to have a native UI support externally generated content, if that content always fits into a pre-defined structure which you build into your app. But what if you want an app that supports a system with very little known ahead of time—just an email address and password, for instance—and the rest of it need is determined based on parameters, permissions, and a web service API?

Then, I thought, why not write a native Android library that will accommodate that very thing?

And that’s what I did.

I even had the presumptuous audacity to give it an official-sounding name, though it is by no means official (or truly useful) just yet. There is no W3C specification for it. And for all I care, it may never become official, but even if I’m the only one who uses it, this library it will certainly make things easier for me. And on top of that, it’s been a great learning experience over the last four days.

Ladies and gentlemen, I introduce to you AML, the App Markup Language, a simple XML-based language that allows you to easily build a clean, functional application for your mobile device.

It resembles HTML in some ways, but it is not a subset of HTML. It is designed to be intuitive and easy, and while it does not implement every possible feature achievable with native Android code, the goal is for it to cover the vast majority of what is necessary for information-based apps, and leave the rest up to you to implement as you desire. It probably won’t help out much with games, but it’s perfect for mobile implementations of websites. It can even be used as part of a local-only application to quickly build the UI instead of using Java code or Android’s layout XML structure.

Additionally, I would love at some point to extend AML in two directions: one, to have it support other devices (namely the iPhone and iPad), and two, to support different languages for the markup (namely JSON, perhaps YAML). While I don’t need these right now and may not actually need them for some time, there is nothing really Android-specific or XML-specific about the language. I have never written code for iOS, so I don’t know if the behavior is inherently different enough to cause a problem, but I bet it isn’t. You should be able to use the same AML markup to generate nearly identical experiences on Android and on iOS.

So, why is AML so cool? Why would anyone want to use it? Check this out.

The images on the right shows a set of different input objects in an Android app. It’s just an example, obviously—an app in the Market that looked like this would be odd indeed. However, it does illustrate a very basic layout with a few different objects.

Now, anyone who has done any Android development know that there isn’t anything truly difficult about building something like this. If you write your own “main.xml” layout file and use it for your Activity object’s content view though, it can be a little tedious. You can use a tool like DroidDraw to speed things up (which is an excellent idea if you need a static layout), but with both of these approaches, your design will be hard-coded into your app. You can only make changes on the fly through clever uses of the LayoutInflater service.

Your other option is to build the layout using only code. This allows for more dynamic design, for sure, but doing this manually is still tedious. AML bridges the gap between an external data source and the native application, so that the external source can very simply instruct the app what to build and how it should behave.

This is the Android layout XML necessary to create the layout shown above in the screenshot on the right:

<LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Test Button" />
    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Test Checkbox" />
    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/icon" />
    <ToggleButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:checked="true" />
    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Test Text"
        android:singleLine="true" />
    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Test Password"
        android:password="true"
        android:singleLine="true" />
    <RadioGroup
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="Radio Button 1" />
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Radio Button 2" />
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Radio Button 3" />
    </RadioGroup>
</LinearLayout>

Keep in mind that the above code is basically fixed, and cannot really be customized at runtime on a large scale. Now, for comparison, here is the AML necessary to create the layout above:

<aml>
  <input type="button">Test Button</input>
  <input type="checkbox">Test CheckBox</input>
  <input type="togglebutton" checked="yes" />
  <input type="imagebutton" image="drawable/icon" />
  <input type="text">Test Text</input>
  <input type="password">Test Password</input>
  <radiogroup>
    <input type="radiobutton" checked="yes">Radio Button 1</input>
    <input type="radiobutton">Radio Button 2</input>
    <input type="radiobutton">Radio Button 3</input>
  </radiogroup>
</aml>

It’s that simple. Additionally, for my tests, this layout info was actually being pulled from a web service, just so I could prove to myself that I could do it. The web service dynamically built that layout.

Here is a sample Android ListView constructed with the following AML:

<aml>
  <list>
    <item>Sample Test List Item A</item>
    <item>Sample Test List Item B</item>
    <item>Sample Test List Item C</item>
    <item>Sample Test List Item D</item>
    <item>Sample Test List Item E</item>
    <item>Sample Test List Item F</item>
    <item>Sample Test List Item G</item>
    <item>Sample Test List Item H</item>
    <item>Sample Test List Item I</item>
    <item>Sample Test List Item J</item>
    <item>Sample Test List Item K</item>
    <item>Sample Test List Item L</item>
    <item>Sample Test List Item M</item>
    <item>Sample Test List Item N</item>
    <item>Sample Test List Item O</item>
    <item>Sample Test List Item P</item>
    <item>Sample Test List Item Q</item>
    <item>Sample Test List Item R</item>
    <item>Sample Test List Item S</item>
    <item>Sample Test List Item T</item>
    <item>Sample Test List Item U</item>
    <item>Sample Test List Item V</item>
    <item>Sample Test List Item W</item>
    <item>Sample Test List Item X</item>
    <item>Sample Test List Item Y</item>
    <item>Sample Test List Item Z</item>
  </list>
</aml>
And another sample TableLayout that uses alignment and column spanning, generated by the following AML:

<aml>
  <table expand="2">
    <tr>
      <td colspan="2">This is a block of text contained within a single table cell. This cell has a colspan of 2 so that it looks good on top of the label/field pairs below.</td>
    </tr>
    <tr>
      <td align="right">Email:</td>
      <td><input type="text" width="fill" /></td>
    </tr>
    <tr>
      <td align="right">Password:</td>
      <td><input type="password" width="fill" /></td>
    </tr>
    <tr>
      <td colspan="2">Here's another 2-column cell. Is this awesome or what?</td>
    </tr>
    <tr>
      <td colspan="2">Notice the slight visual break from the text above. This text is in yet another row. The field labels above on the left are aligned to the right, and the table is instructed to make the 2nd column expandable (like an "auto-width" kind of thing).</td>
    </tr>
    <tr>
      <td colspan="2">Additionally, the fields have their widths set to "auto" so that even though they are empty, they fill their parent cells.</td>
    </tr>
  </table>
</aml>

Seriously, can it get any easier than that? You can store this kind of layout definition in your app code and reference it directly from there, or you can use a web service to build this stuff on the fly and send it to your app (though you might want to implement some sort of caching mechanism in that case, for efficiency). The AML library is in its own package, and doesn’t require any imports from your package to work. You do need to put the template layout XML files into your /res/layout folder, but that’s all. AML doesn’t require you or your web service to know the details of how Android builds its views. It doesn’t depend on some extra plugin installed on your device, and it isn’t passing your app code through another service. You probably still have to write some Java code to accomplish your goal, but this makes the whole thing easier.

So far, what I have written only supports layouts, but no actions. Many objects support attributes like align, valign, fontsize, padding, color, and bgcolor, to name a few. The rest of the code just isn’t there yet. I have been building the tap and hold attributes into buttons and other clickable objects, but I’m not done. I haven’t done a date picker, time picker, or spinner (Android’s version of an HTML <select> element). But it’s coming together very quickly—a lot faster than I thought it might. It’s been an awesome learning experience so far though.

I’m writing this for me, honestly, but I’m really interested in any kind of outside interest. Any questions, comments, or recommendations? Has anyone else done this? Would you be excited to get your hands on this code? If you used it, what would you need it to be able to do?

Let me know in the comments!

Getting Rid of Stuff, Revisited

No Gravatar

I’ve had some good feedback on the How to Get Rid of Stuff post that I wrote a couple of weeks ago. I wanted to update everyone to let you all know that I do indeed follow my own advice.

This weekend, Courtney and I finished going through our own stuff in a very quick clean-up process. It was Courtney’s idea originally—not that I wasn’t thinking about it, but I wasn’t going to make a point to do it now. She initiated it and did most of the work, actually. I mainly provided some input here and there on items that were mine. We digitized some cassettes and made a trip to the local Goodwill earlier this afternoon, and the few things that remain will be going on eBay soon or else to Goodwill too, if we decide it isn’t worth the time to sell them online. Our small closet dedicated to storage has returned to a more organized state, and we’ve both been encouraged and emotionally liberated by the whole event.

It’s just so darned nice to get rid of stuff.

Political Labels and Logical Fallacies

No Gravatar

What do you think when you hear the term “Left-wing Liberal”? How about “tea party”? “Right-wing extremist”? “Die-hard Republican”? “Card-carrying member of the NRA”? “Reactionary”? “Obstructionist”? “Moderate”? “Libertarian”? “Independent”? “Neocon”? No matter what you believe, or what your personal political affiliation is (if you have one), the odds are good that those terms conjure up quite a few different images, some of which are bad.

While some of these kinds of labels are meant to be derogatory caricatures of the people we disagree with, many of them are not. The problem is that even the more “harmless” of these words mean significantly different things to the people who use them regularly. A self-identifying Republican thinks “Republican” is a good thing, while a self-identifying Democrat thinks “Republican” is a bad thing. Say the word in front of both of them, and two very different mental pictures will form in their respective heads. From a linguistic and logical standpoint this means that these words are fundamentally useless for worthwhile communication because their meanings have become arbitrary—not depending on context, which would still allow usefulness, but instead depending only on the personal meaning ascribed by the one using it.

I subscribe to many different political or environmental email newsletters. I don’t agree with most of them, but I like to read through the agendas of different organizations just so I get a well-rounded idea of what’s going on around the country. It’s saddening to me that the content from the organization I disagree with most (MoveOn) is usually the least full of distracting propaganda. Don’t get me wrong, they do have many other more subtle forms of propaganda. But the most blatant name-callers of all of them are often the ones that I agree with in principle. I just can’t stand their method of delivery, and I doubt their credibility because they resort to that kind of communication.

Political labels allow for an easy way for group members to identify themselves. However, I am virtually certain that most of the people who consider themselves part of a large group (such as MoveOn or, say, the Tea Party) either don’t agree with 100% of the agenda, or more likely don’t know 100% of the agenda and so cannot truly agree or disagree across the board. It is challenging even among family members to find someone who completely agrees with everything you believe.

Labels create a simple but inaccurate group identity among ideological subscribers, while at the same time they create a shallow but intense divisiveness between “believers” and “non-believers.” People often treat their own political beliefs like religious dogma and use opposite labels on their opponents as spiteful, condescending pejoratives. This makes it easy to fall prey to a logical fallacy commonly known as a straw-man argument. A straw-man argument entails the misrepresentation of the position of our opponent for the purpose of easily shooting it down. Such a position is easy to defeat, but it is not a true victory because we have ascribed viewpoints that the opponent does not really hold. The reality is that people that identify with an opposing group often have worthwhile points, and they are rarely as idiotic as they are made out to be either in our minds or our conversation.

Corruption, deception, and ignorance admittedly run rampant among politicians and their constituents. But when you listen to or talk to others about politics, try to keep in mind what effect some of those seemingly benign labels have, and remember that just because they call themselves something else doesn’t automatically mean they are less than you in any way.

How To Get Rid of Stuff

No Gravatar

Over the last decade, I have developed a penchant for getting rid of stuff. I do not lead an austere life, but I appreciate simplicity and order very much. I don’t have a lot of furniture, books, CDs, dishes, clothes, papers, or many other things that some people seem to collect or, at least, have difficulty controlling.

Part of this comes from the fact that I am only 25 at the moment, and so have not had as much time as some have to accumulate a depressingly large collection of material. Another part comes from the fact that I haven’t ever been a junk collector, and I’ve always liked being organized. I haven’t always consciously desired not having stuff, but I’ve always leaned that way.

Last Wednesday, I got home from a three-week visit to my parents’ house in California. While I was there, I tried to take the opportunity to get rid of a few things that have been stored there in my absence (since last July). I didn’t intend to do much of that at first, but when I got there, it struck me as being very important especially that I not burden other people with my stuff, beyond my desire not to burden myself with it in the first place. I even have some things in a storage unit that my aunt is graciously letting Courtney and me use part of for free—I didn’t even know our stuff had been moved there until this trip, since I wasn’t part of the moving crew (it was done for us after we moved to Virginia). As evidenced above, I’ve never been a self-storage-using sort of person, so having even a few boxes in storage is unnerving to me, though I definitely appreciate the convenience of it and the generosity of the people who made it happen with zero effort on my part.

My parents have also been going through the same get-rid-of-stuff process, though they have more stuff than I do by somewhere between one and two orders of magnitude. Their task seems much more daunting than mine does, especially to them. We talked a bit about this very thing while I was out there during this recent trip. So, I thought, why not compile a basic set of rules that I would follow if I had that much stuff to get rid of, and pass it on to them and anyone else interested?

The Problem

It seems to me that collecting a bunch of things that you don’t know what to do with, which then causes you to need more and more storage space, is analogous to getting fat. To qualify that assertion, let me say that I don’t mean that you should never buy or otherwise obtain new things. But, like consuming food, it should be done in moderation. If you eat more than you need, you get fat. If you continue to do so, you become obese to the point of being disabled and in danger of death.

While having way too much stuff doesn’t put you in the same kind of physical danger or create the same type of inconveniences, it is easy to see the parallels. Consider for instance how someone under a strenuous exercise regimen might legitimately consume perhaps 4,000 Calories per day, whereas if I ate that much, I would gain excess weight at an alarming speed. This is similar to the phase of life that parents go through while they have children; obviously, it is necessary to have more things to accommodate a developing family of five than a newly married couple, or than that same married couple after their kids have grown and moved out. If our example person stopped exercising, he would certainly need to cut back on his food consumption or risk terrible heath.

The Solution

There are two basic decisions that need to be made if you want to get rid of your stuff. They are related, but neither really depends on the other one:

  1. Decide what to get rid of.
  2. Decide how to get rid of it.

These decisions are often so hard for people that they will actually pay someone else to make them on their behalf. Companies like 1-800-GOT-JUNK exist for this reason. You may have seen people with this same problem on Extreme Makeover: Home Edition. People become too attached to their things, or they simply don’t know how to approach a problem that seems so massive. The longer they put it off, the more massive it becomes.

The first decision is definitely the harder of the two. I will assume for the sake of my rules that you want to get rid of things because you want more space, and not because you want more money. Money is sometimes a convenient byproduct of getting rid of stuff, but if you are only willing to sell things to get rid of them or you are only looking to get rid of things that are worth some notable amount of money, you probably won’t make much visible progress unless you happen to be liquidating an art gallery. If the desire to recoup your original investment is secondary to your goal of simplicity and orderliness, the whole process will be less complicated and more efficient.

So, if I were faced with the same collection of stuff as my parents have, here are the basic rules I would follow to eliminate the excess. Not all of these are absolute rules, but if you can manage to follow them 95% of the time, you’ll be much better off. (I would like to point out before going on that my parents are not stuck and/or helpless in the battle against their stuff; they have been making progress for quite some time. They just want to make progress faster, which is what prompted me to write this.) There are general principles as well as rules for specific kinds of junk, since applying general principles isn’t always easy.

General Principles

  1. Getting rid of stuff is really liberating.
    If you have a lot of stuff, it’s like having a ball and chain. You cannot move around easily. It takes time and effort to keep it organized and maintained, or if it isn’t perfectly organized, it takes time and effort to find things in the mess if you need to. It’s a psychological weight, even if you don’t need to look through it on a regular basis. Getting rid of stuff decreases your overall responsibility and gives you freedom of movement, not to mention less clutter and more space.
  2. Keeping something because you think you might use it is not worth it.
    One of the hardest hurdles to overcome is the desire to keep something because you might have a use for it one day. If you value simplicity and order, this is a more costly approach than getting rid of everything and then just re-buying things that you really end up needing. You will probably discover that you don’t miss having any of that stuff. Empty space is refreshing and motivating.
  3. Nostalgia and sentimentality are not friends of simplicity.
    This is another really difficult hurdle. If you collect gifts, cards, children’s schoolwork, baby toys, or anything like that, it can be hard to get rid of them even if you can openly acknowledge that they have no practical use. It’s emotionally worthwhile to keep things if the sentimental value is truly large enough. That is something only you can decide. But think about who will be able to enjoy it, and what will actually happen when those people are no longer alive (a morbid thought, I know, but it is important). If it’s going to gather dust for 50 years and then end up in an estate sale, you might consider saving your offspring the trouble. You might also consider digitizing sentimental things and getting rid of the physical objects, so the memories remain but the space is reclaimed.

Rules for Any Kind of Stuff

  1. If you don’t want it, get rid of it.
    Let’s start with the obvious. Voila, problem solved! This is not usually a difficult choice most people have though.
  2. If it belongs to someone else, give it back.
    If you borrowed or rented something, return it to the person who owns it. Let them deal with their own stuff.
  3. If someone else could benefit from it, give it to them.
    Often, other people can find good uses for the things you no longer need. However, this is not an excuse to pawn off your stuff on other people who have a junk problem. The idea is to continue the useful life cycle of something if possible, rather than simply getting rid of it.
  4. If you haven’t used it in over a year, get rid of it.
    If you never use it, then you might not need it. A year is a good benchmark, though of course there are exceptions. Reclaim the space now, and if you need it or something similar again at some point in the future, get a new one. You may never need it.

Rules for Self-Storage

  1. If something has been in a self-storage unit for over a year, get rid of it.
    Once again, you probably don’t really need it if you never use it. On top of that, think about what you’re paying for the storage unit. An average-size unit can easily run for $100 per month. What would you rather be doing with that money?

Rules for Clothing

  1. If you don’t like how it fits, it goes.
    If something doesn’t fit, you won’t wear it often enough, or at all. It will continually get passed over when you pick outfits, and will eventually be relegated to the back of the closet or even a box somewhere.
  2. If you don’t like how it looks, it goes.
    The exact same reasoning as the previous rule applies here. Just get rid of it.
  3. If you haven’t worn it in over a year, it goes.
    This is a little more difficult, but the same principle applies to clothes as to anything else. If you don’t use it, you probably don’t need it. Additionally, with clothing, styles change rapidly, and older clothes may not fit the style you like. Get rid of it, and get something new when the need arises.

Rules for Chemicals/Cleaners/Paint

  1. Cleaners and old chemicals should be minimized.
    Old chemicals are not only ugly, they could also be health hazard. It is rarely necessary to have many strong chemicals or cleaners on-hand for normal household use. If you have a large collection, consider paring it down a bit.
  2. If extra paint is more than a year old, get rid of it.
    The older paint gets, the more difficult it is to work with. If you’re keeping paint for a specific project, then just do the project and be done with it. If you’re keeping it just in case, then it should go.

Rules for Raw Materials (Wood, Concrete, Pipes, etc.)

  1. If it isn’t already designated for a specific project, just get rid of it.
    Raw materials are great to have on hand if you need them for something specific. But keeping them just in case you need them is a waste of space and, often, a psychological burden. It’s worth it to get the space back and the clutter gone.
  2. If it is designated for a specific project, get it done!
    It doesn’t do any good if you bought all of the wood to build a fence…ten years ago. Either use the material, or get rid of it. Simply declaring that something has a purpose is pointless (and demoralizing) if that purpose is never fulfilled.

Rules for Books

  1. If you’ve already read it, get rid of it.
    Unless it’s that very special kind of book that you know you will want to read over and over again, how likely are you to read it again? Probably not very. Save the space and get rid of it.
  2. If you need it for reference, consider getting an electronic copy instead.
    This works very well for device manuals and how-to books. You can buy or find legitimately free copies of all kinds of books. Try Mashable’s list of 20+ Places for Public Domain e-Books to get started.
  3. Try finding the same information online to eliminate the need for the book.
    The internet is your friend. You can find virtually anything, even really obscure stuff. If you’re keeping a 200-page book because of five pages of important info, it might be readily available online. If it is, bookmark or save it, and then just get rid of the book.
  4. If you’ve had it for years but haven’t “found time” to read it, get rid of it.
    Unless it’s really important and out of print, it’s far more liberating to get rid of it and then buy a new copy if and when you need or want it again. You might never notice its absence.
  5. If someone else wants it, give them your copy.
    Recycling books to other interested people is a great idea. You probably won’t be able to do it on a large scale because of the time required to match books with interested new owners, but you might be able to make a few people happy without much effort. Think about the interests of people you know and the books you have, and make some offers.

Rules for Movies and Music

  1. If it’s a VHS or 8mm video tape, convert it to digital video.
    If you don’t have the hardware to do this, services such as Digital Pickle will do it for a fee. Magnetic tape media deteriorates rapidly compared to digital video, so this should be done as quickly as possible. Keep it stored on a hard drive, or burn it onto a DVD.
  2. If it’s a cassette tape, convert it to digital audio.
    The same principle applies here (and the same company mentioned will do that, too). Digital media is easier to organize and much easier to keep intact. You can do this yourself with a tape deck and an audio cable, or you can make it even easier on yourself with a Plusdeck 2c PC Cassette Deck (I have one of these, and it works beautifully).
  3. If it’s an LP or 45 record, convert it to digital audio.
    There are services that will do this for you as well, or you can use a USB turntable. Once again, the key idea here is to convert analog to digital, then toss the analog copy. Digital media takes up far less space—virtually zero by comparison, if you store it all on a few ginormous hard drives.
  4. If you have a huge DVD collection, consider Netflix instead.
    Depending on your movie collection, this could be a massive change. Consider how much space you could recover and how much money you could recoup if you sold all of your movies, and then just used Netflix to watch what you actually wanted to see. Their average plan is less than $15/mo and gives you access to thousands of watch-instantly movies and TV shows, and just about every other movie ever made available for free shipment both ways and unlimited borrowing time. It’s almost impossible to beat. If you have 200 DVDs, how many will you actually watch, ever? If you’ve seen them once, how many will you watch again? If you sold them, how much would you get back? Netflix is a great alternative to building a physical movie collection, especially considering that most media services are moving towards an instantly available subscription model anyway. Do you really want to buy every movie again once Blu-ray becomes the everyday standard instead of the expensive option? I didn’t think so.

Rules for Papers

  1. Digitize anything important, then get rid of it.
    I go paperless whenever I possibly can. If it’s an option, I use it. It’s far easier to organize a digital file than a physical one. However, if you don’t have the option, or you’ve accumulated a lot of papers that you feel the need to keep, you can at least digitize them. Get a flatbed scanner and set aside some time to scan the papers. Just do a few a day, or pick one stack and go through it. Recycle or shred them after scanning.
  2. Shred anything unimportant yet sensitive.
    This one is kind of obvious. I use the Aurora AS890C 8-sheet shredder, and I have no complaints. It shreds anything I throw at it, provided it’s eight or fewer sheets at a time. The basket is a nice feature. Any decent shredder will get the job done. You shouldn’t have any excuses for keeping sensitive but otherwise unimportant papers around. Shred, then recycle them!
  3. Recycle everything else.
    Again, this one is obvious. If it isn’t important and it isn’t sensitive, recycle it.

Rules for Photographs

  1. Digitize them.
    That’s right—only one rule. Unless the photo has real monetary value, there is no reason to keep a physical copy when digital media is so cheap these days, and scanning is easy. Just get a flatbed scanner, as mentioned above, and scan them. You may want to look for scanners that allow slide or negative scanning as well, if you need that functionality. Once scanned, you won’t need to worry about photos losing their coloration due to temperature or moisture, and you won’t have to store them anywhere.

Whew. Okay, remember, these aren’t absolutely strict rules. You probably shouldn’t follow them 100% of the time, since there are definitely valid exceptions (in the midst of significant life changes, moving, death in the family, inheritance, etc.). But most of the time, this will really help.

What To Do With The Stuff That Is Going Away

But what about the other decision? How do you decide how best to get rid of something? Sometimes, people can decide what they want to get rid of, but they don’t know how, or they are stuck on the idea of getting some money back for their hard word and/or presumably valuable stuff. This is a difficult idea to overcome. Certain things lose their value extremely quickly, and others just have very little resale value in the first place.

It is not a bad idea to try selling something before you either give or throw it away, but it is also good to have an ultimatum for anything that doesn’t sell. For instance, you might put up a sign at your garage sale that says “Anything still here after 1pm is free!” (Incidentally, that’s not a bad idea if you want to get rid of a lot of stuff very quickly.)

Different items will sell better in different venues. Additionally, different venues require different amounts of work to get through the complete selling process:

  • A garage sale is easy for a large quantity of items, but provides the least exposure and income potential.
  • craigslist, an online classifieds site, offers good local community exposure and decent income potential, but requires more work for each sale (email or phone communication).
  • eBay offers the best exposure and maximum possible income potential, but requires a tremendous amount of work to sell individual items unless you have an assembly-line-like process for photographing, describing, listing, and shipping every item.

Trying to list everything on eBay is way too difficult unless you plan to make a business out of it. Craigslist offers a far better return-on-investment for most items. Only use eBay if you are convinced that you need maximum exposure. Rare antique items may fall into this category. Use a garage sale if you want to move lots of stuff quickly, and don’t mind a smaller profit.

Here is my general order of steps for getting rid of things, once I’ve decided it needs to go:

  1. If it’s hazardous waste (paint, chemicals, etc.), take it to an appropriate waste facility.
  2. If it’s recyclable trash (cardboard, shredded paper, etc.), take it to an appropriate recycling facility.
  3. If it’s trashed computer hardware (displays, drives, I/O cards, keyboards, mice, etc.), take it to an appropriate tech junk facility.
  4. If you expect to make less than $20 on the item (or set of items), give it away instead. The time you save is worth it.
  5. If you expect to make $20 or more, try to sell it once on the appropriate venue. If it doesn’t sell, give it away instead.

I value my time highly. If it takes me 30 minutes of time to sell something that will only make $10, it’s not worth it to me, and I’ll just give it away instead. Whether you have a fixed dollar amount on your own time or just a general gut feeling about whether or not it’s worth it, it’s important to realize that some things just aren’t worth selling. Pick a local thrift store or charity and donate the stuff instead. You might make more with a tax write-off than you would selling it even if you put in the time, and the result is instant—your stuff is gone, and you never have to deal with it ever again.

That, dear readers, is my goal. Don’t collect stuff, and don’t keep stuff longer than you need it. Don’t get too attached to your stuff, and understand that simply not having stuff is quite valuable in itself.

Up in the Air

No Gravatar

I’m at 37,000 feet flying at 502 miles per hour (give or take) right this very second. I will still be in those same conditions when I publish this post, thanks to Gogo in-flight internet service. I’ve never used it before, and this is only the 2nd time it’s been available to me (the first was on the flight over to CA a three weeks ago, whereas this is the return trip). I opted not to use it then because I just wanted to sleep, but this time I figured I’d give it a shot.

$10 for full access for the duration of the flight, which for a 5-hour flight isn’t too bad. If you fly all the time, you can get a subscription for $35/month or so, but I don’t fly nearly enough to make that worthwhile. You can use the coupon code “SAVE25″ to save a little, though I didn’t know that until after I’d signed up and had Google access. Oh well. I figured I’d use some of the flight time to do some work, so I can recoup the investment pretty easily. Plus, it’s just plain fun to write a Facebook post from 37,000 feet. I’m sure this technology will rapidly advance to the point where it’s no more exciting that using home wi-fi, but for the moment, it’s still pretty darn cool.

It only works above 10,000 feet. It’s a cellular land-based service. I’ve only had it cut out once for about two minutes while I’ve been up here. The performance isn’t incredible compared to home usage—the connection latency is about 10 times what I have at home (about 200-300 ms). However, it’s about 800kbps downstream and about 500kbps upstream, which is certainly useful enough. The speed fluctuates a bit; sometimes it’s considerably faster. Here’s a sample Speedtest.net result that I just got on this connection:

They warn about streaming video performance, for people who want to watch Youtube or Hulu or whatever, but I haven’t been doing that. They also say that FCC regulations prohibit VoIP clients like Skype, though there certainly isn’t a technical reason for that as long as they’re also allowing you to browse Youtube. Some of the higher-ups in the bureaucratic control structure just haven’t come to terms with the idea of phone calls on an airplane yet, I guess.

Anyway, I think I’ll get back to the flight. The live map says we’re over Arkansas now, and we’ll be in Atlanta in just over an hour.

Reverse Engineering a Protocol

No Gravatar

A QUICK ASIDE before the rest of the post: Today marks six years since I met my wife. Six whole years! We’ve only been married just over 10 months so far, but it’s been absolutely incredible and I know I have a lot more to look forward to. I love you, Courtney! (She also wrote about this.)

Ahem.

I’ve never really worked with protocols on a byte-by-byte level before, though I have read some data sheets on TCP/IP and the AIM chat protocol as part of a proxy program I intended to write at one time (but never did, because I found an existing program that did the same thing). Simply explained, a protocol is just a particular way of doing something. In the context of a computer, a protocol usually defines a structure of information that some hardware or software uses to send data back and forth. If both ends of the connection understand the protocol, then the information flows and everyone is happy. If either end doesn’t understand, then the connection is useless.

HTTP, for example, is a very common protocol that you use every time you visit a web page on the internet. FTP is a protocol used for transferring files. There are literally thousands of protocols in existence, some of which are widely used and some of which have only a very narrow area of application. Many are free, open standards and have lots of documentation available to describe how they work and how to use them. But some are proprietary and have no freely available info. Sometimes you can’t even pay a person or company for the info, either because they guard it too closely or they aren’t around anymore to explain it.

For a project that is actually related to something my mom is doing, I’ve had the opportunity over the last weekend to try to reverse engineer one of these proprietary protocols. I’ve made good progress so far, but I’m not done yet. The device is a stenography machine, and it uses a serial port to send keypress information and other data to the computer. Neither my laptop nor desktop even have a built-in serial port—the technology is too old and most people don’t need it anymore for normal computer usage. However, USB-to-serial adapters are easy to come by and fairly inexpensive, so I got one in the middle of last week and set to work.

To learn the details about a serial protocol, you need a few things:

That last item is kind of ambiguous, but if you look at a set of strings of bytes represented in hexadecimal format and have absolutely no clue where to start, then this may not be the project for you. It is important to be able to recognize which bits stay the same and which ones are different, and to know how to look for things like boundary markers, sequence numbers, and checksums.

Also, having a program that already talks to the device is critical. If all you have is a terminal program, you probably won’t be lucky enough to have the device respond to English-like commands, or even technical ones that seem reasonable. If you have a program that communicates to the device, then you have someplace to start. Use that in combination with the monitoring software to gather as much information as possible about which information packets correspond to which actions, buttons, or events in the software or on the device.

The interesting thing I have discovered first-hand with this is that you really don’t need to know what everything means in order to make something useful. It just needs to work. I’m almost there, too…only one more hurdle to overcome before I have a working proof-of-concept application to experiment with. Coincidentally, the hurdle isn’t even in the protocol, as far as I can tell; there’s a bug in my application that is breaking the captured response data under some set of circumstances that I haven’t figured out yet.

I do love a good challenge though.

Copy Protection Fun with Assembly and Machine Code

No Gravatar

I recently had the enjoyably challenging opportunity to patch a very, very old bit of software to defeat some very basic copy protection. (DISCLAIMER: this post doesn’t describe how to circumvent any kind of new application or game protection, which is typically orders of magnitude more complicated than this old stuff.)

[UPDATE 6/17/2010: see links at end of post for assembly code references]

Twice now, I’ve found myself with an ancient, unsupported program that has a pointless copy protection mechanism in place. This particular one required two codes to be entered into a separate activation program, which would then create a separate hidden file that the main program would read to detect proper activation. Fortunately, I learned just enough in my Assembly class from Fullerton College that looking at a disassembled DOS executable doesn’t completely intimidate me. I don’t know most of it, but I do understand basic instructions like mov, jmp, jz, and the use of registers and flags.

What’s nice about old software is that the activation code can usually be traced down to a single logical test, which is just a logical operation followed by a conditional jump. The trick is to find this code, and then replace the conditional jump with either a no-op or an unconditional jump, depending on whether the original code jumps to a failure or success location. I have used this technique to write a no-CD patch, and now also an activation bypass patch. You need a couple of tools like IDA Pro (not free) or PVDasm (free) for disassembly, and then another one like HxD (free) for straightforward hex editing.

Here’s some clipped disassembled code from this last project:

seg008:12D3 call sub_1967F
seg008:12D6 or al, al
seg008:12D8 jz short loc_1A7FB

seg008:1309 jmp short loc_1A808
. . .
seg008:130B ; ----------------------------------------------------------------
seg008:130B
seg008:130B loc_1A7FB: ; CODE XREF: sub_1A75B+6D j
seg008:130B mov al, 0
seg008:130D push ax
seg008:130E mov di, offset aActiveError ; "Activation Error."...
seg008:1311 push cs
seg008:1312 push di
seg008:1313 call sub_2C89A
seg008:1318
seg008:1318 loc_1A808: ; CODE XREF: sub_1A75B+9E j
seg008:1318 mov sp, bp
seg008:131A pop bp
seg008:131B retf
seg008:131B sub_1A75B endp

The important bit is the bold red at “seg008:12D6″ and “seg008:12D8″. The “or al, al” is the logical instruction which sets the “zero” flag if the “al” register is equal to zero. Then the “jz” instruction right after it is a conditional jump to that “loc_1A7FB” label shown below. That’s the part that displays the activation failure message, so I figured that conditional jump was the code to change. In machine code, it’s just two bytes: 0×74 (the jz opcode) and a 1-byte memory offset that points to the new location. I just replaced those two bytes in the .exe file with 0×90 (no-op), and voila! Now it never, ever jumps to the error message, and instead always just continues.

Chalk another one up to machine language succeeding where high-level languages are unusable.

UPDATE 6/17/2010: I’ve found a couple of excellent reference guides that help when you need to make direct edits to machine code:

X86 Opcode and Instruction Reference Home (byte-to-instruction reference)
http://ref.x86asm.net/coder32.html

DOS INT 21h – DOS Function Codes (disk access and some I/O reference)
http://spike.scu.edu.au/~barry/interrupts.html

Memorial Day and Just War Principles

No Gravatar

In light of the fact that Monday is Memorial Day, and with people’s thoughts being directed towards those who have died fighting in wars, I propose a thought experiment about the idea of a Just War. I directly lifted the following summaries of Just War ideas from Wikipedia, because they seem clear enough:

Jus ad bellum (Right to Wage War)

  1. Just cause: The reason for going to war needs to be just and cannot therefore be solely for recapturing things taken or punishing people who have done wrong; innocent life must be in imminent danger and intervention must be to protect life. A contemporary view of just cause was expressed in 1993 when the US Catholic Conference said: “Force may be used only to correct a grave, public evil, i.e., aggression or massive violation of the basic human rights of whole populations.”
  2. Comparative justice: While there may be rights and wrongs on all sides of a conflict, to override the presumption against the use of force, the injustice suffered by one party must significantly outweigh that suffered by the other. Some theorists such as Brian Orend omit this term, seeing it as fertile ground for exploitation by bellicose regimes.
  3. Legitimate authority: Only duly constituted public authorities may wage war.
  4. Right intention: Force may be used only in a truly just cause and solely for that purpose—correcting a suffered wrong is considered a right intention, while material gain or maintaining economies is not.
  5. Probability of success: Arms may not be used in a futile cause or in a case where disproportionate measures are required to achieve success.
  6. Last resort: Force may be used only after all peaceful and viable alternatives have been seriously tried and exhausted or are clearly not practical. It may be clear that the other side is using negotiations as a delaying tactic and will not make meaningful concessions.
  7. Proportionality: The anticipated benefits of waging a war must be proportionate to its expected evils or harms. This principle is also known as the principle of macro-proportionality, so as to distinguish it from the jus in bello principle of proportionality.

Jus in bello (Conduct During Wars)

  1. Distinction: Just war conduct should be governed by the principle of distinction. The acts of war should be directed towards enemy combatants, and not towards non-combatants caught in circumstances they did not create. The prohibited acts include bombing civilian residential areas that include no military target and committing acts of terrorism or reprisal against civilians.
  2. Proportionality: Just war conduct should be governed by the principle of proportionality. An attack cannot be launched on a military objective in the knowledge that the incidental civilian injuries would be clearly excessive in relation to the anticipated military advantage (principle of proportionality).
  3. Military necessity: Just war conduct should be governed by the principle of minimum force. An attack or action must be intended to help in the military defeat of the enemy, it must be an attack on a military objective, and the harm caused to civilians or civilian property must be proportional and not excessive in relation to the concrete and direct military advantage anticipated. This principle is meant to limit excessive and unnecessary death and destruction.

Jus post bellum (Ending a War)

  1. Just cause for termination: A state may terminate a war if there has been a reasonable vindication of the rights that were violated in the first place, and if the aggressor is willing to negotiate the terms of surrender. These terms of surrender include a formal apology, compensations, war crimes trials and perhaps rehabilitation. Alternatively, a state may end a war if it becomes clear that any just goals of the war cannot be reached at all or cannot be reached without using excessive force.
  2. Right intention: A state must only terminate a war under the conditions agreed upon in the above criteria. Revenge is not permitted. The victor state must also be willing to apply the same level of objectivity and investigation into any war crimes its armed forces may have committed.
  3. Public declaration and authority: The terms of peace must be made by a legitimate authority, and the terms must be accepted by a legitimate authority.
  4. Discrimination: The victor state is to differentiate between political and military leaders, and combatants and civilians. Punitive measures are to be limited to those directly responsible for the conflict. Truth and reconciliation may sometimes be more important than punishing war crimes.
  5. Proportionality: Any terms of surrender must be proportional to the rights that were initially violated. Draconian measures, absolutionist crusades and any attempt at denying the surrendered country the right to participate in the world community are not permitted.

You can read the full Wikipedia article if you like. Now, if you are interested, read the full timeline of U.S. military operations since the inception of the country. It’s quite a list, really.

Memorial Day was unofficially started not long after the end of the Civil War in 1845, though it wasn’t declared to be an official Federal holiday until 1967. In light of that, here is a list of the major U.S. military operations since then—this list is from the above linked Wikipedia article, but I have removed most of the “small” operations:

  • 1968 – Laos & Cambodia. U.S. starts secret bombing campaign against targets along the Ho Chi Minh trail in the sovereign nations of Cambodia and Laos. The bombings last at least two years.
  • 1982-1983 – Lebanon. On September 29, 1982, President Reagan reported the deployment of 1200 marines to serve in a temporary multinational force to facilitate the restoration of Lebanese government sovereignty. On September 29, 1983, Congress passed the Multinational Force in Lebanon Resolution (P.L. 98-119) authorizing the continued participation for eighteen months.
  • 1983 – Grenada. Citing the increased threat of Soviet and Cuban influence and noting the development of an international airport following a bloodless Grenada coup d’état and alignment with the Soviets and Cuba, the U.S. launches Operation Urgent Fury to invade the sovereign island nation of Grenada.
  • 1983-89 – Honduras. In July 1983 the United States undertook a series of exercises in Honduras that some believed might lead to conflict with Nicaragua. On March 25, 1986, unarmed US military helicopters and crewmen ferried Honduran troops to the Nicaraguan border to repel Nicaraguan troops.
  • 1983 – Chad. On August 8, 1983, President Reagan reported the deployment of two AWACS electronic surveillance planes and eight F-15 fighter planes and ground logistical support forces to assist Chad against Libyan and rebel forces.
  • 1987-88 – Persian Gulf. After the Iran-Iraq War resulted in several military incidents in the Persian Gulf, the United States increased US joint military forces operations in the Persian Gulf and adopted a policy of reflagging and escorting Kuwaiti oil tankers through the Persian Gulf, called Operation Earnest Will. President Reagan reported that US ships had been fired upon or struck mines or taken other military action on September 21 (Iran Ajr), October 8, and October 19, 1987 and April 18 (Operation Praying Mantis), July 3, and July 14, 1988. The United States gradually reduced its forces after a cease-fire between Iran and Iraq on August 20, 1988. It was the largest naval convoy operation since World War II.
  • 1989-90 – Operation Just Cause, Panama – On December 21, 1989, President Bush reported that he had ordered US military forces to Panama to protect the lives of American citizens and bring General Noriega to justice. By February 13, 1990, all the invasion forces had been withdrawn. Around 200 Panamanian civilians were reported killed. The Panamanian head of state, General Manuel Noriega, was captured and brought to the U.S.
  • 1990 – Saudi Arabia. On August 9, 1990, President Bush reported that he had ordered the forward deployment of substantial elements of the US armed forces into the Persian Gulf region to help defend Saudi Arabia after the August 2 invasion of Kuwait by Iraq. On November 16, 1990, he reported the continued buildup of the forces to ensure an adequate offensive military option. American hostages being held in Iran.
  • 1991 – Operation Desert Shield and Operation Desert Storm (Persian Gulf War). On January 16, 1991, U.S. forces attacked Iraqi forces and military targets in Iraq and Kuwait in conjunction with a coalition of allies and under United Nations Security Council resolutions. Combat operations ended on February 28, 1991.
  • 1991 – Iraq. On May 17, 1991, President Bush stated that the Iraqi repression of the Kurdish people had necessitated a limited introduction of U.S. forces into northern Iraq for emergency relief purposes.
  • 1992 – Kuwait. On August 3, 1992, the United States began a series of military exercises in Kuwait, following Iraqi refusal to recognize a new border drawn up by the United Nations and refusal to cooperate with UN inspection teams.
  • 1992-2003 – Iraq. Iraqi No-Fly Zones The U.S. together with the United Kingdom declares and enforces “no fly zones” over the majority of sovereign Iraqi airspace, prohibiting Iraqi flights in zones in southern Iraq and northern Iraq, and conducting aerial reconnaissance and bombings. (See also Operation Southern Watch)
  • 1992-95 – Somalia. “Operation Restore Hope” Somali Civil War On December 10, 1992, President Bush reported that he had deployed US armed forces to Somalia in response to a humanitarian crisis and a UN Security Council Resolution. The operation came to an end on May 4, 1993. US forces continued to participate in the successor United Nations Operation in Somalia (UNOSOM II). (See also Battle of Mogadishu)
  • 1993–Present – Bosnia-Herzegovina.
  • 1993 – Macedonia. On July 9, 1993, President Clinton reported the deployment of 350 US soldiers to the Republic of Macedonia to participate in the UN Protection Force to help maintain stability in the area of former Yugoslavia.
  • 1994-95 – Operation Uphold Democracy, Haiti. U.S. ships had begun embargo against Haiti. Up to 20,000 US military troops were later deployed to Haiti.
  • 1995 – Operation Deliberate Force, Bosnia. NATO bombing of Bosnian Serbs.
  • 1998 – Operation Desert Fox, Iraq – U.S. and British forces conduct a major four-day bombing campaign from December 16–19, 1998 on Iraqi targets.
  • 1998 – Operation Infinite Reach, Afghanistan and Sudan. On August 20, air strikes were used against two suspected terrorist training camps in Afghanistan and a suspected chemical factory in Sudan.
  • 1999-2001 East Timor. Limited number of U.S. military forces deployed with the United Nations-mandated International Force for East Timor restore peace to East Timor.
  • 1999 – Operation Allied Force – NATO’s bombing of Serbia in the Kosovo Conflict.
  • 2001 – Afghanistan. War in Afghanistan. The War on Terrorism begins with Operation Enduring Freedom. On October 7, 2001, US Armed Forces invade Afghanistan in response to the 9/11 attacks and “begin combat action in Afghanistan against Al Qaeda terrorists and their Taliban supporters.”
  • 2003 – 2003 invasion of Iraq leading to the War in Iraq. March 20, 2003. The United States leads a coalition that includes Britain, Australia and Spain to invade Iraq with the stated goal of eliminating Iraqi weapons of mass destruction and undermining Saddam Hussein.
  • 2004 – War on Terrorism: US anti-terror related activities were underway in Georgia, Djibouti, Kenya, Ethiopia, Yemen, and Eritrea.
  • 2006 – Pakistan. 17 people including known Al Qaeda bomb maker and chemical weapons expert Midhat Mursi, were killed in an American MQ-1 Predator airstrike on Damadola (Pakistan), near the Afghan border.[9][10] However, statements by U.S. and Pakistani officials reported in September, 2007 disclosed that that none of those al-Qaeda leaders perished in the strike and that only local villagers were killed.
  • 2009 – Pakistan, In relation to efforts in Afghanistan, U.S. Forces struck an insurgent encampment in the Northern mountains, killing 24, with missiles fired from an unmanned aerial assault vehicle.

What on earth have we been up to? And, much more importantly, why? Answering those questions could take more than a lifetime, so I won’t really try right now. But think about Just War principles, and think about the wars or individual battles that you might actually know something about. Do the principles line up with history? How many things have we done that we had no business doing?

Or, to put it another way:

  • Is the idea of a “just war” as describe above missing any principles?
  • Are any of the existing principles incorrect?
  • Can you think of a war that you consider “just” that wouldn’t be classified that way by the above ideas?

Spend some time answering those questions, and you might have a more pensive Memorial Day amidst all the barbecues and such.