This is my blog where I hope to post information about what I am doing technically and what my family is up to. I hope you enjoy

Monday, May 24, 2010

Formatting LogCat Output

The output from an Android Logcat application can be quite difficult to determine problems especially without being in debug your application.   Logcat is a great way to view the logs.  I found a really nice python script that enables one to format the Logcat log so that the log types DEBUG, WARN, INFO, etc are colored making it easier to view.

Here is the output of such a log after piping the logcat to the python script;
This is a terminal output of the Logcat log.  I captured this while running my Android application in debug mode within Eclipse.  This log is much easier to read than the logcat that is within Eclipse.

How did I do this?   execute the following on the terminal command line.
adb logcat |  ~/tools/scripts/coloredlogcat.py

The coloredlogcat.py is a python script I got from colored.   I stole this script from Jeff Sharkey, thanks Jeff.

Monday, May 17, 2010

Chrome Browser Plugin/Extension

Found this awesome little Chrome Browser plugin from BuiltWith .  Actually Firefox calls them plugins for Chrome it is an extension.

With this extension you can determine all of the technologies any non-https website you visit uses.  You will be able to determine what client side technologies and server-side web servers they use.  

I used to determine this information by checking out the url and viewing the source of the page I was visiting for the libraries they pull into the page.   This nice little extension enables one to simple ask.

I have not viewed how BuildWith is doing this.  Not sure if they have a database of this information they have collected or they are determining this information at run-time.


Here is the href to the extension

Friday, May 14, 2010

Android Shared Preferences

Android has a concept of an application storing default information in a preference. Example would be when a user first down loads an Android application installs and configures the application with some setting like email or user name. During the setting of the application the information retrieved from the user can be stored in the SharedPreference API. This is a very easy way to save data that can be used later even after the application is stopped and restarted.

public class ConfigActivity extends Activity {
     public void onCreate( Bundle state ) {
         super.onCreate( state );
         // Show the config settings in View
         saveButton = findByViewId(...);
         saveButton.setOnClickListener( new View.OnClickListener() {
                   public void onClick(View v ) {
                      saveEmail(user, pass);
                   }
          });
         // Get Email and place into config Text box
      }
protected void saveEmail( String user, String pass ) {  
         SharedPreferences pref = null;
         getSharedPreferences( "EMAIL_SETTINGS", this.MODE_WORLD_WRITEABLE );
// Must edit and commit
         Editor edit = pref.edit();
         edit.putString("emailName", user);
         edit.putString("emailPassword", pass);
         edit.commit();
      }
protected String getEmail() {
         SharedPreferences pref =
         getSharedPreferences("EMAIL_SETTINGS", this.MODE_WORLD_READABLE );
         String email = pref.getString( "emailName" , null); 
         return email;
      }
}

Friday, May 7, 2010

UNIX via JavaScript

Just came across this JavaScript library JS/UIX Terminal that enables you to run UNIX within the browser. A lot, not all, of the unix commands work in this little tool. I find it amazing what developer can do with software. I am not sure why this person decided to build this what it can be used to do functionally I am not sure. Still pretty cool.

Possibly a good use for this would be to give your UNIX friendly users an interface they are used to in the browser.
Layout-->Edit HTML -->