Monday, March 12, 2012

New Apps

New Apps Released!
Well it was a busy couple of weeks, I have released 2 apps on the market in the last few weeks.  Pizza Area, and I Am Here.

Pizza Area
This calculates the square inches of a pizza for you (really works for any size circle with a diameter), Also if you have a price it'll calculate the price per square inch, as well as the estimated cost at that rate for the pizza size smaller and larger that the app contains. Give it a try and let me know if you have any suggestions, and as always a positive rating on the appstore would be appreciated.


I Am Here
This app will allow you to select a friend from your contacts (or type the number in) and when you hit the icon it'll send a message. This app is very similar to another one on the Apple Market, I was a little disappointed I hadn't released this sooner, my buddy civissmith had come up with the idea originally,  and I was just way to slow to implement. Well give it a try either way, I think mine has a little more spunk then the Apple Market version.

That's all for now, I have so many projects in the works at all time, I just have to finish a few so I can write about them.

Thursday, February 16, 2012

GraphViz

I decided to start playing around with GraphViz, here are a few of my notes:
To call a file use the following command (works for me).

dot .gv | dot -Tpng >.png
This generates a png file.

Next up what the .gv file contains:

digraph G {Hello->World; World->Earth; World->Mars; World->Jupiter}

It looks like if you call it a digraph, and give it each of the start/finish points, it'll graph them for you.

I'll be back with more as I discover more.

Friday, February 10, 2012

TrueCrypt

I was having problems getting truecrypt to work on my ubuntu machine. Once I downloaded it and unzipped it there was no extension and for some reason my machine didn't know what to do with it. I simply renamed it with a .sh at the end and re-ran the file, everything worked as advertised at that point.
I.E. FROM: truecrypt-7.1a-setup-x86
      TO: truecrypt-7.1a-setup-x86.sh


Good Luck

Tuesday, January 10, 2012

Android Like SQL Statement, sqllite sql software

While using sqllite sql software for android, I was runing into problems. I was able to do exact matches, but for some reason I couldn't get LIKE matches to work. I was hunting around like crazy trying to figure out how to write a LIKE statement in Android. I had a working example of '=' and figured it would be pretty simple to use the LIKE command. After many variations I just couldn't figure it out. I almost posted to stackoverflow but decided to read the information on the "rawQuery" parameters of the database methods.

After doing a little reading it turns out that if you enter in a ? in your query it pulls the selection arguments and stuffs them in where that ? is. My first example didn't exactly make it clear that ? was replaced with the arguments, so now that I knew that it led me to my next train of thought.

As silly as this might sound my original query that pulled exact matches in used this:
cursor = db.query(DBHelper.TABLE, null, DBHelper.C_TEXT + " =?", whereArgs, null, null,null);

I finally tried this:
cursor = db.query(DBHelper.TABLE, null, DBHelper.C_TEXT + " LIKE ?", whereArgs, null, null,null);

Guess what? The whereArgs get stuffed in the ? position.

As much as I could have sworn I tried this, apparently I tried various iterations. Be sure if you're going to  use this, make sure you have "column" space "LIKE" space "?" and then your arguments as the next parameter. If you notice that the first example I was using had no space between the front, between the = and ? as well as behind, this is part of what tripped me up, LIKE is a word so you have to be sure to separate them using the right spaces.

If you're not sure what a column is take a look at W3 Schools SQL Like Tutorial. It doesn't explain the ? and how that works with respect to android. But after reading to this point you should be able to use the LIKE command in android.

I hope this helps others, so long and short of it, I can now query my db with a like operator, and it works.

Note* whereArgs contains only one element which contains % on either side in my case (%string%). Perhaps in the future I'll poke around at the options when I have more then one string in that field.

Monday, October 17, 2011

Music Glove Part 1

Well after much heartburn (and once again being burned by pull down resistors). I have managed to make some progress.

I now have half of my Music Glove prototype complete. This is the hardware side. I paired a bluetooth module from sparkfun (something that does uart). With an arduino to handle the button presses. I can now receive an A and a B from my button presses on my phone using the BlueTerm application.

Once I am able to handle receiving the bluetooth data on the phone side, I will better package the whole assembly.

Here is a shot of the circuit:




Here is the code which does all the work:

/*
  What you will need to do is wire up your bluetooth module hooking the RX and TX up to the arduino, then

 */

// A is IO 2
int A = 2;              // Switch connected to digital pin 2
int AState = 0;              // Switch connected to digital pin 2
int AStatePrev = 0;              // Switch connected to digital pin 2
// B is IO 3
int B = 3;              // Switch connected to digital pin 3
int BState = 0;              // Switch connected to digital pin 3
int BStatePrev = 0;              // Switch connected to digital pin 3


int buttonState = 0;


void setup()                    // run once, when the sketch starts
{
  Serial.begin(115200);           // set up Serial library at 115200 bps
  pinMode(A, INPUT);    // sets the digital pin as input to read switch
  pinMode(B, INPUT);    // sets the digital pin as input to read switch
}


void loop()                     // run over and over again
{
  AStatePrev = digitalRead(A);              // Switch connected to digital pin 2
  BStatePrev = digitalRead(B);              // Switch connected to digital pin 3
  delay(60);
  BState = digitalRead(B);              // Switch connected to digital pin 3
  AState = digitalRead(A);              // Switch connected to digital pin 2

  // Handle button "2" presses 
  if (BStatePrev==BState)
  {
    if (BState == HIGH)
    {
      Serial.println("B");
      delay(60);
    }
  }
  // Handle button "1" presses
  if (AStatePrev==AState)
  {
    if (AState == HIGH)
    {
      Serial.println("A");
      delay(60);
    }
  }

}

Tuesday, August 16, 2011

Folder Permissions

I've been having problems with folder permissions on ubuntu, oddly enough, trying chmod 777 on stuff wasn't really working well, basically I just did gksu nautilus then I modeled the "permissions" tab to the same as a folder I wanted permissions to be the same as. Apply to all files/folders within and viola it worked.

Hope that helps others.

Originally found the command from http://ubuntuforums.org/showthread.php?t=1086624 although I have heard of it before, just haven't used it much.

Tuesday, August 9, 2011

Boxee Update DEB

I was hoping to download boxee for my recently updated media server.

Turns out that boxee has some issues with the package downloadable from here:
http://www.boxee.tv/make#content

The original site I built the script to mimic is located in the source code.

The file which did the job for me can be found here:
Boxee Deb Fix


Good luck!

Friday, July 29, 2011

getc/getchar why doesn't it wait?

So getc is basically the same as getchar but to get the same effect
getc(stdin) = getchar basically.
From the above link:
Returns the character currently pointed by the internal file position indicator of the specified stream. The internal file position indicator is then advanced by one character to point to the next character.

What this means is that this is not a "wait for input" type operation, it literally will grab the next character from the stdin stream unless you find a way to prevent it,


Example function from code to be used:

char getMathSymbol()
{
while (getchar() == '\n') // use this or getchar will not wait for input.
{
// temp varaible
char userSymbol;
cout << "please enter yoru math symbol" << endl;
// need getchar to get a character from the console
      userSymbol = getchar();
      
//cout << "getchar done" << endl; // debug code
// return your symbol
return userSymbol;
}
}

For Example you entered in the following:


Enter your first number
1
Enter your second number
2
please enter yoru math symbol
+
3


Lets look at this again, with all (hidden) characters visible
Enter your first number\n
1\n
Enter your second number\n
2\n
please enter yoru math symbol\n
+\n
3



When you hit getMathSymbol
you are at this point:
Enter your first number\n
1\n
Enter your second number\n
2\n
please enter yoru math symbol\n

When you get the char, the \n is grabbed (which is why the "while loop works").

So what I suspect happens is that we hit that \n and since it's a valid character (not end of line or end of file) we grab the character and exit the function. (when the while loop is gone).

What happens if we read the last character to increment to the next char (which is EOF or EOL)?

char getMathSymbol()
{
//while (getchar() == '\n') // use this or getchar will not wait for input.
{
// temp varaible
char userSymbol;
cout << "please enter yoru math symbol" << endl;
// need getchar to get a character from the console
           userSymbol = getchar();
           userSymbol = getchar();
      
//cout << "getchar done" << endl; // debug code
// return your symbol
return userSymbol;
}
}

After compiling, it looks like it works, so what happens is that if there is a valid character the getchar returns immediately, if the next char isn't valid, then it waits until a valid char occurs.

Make sense?

Thursday, July 28, 2011

Forward Declaration vs Function Prototyping, What's the difference?

Valid Conditions
The following will be how we can get a successful compile.

This would be using Function Prototyping:

### BEGINNING OF FILE###
... // declarations of whatever you want

void INSERT_STRING (char b);

int main()
{
  INSERT_STRING("A");
}


void INSERT_STRING(char b)
{
  // Where INSERT STRING is literally implemented.
}
#### END OF FILE ####



This would be Forward Declaration.

### BEGINNING OF FILE###
... // declarations of whatever you want

void INSERT_STRING(char b)
{
// Where INSERT STRING is literally implemented.
}

int main()
{
INSERT_STRING("A");
}
#### END OF FILE ####

Now what this last one means, is that if you wish to use INSERT_STRING, it must be fully implemented above the calling function (in this case main).



### BEGINNING OF FILE###
... // declarations of whatever you want

void INSERT_STRING (char b);
void USE_INSERT_STRING();
int main()
{
USE_INSERT_STRING();
}

void USE_INSERT_STRING()
{
INSERT_STRING("b");
}
void INSERT_STRING(char b)
{
// Where INSERT STRING is literally implemented.
}
#### END OF FILE ####

This is because the function has been prototyped, when the compiler goes to use it it knows that some function exists that has such and such properties and then it won't complain.
When it finally hits that function it compiles it, I am pretty sure that later the compiler comes back to the USE_INSERT_STRING function and replaces the "pointer" (or however it knows where to go to "call" the function), with the location that INSERT_STRING finally ends up, but don't quote me on it, as I'm not 100% certain, and I don't know compilers that well. If someone can confirm I would appreciate it.




Error Conditions
The following will contain some examples of how we can fail to compile.

Post Declaration with No Prototype

### BEGINNING OF FILE###
... // declarations of whatever you want

int main()
{
INSERT_STRING("A");
}

void INSERT_STRING(char b)
{
// Where INSERT STRING is literally implemented.
}
#### END OF FILE ####


Gotcha
This time it is by another function then main. You might have thought you were safe, but this should fail as well.

### BEGINNING OF FILE###
... // declarations of whatever you want

void USE_INSERT_STRING()
{
  INSERT_STRING("b)");
}

void INSERT_STRING(char b)
{
  // Where INSERT STRING is literally implemented.
}

int main()
{
USE_INSERT_STRING();
}
#### END OF FILE ####

The above fails because again the compiler is trying to use the function INSERT_STRING in USE_INSERT_STRING, and since it's not been "forward declared" (declared before it's used), it fails.

Saturday, July 16, 2011

Building an Echo Server using Bluetooth and Blueterm

I recently picked up the Bluetooth moduleRN-42 This was a cheap low cost way to integrate Bluetooth into an upcoming project. First up was getting the pieces soldered. Thanks to Walter over at Walter's Epic Blog he hooked me up with a great soldering job.
He soldered up the power, ground, tx and rx lines, as well as the required SPI lines in case I need to program the device.
I got the itch a little bit ago and started doing some research on building an Android App to communicate with this thing (with the eventual plan to hook it up to a microcontroller). I found BlueTerm this program connects to a Bluetooth Device and sends UART data across.
I started thinking to myself I wonder how I can echo the data back without having to build the UART up for my microcontroller. I asked the question over at electronics.stackexchange, and of course being the impatient type I just jumped in and hooked the rx to the tx lines.
As you can probably guess from the little jumper above, those are the RX and TX lines. It worked, I type something and bam it echoes it back. I'll be posting more as I build this project up so stay tuned.

Sunday, July 10, 2011

AsyncTasking

I was attempting to place my calculations from eecon into an AsyncTask.  I initially thought I would make a common task, calling it from both my find factor activity, and my find interest activity. I had to deal with the whole mess of figuring out which one was being called, and whatnot. Then I ran across the problem of getting the data back from the task. I initially tried using the getstatus function that async provides, as well as the get function, this returns the result. Seems great right? WRONG! get is blocking, this means that when I kick off the async task, it doesn't just kick off and run and when it's done let the UI know it's done, I FROZE the UI. This is bad.  Now if my calculation is time consuming then we have a chance at a force close. I wanted to try to pass the data back to the UI components so hopefully I wouldn't have to cause the main thread to wait. I wasn't sure how to do this, but after reading about the AsyncTask more, I realized that the onPostExecute was supposed to update the calling UI thread. Finally I realized (after a little reading) you can place the AsyncTask class in as a subclass, this allows it to have access to the parent's elements. 

No more blocking and no more force closes from this calculation.

Good luck and Good night.

Saturday, July 2, 2011

Admob in Android

This link is great for just throwing a quick ad in with admob into your app.

http://code.google.com/mobile/ads/docs/android/fundamentals.html

followed by the following:

http://code.google.com/mobile/ads/docs/android/banner_xml.html

Basically you add the "publish code" jar to your app, then insert a few lines into your manifest. Then you place the banner into your app where you want.

The one piece that tricked me is that if you simply try to add the sample xml unit to your project you need to make sure that in the main layout (the one that declares the "android" namespace), you need to add the following:

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"

Monday, April 4, 2011

Job At Google

Well I finally did it, I applied at Google, I don't know if I'll ever feel ready with the epicness this company has brought to every household. If not, I won't discourage, I'll keep working, if anything I'll create a business that Google will want to buy, so I'm not too worried, if it doesn't happen now, it will someday, but then again someday I might be ready for my own business and will be able to R & D on my own merits.

Here is my submission window, I was kinda excited:

Monday, March 28, 2011

Ideas

How often do you have "big ideas"? It frustrates me as I have so many ideas so frequently, and I don't have enough time to implement them all. Once school is out, I'll have some more freetime and will finally be able to hit on all the projects I've got queued right now.

Stay tuned, when May hits, there will be a lot, I might even start making more videos about the projects and build process.

Thursday, March 24, 2011

Google Market vs. Amazon Appstore

The Amazon App store looks good, and yes I do like the recommendations and whatnot just like regular old Amazon. My question for the big G is this, we had to check "unknown sources" just to get the appstore on our phones and download apps through them.

Recently there were some issues with some apps found in the Android App Market and this prompted google to remove apps from their store, as well as remove them from infected phones. Will they continue to do this with Amazon Store apps, or will it be a "too bad" because it's not something we're controlling, and you took the risk.

Will this fall on Amazon's shoulders?

Here are the emails I've sent to Amazon when I get word from them I'll update:

Since we are installing apps from the Amazon App Store, what will the process be if/when an app that has been downloaded has been found to contain a virus?

Tuesday, March 22, 2011

Batch Renaming

I have a bunch of MTS files that I get from my camcorder, and frankly I don't have any interest in sitting down and renaming each file by hand, in perl this is a pretty simple case, I decided I wanted to name them based on their creation date, then number of file in that creation date. I still would say read over this script and make sure you understand what it is doing and then go ahead and use it.

This can easily be modified to work with any kind of file, but I was only concerned about my video camera files. if you want change the <*.MTS *.m4v> to whatever file types you want!


Here is the code:
#!/usr/bin/perl
# Written by Tyson Bailey
# with date/string creation from: http://www.seto.org/mt- diary/archives/2005/11/using_perl_to_d.html
use File::stat;
use Time::localtime;
@files = <*.MTS *m4v>;
$extension = "";
foreach $file (@files)
{
    # get date/time
    $date_string = ctime(stat($file)->mtime);
    # break it up into an array.
    @date = split('\s+',$date_string);
    $i = 0;
    # figure out file extension
    if ($file =~ m/.m4v$/)
    {
        $extension = "m4v";
    }
    else
    {
        $extension = "MTS";
    }
    # Filename format MAR_05_2011_x.extension
    while (-e "@date[1]_@date[2]_@date[4]_$i.$extension")
    {
        $i++;
    }
    # just to be safe
    $base_name = quotemeta("@date[1]_@date[2]_@date[4]_");
    chomp($file);
    # if our filename already exists we really don't want to try renaming it.
    if ($file !~ m/$base_name/i)
    {
        print "Didn't Matched: $base_name\n";
        print "Renaming: " . $file . "\n";
        print "To: @date[1]_@date[2]_@date[4]_$i.$extension\n";
        rename("$file", "@date[1]_@date[2]_@date[4]_$i.$extension");
    }
    else
    {
        print "Not Renaming: $file\n";
    }
}

Big thanks to:
http://formatmysourcecode.blogspot.com/
for formatting my source code!

Wednesday, March 2, 2011

Friday, December 24, 2010

GoogleTV

Right now I am watching Youtube on a Google TV. I see some things that should very much be fixed. Frankly the video should be larger,the page itself takes up a ton of space, and the suggestions, those should be a side bar pop-in, same with comments.

Here's a quick screenshot:
and it looks almost exactly like this on the tv, and if all I was doing was websurfing, this wouldn't be a problem, but since I'm wanting to watch video on GoogleTv, I don't want to see this, I'm hoping google will come out with a youtube app that cleans this interface up.

Things like centering the video, and allowing a translucent slide in from the right with a set of suggestions for additional videos. And finally the comments should slide in from the bottom, just a small bar not distracting.

Interestingly enough. Why is it ok to have an interface like this on a regular computer, but when we get to hand held device, or something small, we want a cleaner and simpler interface, the question is, is this how interfaces should look on computers? I mean google got it right when they designed a really simple and clean interface for searching. Google taught us that screen real estate is valuable and as a company they wanted to make sure it was worth it. When it comes to TV, the same holds true.

On second thought why do websites even have search bars anymore? I mean why not push it back on the browsers to simply allow a search function that searches whatever is on the current domains content. If I can find a way to create apps for GoogleTv I think any media sites should be the first targeted, either that or create a "tv." version much like mobile contents. This comes back to the whole idea of content vs formatting separation. Why not just put a bunch of websites together and say "heading" and "video" and then the device that get's it can format it how it likes....wouldn't that be sweet? Well I hope you've managed to follow the off the wall insanity that my posts seem to like to follow. If you have Google TV, what do you like, or not like about it?

Wednesday, December 8, 2010

SPI vs UART vs I2C vs Four Event Protocol

I had to write a paper for my Computer Organization and Architecture course. Its due this evening but if you want to take an early look I've shared it on google docs. I plan to make a few grammatical edits, if you have any additional suggestions or comments I'm all ears.
Here's the link:
Communication Protocols