Archive for the ‘ Development ’ Category

Nexus One Support in Ubuntu 10.04

I recently purchased the Nexus One from Google. It is quite an amazing phone and I've been really happy with it. I've taken interest in developing for the Android platform now that I have one. Luckily Google has provided a very good resource for Android app development at http://developer.android.com/.

Today I was working on allowing me to upload my applications onto my Nexus One so that I could test the software on a real device. Well I ran into an issue after following Google's tutorial on how to do it located here. I run Ubuntu 10.04 on my main development machine and so I followed the instructs for how to do it for Linux. Well when I got to the end of the tutorial when it tells you to test your the setup with the following command:

adb devices

I got the following output:

List of devices attached
???????????? no permissions
It turns out that Google's instructions have not been updated so reflect how to get the Nexus One to work under Linux. Well after a bit of research I came across the following blog post that explained it. Basically the list of USB Vendor IDs does not have listed the proper value for the Nexus One. I had selected to use HTC's Vendor ID ("0bb4") being that the Nexus One is actually produced by HTC, however that is incorrect. Instead you need to use the Vendor ID of "18d1". So the following line should be in /etc/udev/rules.d/51-android.rules
SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666"
NOTE: Be sure not to capitalize the D in 18d1, doing this will cause this solution not to work.
Now that you have added that line to the file, you will simply need to restart udev. With the Nexus One unplugged from your system run this command:
sudo service udev restart
Now you can plug in your Nexus One and run:
adb devices
You should see something like this:
List of devices attached
???????????????? device
I hope this helps and post below if you need any further help.

Examining Security Of Open Source and Closed Source

I recently just completed a research paper, with two of my colleagues: Clint Caywood and Matt Strayhall, on the security of Open Source Software. The paper went very in depth and I feel helped fill a void of the lack of credible information in this hotly debated topic. Here is the abstract:

In this paper, we examine the security of open source software versus that of closed source software. Facets examined include a brief history of the growing need for security in software, a comparison of the different philosophies driving the development of security in open and closed source software, arguments for obscurity in closed source versus the “many eyeballs” theory in open source, and the pros and cons involved with both development processes. We also look at the two approaches in practice, focusing on competing software like Linux and Windows, OpenOffice.org and Microsoft Office, and Apache and Windows IIS Server. Finally, we examine the impacts on society from software security, as well as who is responsible for maintaining secure software.

You can find more, including download links, if you visit my Research section of this website.

Floating Point Guide

I came across a great article about the pit falls of using floating point numbers in programming. All to often software bugs come up because developers expect something like 0.1+0.2==0.3. The article goes into very clear detail as to why it is not the case that we can expect exact equality while using float point representations.

Future of AI

AI has always intrigued me. The idea of recreating human or at least intelligent behavior with software is an amazing idea. Unfortunately modern AI is nothing like the dream of creating human behavior. Sure the current solutions can solve some pretty cool problems, but its not the types of problems that people think of when they dream of AI. At h+ Magazine an article was posted discussing what the experts of the AI field predict to happen over the next century. Most seem to think we are a long way off from even being able to pass a 3rd grade exam and possibly 100 years off from making smarter than human AI.

The thing about most AI style problems is that we can solve them in a much easier ways without AI. Passing a 3rd grade exam could be done with advances in natural language processing and some clever Internet searching. It turns out to be very difficult to find ways to test AI. Even the famous Turing Test may not be as satisfactory as one might think. Its hard for a human to tell even if they are talking to another human even if they are, in fact, talking to another human.

The reason why it is so hard to identify another human during the Turing Test is because we don't know what we expect from another human. It comes down to the fact that we have no idea what makes us human. Its nearly impossible to describe a humans intelligence and identify the intelligent parts. So it would be very difficult to quantify how an AI system is better than a human, let alone equal.

I think before we are able to make any true AI system we first need to figure out how the human mind works. Which is turning out to be much easier said than done. Every time we figure something out about the brain, it creates at least ten more questions about the brain. To put this problem in some sort of perspective: We had a theory of computation decades before the first computer hardware and we had predictive models of space centuries before we had the ability to test them. However we have the hardware to run our AI systems on, but no theory as to how to do it. So I think we are at least half a century away from having anything near what we dream AI to become.

Fast Case Converter

Often I find myself needing to convert between upper case to lower case and vice versa. This is a fairly simple thing to do if you understand ASCII encoding. A good reference for the ASCII Table can be found here. As you can see, to convert a letter to lower case you would add 32 to the current value and subtract 32 to convert it from lower to upper. However to implement this it takes a few lines of code to put some conditions in that check to see the current case and decide to add or subtract.

I was looking at the ASCII Table the other day and came up with a simplistic method to swap the case of a given character. That is to exclusively-or the value of the character with 0x20. This will convert the upper case to lower and the lower to upper. Its probably the fastest method to swap ,CPUs can xor in one cycle (excluding memory load time). However you still need some type of conditions to make sure the character is actually a letter and not a number of symbol.

Enjoy!

MySQL and Java common problem

Have you ever received the following error while using Java and MySQL:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '????????????????' at line 1

This is a common error when you first set up Java and MySQL to work together. To correct it simply add the following lines of code to your my.cnf in the section [mysqld]

collation_server=utf8_general_ci
character_set_server=utf8

Self Replicating Code

For a class recently the teacher challenged us to write a code snip-bit that would be self replicating. By that I mean write a program that when executed would write out its own source code. This is a bit harder than you'd initially think it to be. My first attempt tried to store the source code within the program when execute it would output what was stored within. However this creates a chick and egg problem. The source code contains the source code. Something that at first stumped me. Then I remembered Stringification in the C preprocessor and I came up with this:

 
#include "stdio.h"
#define M(Code) main(){FILE* fp = fopen("source.c", "w");fprintf(fp,"#include \"stdio.h\"\n#define M(Code) %s\nM(%s)\n",#Code,#Code);fclose(fp);}
M(main(){FILE* fp = fopen("source.c", "w");fprintf(fp,"#include \"stdio.h\"\n#define M(Code) %s\nM(%s)\n",#Code,#Code);fclose(fp);})
 

This is a pretty cute program if I can say so myself. When its ran it will create a file called source.c that will be exactly the same as the code above. You could even recompile source.c and it will create another source.c. You should attempt to do this on your own to see if you can come up with other cool ways of doing it.

Download: SelfRep.c

Consider both sides

I was recently watching some research project proposals at my university. One of the proposals caught my eye, it was a way to stop common cheating techniques for page rank. At first glance the proposal has some good merit, the system would stop the current techniques used. However the problem was that they did not take into account what new problems they would introduce.  The actual proposal is still private so I can not talk to much about the details.

It is very common to come up with solutions that fix very common bugs. What is equally as common is creating new bugs that are as bad as ones that were corrected. When fixing security vulnerabilities the fixer must consider both what is fixed and what bugs the fix will introduce.

Twitter can be neat

If  you are like me you don't exactly see the usefulness of the social networking site Twitter. After reading a recent wired article I can not better see that usefulness. There appears to be some pretty clever people connecting common house hold devices to Twitter.

This really isn't all that new of a concept however. People have been connecting bots to IRC for control for a very long time now. I would suspect similar devices have been plugged into IRC. I wonder about the secuirty behind putting so much control of your house onto the net. Losing control of your own account could give an attacker control of say your air conditioning and drop your house to 60 degrees. Causing your electric bill to ski rocket.

Great C Tutorial

Dr. Dave Marshall at Cardiff School of Computer Science has written a great C tutorial. This tutorial is mostly aimed at UNIX C developers and covers the basics of C programming to advanced multi-threaded application development. This is the tutorial that I used to learn C and I still open it up whenever I need to look up something new or need a quick refresher on something. Unfortunately it appears that Google keeps burying the link so I thought it would be helpful to others that are looking for in my opinion the best C tutorial available online.