Thursday, July 29, 2010

Prime number

http://www.dzone.com/links/rss/a_regular_expression_to_check_for_prime_numbers.html

Just in case that link ever fails in the future, a regular expression to check for PRIME numbers? This breaks my mind too much.

Regular expressions are extremely powerful: /^1?$|^(11+?)\1+$/ checks if a number is prime or not.

Monday, July 26, 2010

Cribbage calculator

While playing cribbage with my girlfriend (who always kicks my behind in it) I decided I needed a little help doing the calculations to compute the score in your hand at the end of a round. I looked into the app store and there is no "cribbage calculator". Maybe I didn't look hard enough, but either way this has inspired me to try and do my first android application.

http://download.oracle.com/docs/cd/E17476_01/javase/1.5.0/docs/guide/language/enums.html

Thats probably a good place to start to construct a deck.

My next goal after that is to have the ai do a search based on your hand to see how many points you should have (but that will come later).

Assuming i can prototype the calculator, I'll then port that to an android app with graphics and such at some point in the future.

Tuesday, July 6, 2010

Custom Components

In the book Android 2- Application Develpment there is a section in chapter 4 that describes how to create compound components. He shows the basics of creating one, but doesn't actually show you how to use it. Unfortunately his example code only shows him overwriting one of the two constructors.

Constructor(Context context){
super(Context context);
}

Constructor(Context context, AttributeSet attrs){
super(Context context, AttributeSet attrs);
}

It is important that you overwrite both in my opinion, but especially the second. If you don't, your application won't be able to set the layout from your xml file attributes. Goes to show how important it is to correctly overwrite the constructors.

Random droid error

While following my guide/tutorial reading I ran across the strangest error with the Droid SDK and eclipse. In case any of you also have a "compiling" error in eclipse that won't let you start up the droid emulator due to a "Unparsed aapt error(s)! Check the console for output" but you dont have any real coding errors you might want to consider just deleting that error message and re-running the application to compile.

It worked for me without any code/bug fixing. This took me a good hour before I figured googling the issue might be a good idea. So hopefully I'll save some of you an hour too.