Sunday, December 30, 2012

Gambling - How much should you bring to the table?

I just came back from Atlantic city where we stayed at the Borgota.  We basically did three things:
  1. Ate steaks at Old Homestead - The steaks were tasty, but you definitely needed steak sauce.  I prefer it when steaks have enough taste that using sauce is unnecessary.
  2. Drank at the tables - The liquor was not top shelf.  I would've like some better options.
  3. Played blackjack and craps - Some of us won and others lost.
Since gambling is what we did for the majority of the trip, it's still on my mind.  One thing I noticed is that the losers started out with less money than the winners.  In gambling, as in life, the rich get richer and the poor die trying.

The reason that the players with smaller bankrolls tend to go bust faster is simple; they cannot survive even the smallest fluctuations.   After a few losses, these players hit 0 and cannot recover.  Players with bigger bankrolls are more able to survive downswings and make a run to actually make some money.

In my experience, I often go to the casino willing to use about 200 dollars a night.  If I play blackjack, I typically sit at a 10 to 15 dollar table.  This gives me 13-20 bets to work with it.  The question I have is: How long can I expect to play before busting out?  Of course, there may be times where I lose every hand and bust out after 13-20 bets, and there may be a time where I make so much that I will last through the night.

I'm sure there is a good mathematical way to express what is occurring here.  It is a random walk, with a weighted probability of losing slightly higher than winning each hand.  If I have some time, I'd like to:
  1. derive formulas that will give me the exact expected value of busting out over time.
  2. derive an easy way to get a quick back of the envelope calculation of the expected value.
  3. Write computer programs to simulate the results, which will confirm my formulas.
If I ever get some time to do the above, I'll update this post with the data or update with a link to another post.  If you know of this analysis already, please leave a comment.

Friday, December 28, 2012

HP Pavillion Laptop

I just bought a HP Pavilion g7-2238nr 17.3-Inch Laptop and a Microsoft Office Home & Student 2010 - 3PC/1User (Disc Version) for my aunt.


This post will just be a rundown of my first impressions of setting up the system.

Physical aspects
  • The screen is big and bright.  
  • The raised keyboard keys feel solid.  Each key feels like it can only be pressed up and down.  The keys on some other budget-friendly laptops I have tested felt like you could accidentally push a key sideways (if that makes sense).
  • The frame looks sleek, but the plastic feels cheap and it will probably feel cheaper over time.
  • The track pad has a nice grated texture.  However, given the huge size of the screen, the default mouse sensitivity or speed is too low.  If I start at one end of the screen and slide across the track pad, I can only make it about half way across the monitor before I have reached the end of the track pad. 
  • The mouse buttons below the track pad are a little hard to press.  I think this is good as they will probably loosen up over time.
  • The cd drive is very loud (as I ran it to install Microsoft Office).
System setup 
  • Initial setup was pretty painless.  It probably took a total of 15 minutes.
  • I used the express settings, as I often choose default settings anyway.
  • Since I am setting this laptop up for my aunt, I did "Sign in without a Microsoft Account".  
  • On first loading, there is a little tutorial, which is helpful for any new user to Windows 8.  
  • There is a lot of HP bloatware.  About half of the tiles on the windows 8 screen and all of the shortcuts on the desktop are to bloatware programs or links.  One particularly annoying program was the Norton Antivirus program, which kept popping open asking for me to sign up for something.  I eventually uninstalled the program.
Installing Office
  • I inserted the installation disk and then entered the product key when prompted.
  • After about 10 minutes of installation, I was told to restart the computer, which I did. 
  • After the restart, when I clicked on the Microsoft Office icon, the computer asked me if I wanted to install Office.  I thought I had already installed the program, so I'm not sure what's going on. 
  • I chose the option to activate my product.  When prompted, I entered the product code again.  I hope this isn't using more than 1 of my product key licenses, but I have no idea how to check.  
  • The Microsoft office set up program began running again and it took about 15 minutes again. 
  • It then prompted me to restart again. I did, and another status bar began again with the message "Completing Office Setup" and "Do not power off your computer".  It took a few minutes for the computer to shutdown and restart.
  • In total, it took me about an hour to install Microsoft Office.
Windows 8
  • There has been some criticism about Windows 8, so I won't rehash it or weigh in on whether it is better or worse than the past versions.  I encourage anyone who gets a Windows 8 computer to read through the tutorials in the tile "Navigating in Windows 8".  
  • One thing I learned from the Navigating in Windows 8 tutorial is that gestures with a laptop track pad are pretty cool.  Here are some that I would probably use.
    • Swipe from the right edge towards the middle to open an options menu, aka "Charms".  
    • Swipe from the left edge towards the middle to open the previously used app.
    • Slide up/down or left/right with two fingers to scroll the window in any direction.
  • Another thing I learned is that you can just press the power button on your computer and Windows should shut down properly.  So you don't have to go to click on any "Shut Down" button anymore.  This may be odd for a newcomer to Windows 8, but it is a very nice improvement.  
  • There is a lot more than could be said about Windows 8.  But it isn't specific to this laptop, so I'll just move on.
  • I tried a few times and the computer goes from completely off to ready to run in less than 10 seconds.  This might go down as you install more programs, but it's pretty good for now.
Conclusion
Overall, I am happy with this purchase and I think my Aunt will like it.  I imagine that her initial thought will be, "How do I use Windows 8", and she will immediately want to go to the "Desktop" view.

Nevertheless, if you are looking for a cheap laptop with a big screen, I think this is a pretty good option.

Thursday, December 27, 2012

Should every programmer have his/her own website?

I am a professional software developer.  I mostly work with C++ and JavaScript.  

I started this blog to practice writing, have some historical perspective on what I think about, and make some money with my AdSense account.  I am pretty sure that two of those three items are attainable.  But as I blog with blogger software, I think, should I be creating my own site that I build from scratch?  As a programmer, it just seems natural to make my own unique platform. 

I have decided against it because it would take time, and I'm always short on time. Also, other than the generic look, I think the blogger generated site looks OK.  There's definitely sites that look much worse.

I think I will end up building one if some of these conditions are met:
  • The experience of building and maintaining a web site seems like it would enrich my programming skills.
  • Blogger's platform impedes me from doing something I'd like to do.
  • I see some real value (from a monetary standpoint) in building one.

Thursday, December 13, 2012

Google App Engine - Hello World

This post is part of series about building something with the Google App Engine.
If you haven't done so yet, read an overview of these posts here.

In this post, I'm documenting the process of starting up my first application, as I follow the steps in the developer guide from Google.

1. Create a new Google Web Application project.

2. I named my project testproject, with a package name of com.refactoringproject.
3. After running the project, you should see a development window open in Eclipse.
4. If you click on that line, you should open the web app in a browser.
 5. Entering my name in gave me this.
This all worked very easily for me "right out of the box".

Thursday, December 6, 2012

Algorithms

I have been a professional software developer for a few years now, but I haven't had any formal training on the subject of algorithms.  So, I think it's about time for me to do some hard technical reading on the subject.

To that end, I am currently reading Introduction to Algorithms to learn about algorithms.  So far, I think the book is well written and pretty easy to read.  However, I think I will need to do some pen on paper or coding work to internalize the material and ensure that I get some long term value out of it.

I thought it would be pretty cool to write the code for various sorting algorithms, and then demo it in an Android app.  That must be a decent idea, as someone has already built an app that demonstrates sorting algorithms very nicely.

Please leave a comment if you'd like me to see some posts on algorithms or if you know of any other great resources to learn from.

Sunday, December 2, 2012

About this Blog

This blog is basically about me and what I'm working on.  Thus, there's a good chance that you don't find anything interesting here.  But, if you happen to like programming, basketball, and criticizing movies, I guess we have something in common.

Android Development

In this series of posts, I will show you how I built a simple Android App.  Specifically, I'll show you how to build different pieces of an Android App.  I assembled the components into an app that is the App Usage Monitor, which you can install from Google Play, but you can use the components in any way you like to make your own app.
Before I began building this app, I had never written a program in Java before, never built a mobile app, and never used Eclipse (the primary tool I now use to build apps).  Nevertheless, I was able to publish an app that has actually been installed by a few people.  I encourage you to give app building a try and to learn from the notes I have listed below.
Note, like most development projects, I'm still updating and improving the app.  Similarly, I will be editing the posts to make each more informative and easier to understand.

Here are some other posts about Android development.
Please feel free to leave a comment if you find anything unclear or would like me to cover any other material.

    Refactoring my apartment

    In the beginning
    I didn't have any furniture.  We (my wife and I) had a blank, one-bedroom apartment in New York City.  For the living room, we thought, let's get the essentials and fill out things as we needed.  This consisted of the following items:

    television
    television stand with storage
    couch
    dining table
    and some bookcases.

    Multi-purpose sucks
    One item we did not invest in was a desk.  I thought to myself, if I got a desk, then it would encourage working from home.  This was something I was already doing, and I didn't want to do more of.  So, whenever I had to do work at home, I worked with my laptop from my couch or dining table.

    However, things have changed, and I want a desk now.  Working from a couch is ergonomically crappy.  Working from a dining table creates a lot of clutter.  Finally, while I still don't want to take my work home with me, I do want to work on this blog and work on my Android apps.  So, I'm in the market for a compact, functional, clean, good-looking desk.

    The search is on
    I am looking for a desk that is less than 38 inches wide.  I plan to put a big monitor on the desk.  I also want to plug in a laptop into the monitor, so that I can work on a nice big screen.

    One candidate is onelessdesk from heckler design. It is the perfect width, but in its ambition to be as sleek as possible, it looks like using the desk to do some other tasks, like writing with pen and paper, is difficult. 

    Some other candidates that are all a bit too wide, are listed below.
    http://myturnstone.com/products/bivi-table-for-one-with-back-pocket/
    http://store.hermanmiller.com/Products/Airia-Desk
    http://www.bluelounge.com/products/studiodesk/

    I have also been considering re-purposing one of my bookcases into a desk area, but that might be more multi-purposing that I'm looking to get away from.  

    Lessons learned
    I am not good at picking furniture.  If you know what you want, in particular the name of the piece of furniture, it's pretty easy to find anything.  If you only have an idea of what you want, then searching for furniture is hard. 

    Wednesday, November 28, 2012

    Stealing Android Apps

    Lifehacker is promoting an app that allows users to remove ads from their apps.  In my book, it sure feels like stealing.

    A few years ago a similar situation played out on our desktops.  Villainous spammers made internet browsing a clicking war as they used pop-up windows to shove their ads in our faces.  In response, browsers mercifully designed pop-up blockers that has all but stopped the madness of popup ads. 

    So, what is different about the situation?  I don't think there is anything different.  The only difference for me is that I'm the guy being blocked this time. I guess it's one of those, sucks to be me situations.

    So, what can be done?  Are we in a hopeless predicament?

    I know that Android Apps can include an end user license agreement (EULA).  Making users agree to a legal document makes me feel a bit dirty.  I want to make my users feel good when they use my product.  I can't imagine that this would alleviate the situation either.  

    Maybe the solution is just to educate our clients.  Here's a letter I could send: 

    Dear Android User,
    I'm glad you downloaded and installed my app. I genuinely hope you enjoy using it, and I hope it makes your life easier and happier.  But you should know something.  As much as I like building applications, writing code is hard and time consuming.  It's difficult to put together an Android app that works well on tiny phones running Honeycomb as well as a tablet running Jellybean.  Now, don't get me wrong, I'm happy to work through the bugs and create something awesome for you.  With that said, can you please allow my small pop-up to be shown in the app you downloaded from me.  Better yet, if you see something of interest, please feel free to click on that ad.  It might be a little annoying to you, but each of those clicks and views mean a lot to me.  And if you block those ads, well, it stops my income flow.  That means, no money to pay for power, no power for computer to run, and no more development of basically free apps for you.  So let's work together on this one. 
    Sincerely,
    A working for pennies - android app developer. 

    PS. If you really *hate* ads, feel free to email me or leave a comment telling me how much you'd like to pay for an-ad free version. 

    I'm not sure if that would work either.  I really think Google should step up to the plate and help us small app developers out.  Either, ad blocking apps should be removed from the play store or they should help us block the blockers!

    So, what do you think? Is it stealing? Is there a better existence we could all mutually agree to?

    Monday, November 26, 2012

    Another Android Chart

    This post is part of series about building a simple Android App.
    If you haven't done so yet, read an overview of these posts here.

    Never design what you can steal - Jeff Atwood.

    In the dual pursuit of building a pretty Android app and increasing my Android development skills, I created my own "view" which displayed a custom drawn pie chart.  Overall, it was a great success.  But after going through the process of designing a custom view (for a rather standard shape) once, I thought it would be good to 'steal' something that works right out of the box.  Or in other words, "good programmers code, great re-use" - not sure where that's from.

    There's an app, I mean a library, for that
    I thought it would be nice to add a line chart to my Android app.  After some research, I ended up working with charting library called achartengine a try.  Here are my notes on what transpired.

    AchartEngine tutorial with eclipse
    1. Set up the library.
    - Download it.
    - Unzip the file and find the file achartenginedemo/lib/achartengine-1.0.0.jar .
    - Copy that file into your <your_project_name>/libs
    - Open your workspace/project in eclipse.
    - If you don't see the file under the libs directory, right click on the folder and choose refresh.
    - Right click on the achartengine jar file, go to 'Build Path', go to 'Add to Build Path'. You should see the achartengine jar file under the Referenced Libraries section now.

    2. Create a class that will create the chart intent.
    Here's my code for it.
    public class ALineChart 
    {
        public Intent getIntent( Context context )
        {
            int[] x = { 1 , 2, 3, 7};
            int[] y = { 2, 4, 16, 64};
      
            TimeSeries series = new TimeSeries("Line 1");
            for ( int i = 0; i < x.length; i++ )
            {
                series.add( x[i], y[i] );
            }
      
            XYMultipleSeriesDataset dataset = 
                new XYMultipleSeriesDataset();
            dataset.addSeries(series);
      
            XYSeriesRenderer renderer = new XYSeriesRenderer();
            renderer.setPointStyle( PointStyle.CIRCLE );
            renderer.setFillPoints( true );
            
            XYMultipleSeriesRenderer mrenderer = new 
                XYMultipleSeriesRenderer();
            mrenderer.addSeriesRenderer(renderer);
            
            Intent intent = ChartFactory.getLineChartIntent( 
                context, dataset,mrenderer, "My first line" );
            return intent;
        }
    }

    3.  Create the object to make the chart intent.
    I added this from a fragment, but it could be called from an activity.
    public void some_event_handler()
    {
        ALineChart aChart = new ALineChart();
        Intent aChartIntent = aChart.getIntent( 
            getActivity().getApplicationContext() );    
        startActivity( aChartIntent );
    }
    That is just a simple example with some toy data.  I may update later if I find some interesting gotcha's or figure out how to make this all work better.

    Update: After some struggling, I found a clip on Youtube that really explained this process much better than I could.  If the link doesn't work, just search for achartengine.  I subsequently updated my tutorial to fall in line with what I saw on youtube

    I got a custom domain name

    So, after I bought my custom domain name, I was able to retire my blogspot address.  I'm still not sure if the expense of paying for a custom domain name was worth it. Although the cost is pretty small, so I think there isn't much to lose.

    On my home computer, I tried searching for 'refactoring project' and this site was the fifth item listed.  Of course, the phrase 'refactoring project' is not exactly a well known catchphrase, so this might be an honor that no one else is really shooting for.  Nevertheless, it's encouraging to know that my domain name is unique enough that you can actually find it without being lost in a forest of other similarly named sites.

    However, I realized that searching on Google is not a deterministic event.  Google search results are different depending on who is searching.  So, when I reported above that my blog was the 5th result when searching for 'refactoring project', that was true.  However, when I searched again on another public computer, my site was not even on the first page (or second or third ... ).  So it seems that I have a lot to work towards. 

    Sunday, November 25, 2012

    Ping Pong Playa

    I was browsing through Netflix last night, and I came across Ping Pong Playain the Feel Good section and decided to give it a try.

    The premise of the film is about an immature Chinese American, who is wasting away his life playing video games, but finally does good when he trains to win a ping pong tournament for his family.

    It is similar to a movie like Napoleon Dynamite, because its protagonist is incredibly awkward.  It is similar to any sports movie as it has an initial defeat, a training video montage and a final battle.

    I think it does a good job of showing the immigrant family experience.  The parents of the protaganist alternate between English and Chinese in a way that felt very authentic to me.

    There is definitely a racial component to this movie, but there's not much to comment on.  It is just one of the drivers of the movie. Much like Chris Farley's weight was used for comedic purposes, so were the racial factors in the movie.

    Should you watch this movie?  Maybe, if you are looking to kill some time and don't want to think.

    Saturday, November 24, 2012

    My Blog List

    Blogger has a widget called 'Blog List' which is a list of blogs that you endorse.  I like this idea in priciple.  If you like this blog, maybe you would like to read what I like to read.  So, there's a list.

    But I wanted to also note why I like a certain blog so that you'd have some reference as to why I think it's good and how it influences me.  So this post, which I will add to over time is my annotated blog list.

    Scripting News by Dave Winer.
    This is the model I use for my blog.  Dave covers a wide range of topics from the techie tools he likes, the software he hates and loves, politics, basketball, movies and biking in New York City (to name a few).  I think most people recommend blogging about a single topic, but he doesn't follow that rule - and neither does my blog. 

    Coding Horror by Jeff Atwood.
    This is a blog from one of the founders of Stack Overflow.  In his words, this blog is about  "programming and human factors".  I find his posts to be well researched, easy to read and humorous.  Moreover, maybe it's just me, but I always find his posts to be challenging.  He challenges the reader to think harder and do better.  There was a series of posts a while ago about building a poker bot, and he said something to the effect that any decent programmer could build ones of these.  Is that true? I'm not sure, but I definitely felt challenged to think about it and see if I could do it or not. 

    Blog Maverick by Marc Cuban.
    Marc Cuban is very rich and owns the Dallas Mavericks basketball team.  He's an entrepreneur who writes mostly about business, technology, and politics. His posts typically argue some point, with a decent amount of depth: read - some of his posts can be pretty long.  However, he doesn't post very often, which balances things out.  I always find his posts to be thoughtful, and he's interested in alot of the same subjects I am peripherally interested in.

    LifeHacker.
    In contrast to most of my other blogs, lifehacker is more of a site with a feed that I subscribe to.  This site gives tips on how to be more productive in life.  There are tons of posts that I just skip over but there are often a few times a week where I will read through the post and learn something new.  For example, lifehacker taught me about the world of Do It Yourself robots like the arduino, and I started building one which might be the subject of a blog post later on.

    Passive Income by Pat.
    This blog provides articles on internet businesses.  He details with incredible transparency how much he makes, what works, and what doesn't.  This blog will inspire you and make you feel like a free-lance internet based job is actually possible.

    More to come ...

    Friday, November 23, 2012

    Knicks lose to the Rockets

    Tonight, the New York Knicks were blown out by the Houston Rockets.

    We can chalk up the loss to the Knicks being on the end of a tiring road trip, or Chandler Parsons having a well-above average performance, or we could overreact and say that the Knicks are a doomed team going nowhere.  Maybe it is a combination of the three.

    A microcosm of the Knicks unraveling came in the third quarter.  After Carmelo Anthony missed an ill-advised one-on-one shot, he began complaining to the ref that he was fouled.  Unfortunately, the ref was standing on the sideline, causing Carmelo to turn away from the basket, while a Rocket ran right by his back and had a free dunk.


    Soon after, Tyson Chandler got tangled up with Omar Asik, and Chandler threw an elbow at Asik, eliciting a flagrant foul.  At this point in the game, Chandler was getting out-rebounded, out-played, out-hustled, out-manned, out-witted ... (you get the point) ... by Omar Asik.  So much for veteran leadership. 

    I guess these are just moments of frustration, and we'll see how the rest of the season plays out.  But the one person I kept my eye on was Coach Mike Woodson.  Would he yell at his guys? Was he also piping mad and berating the refs?


    As far as I could tell, he had the same emotionless face he typically has for the better part of any game.  Maybe he doesn't want to yell at his guys in front of the media and he's gonna rip into the guys later.  Maybe this is a player's league, and he doesn't want to get the boot like the previous Mike, coach Mike D'antoni.  Maybe he gave on the night.

    Maybe the solution is to end the road trip, have a day off, and play against the lowly Pistons.

    Affiliate Ads in this blog

    Adding ads
    In November of 2012, I began adding Google Affiliate ads in some blog entries.  However, I have since moved to using the amazon associates program for affiliate ads. 

    I never felt like I understood exactly how Google's affiliate program worked.  For example, Google Affiliate Ads is supposed to work in this fashion: "When a blog visitor clicks your affiliate ad and makes a purchase, you may earn a commission for referring that visitor."  Why does the "may earn a commission" clause mean?  What instances would a commission be denied? 

    I also found that the universe of possible products that I would like to endorse was not covered by Google's affiliate ads.  If I did find a product I would like to endorse, it was often selling at a higher price.  Using Amazon solves these issues.  I can endorse almost anything, and the price is always competitive. 

    Of course, the proof is always in the sales numbers.  I will make (very happy) updates if there is ever any progress on that front.

    Contrived emotions

    I'm watching American Idol with my wife.  More accurately, my wife is watching American Idol and preventing me from watching basketball.  For my wife's sake and ultimately mine as well, I'll voice my complaints with the show in this blog post, instead of to her. 

    Today is the Thanksgiving episode, so each singer or group is dedicating their performance to someone they are thankful towards.  And boy oh boy, are they laying it on thick.  We've had dedications to a single mom, a dad who gave up his dream of music, a long-lost sister, youth mentors, and the big cheese himself - GOD. 

    I know that giving these singers a back story is important for viewers to feel connected, but I wish they would just focus on the product of the show - singing performances, instead of forcing these contrived stories onto us.
    But, if others like the show the way it is, as evidenced by the millions of viewers (including my significant other), I guess I'm better off complaining in relative silence on this blog.

    My cleaning style = my coding style

    The family came over for thanksgiving yesterday, which meant I had to clean.
    As I was cleaning, I found myself using my own 80% rule.  The rule is to do about eighty percent of the job and then move on.  So, if you're dusting, do most surfaces, but don't worry about the little crevices behind the lamp in the farthest corner of your bedroom or reaching behind the the television.  After you do eighty percent of a job, move onto the next one, be it dishes or sweeping or whatever.

    If you finish all of the jobs, or 80 percent of your job list, you can go back through your list and do 80% of what's left, and so on and so on ... While things don't end up perfectly, after every passing iteration, the job percent completed goes from 80 to 96 to 99.2 to 99.84 ...

    This is basically the same strategy I use when I'm coding.  Although you always want to cover the corner cases so that you're program or api works well and feels professionally polished, it's often a better practice to get 80 percent of the job done.  If your clients notice the missing 20 percent, or maybe the word is "when", then you can go back to the drawing board then.

    Luckily, there's another rule of nature, the 80/20 rule, which says that 80 percent of any effect is caused by 20 percent of any cause.  So, if I clean up 20 percent of what feels messy, then that'll end up doing 80 percent of the job.  Combine this with my rule and I really don't have to do any work at all!



    Disclaimer: I'm sure there are cases where this doesn't apply, but I'll just throw in one more cliche and say that it's just a rule of thumb.

    Tuesday, November 20, 2012

    Daily tools - podcast manager

    Lifehacker has a series where they interview a productive person and ask them how they work, live and play.  These people are always very accomplished and their ways of doing work seem very polished.  I wonder how many iterations these people went through before finding the tools and methods that worked for them...

    In any case I thought I'd note one of my most used tools and how I use it, the BeyodPod podcast player. I use the free version of this App which is installed on my Android smartphone.  I am subscribed to a few podcasts and I've tried countless others.  For now, I am listening to a podcast on general sports discussion, NBA basketball, coding, and Korean language lessons. I listen whenever I am walking - which is quite a lot for me in New York City. I walk my dog a couple of times a day and I walk to and from work. I basically listen to a podcast whenever I have some down time.  This way, even those small moments that are othewise wastes of time, like waiting in line, can be somewhat productive and/or entertaining.

    Beyondpod is definitely the best podcast player I could find for android.  I am leaning towards buying the paid version - which gives me a few nice features like automatic updating.  

    With that said, I remember iTunes being a better podcast manager when I had an iPhone. It seemed easier to get update for my subscriptions.  Also I was able to listen to podcasts at 1.5x speed - a real time saver, without having to buy and install a separate app.

    Monday, November 19, 2012

    Knicks had a moral victory last night

    The other night, the Memphis grizzlies scored more points than the our new York Knicks.  Thus, the Knicks were defeated.  However, here were the moral victories:

    Rasheed Wallace can abuse people in the post. 

    Amare Stademire was missed, in principle.  The Knicks were killed on the boards by our old teammate Zach Randolph. Could Amare have helped? Not sure. But at least we have a desperate need that he could fill in theory.
     
    JR Smith had a bad game. He was in the middle of a minor scuffle and his shot was not falling.  Everything was a struggle.  Yet, he didn't melt down.  Maybe he is more mature this year.

    Jason Kidd is impressive.  He's a great spot up shooter, has quick hands and makes good decisions. 

    Carmelo Anthony also had a rough night with fouls, but he stayed very aggressive.

    Progress Report

    So here are some highlights from the last year with regard to my Android development experience.

    How I ended up with an Android Phone.
    About 11 months ago, the day after Christmas 2011, I got my first smart phone, the iPhone.  In April of 2012, my mom needed a smart phone, so I gave her my iPhone and borrowed an old Motaola Droid from my wife.  A few weeks later, my wife lost her phone (actually it was stolen), so I gave her the droid back and I ended up buying a new Samsung Galaxy Nexus for myself. Except for the fact that the price of the phone dropped by about $100 after a month of ownership, I have been very satisfied with this phone.

    3 months to write an app.
    In July of 2012, I decided that I'd try to write my own Android App.  Three short months later, I published my first app to Google Play.  The App Usage Monitor app that I published is incredibly simple, but I think a turnaround time from thinking about an app to publishing one is pretty good, given that I had never written Java before!

    Not - In the money.
    It's now late November, and there has now been 20 user installs, with 10 active user devices.  I haven't solicited any of my friends or family to use my app, so these are all unbiased downloads and installs.  Monetarily, there hasn't been much of a windfall.  I have earned $1.98 in revenue from AdMob.  In comparison, I've earned 47 cents from Adsense revenue linked from this blog, so I haven't really realized any financial benefit for my effort in this app or in this blog.

    Was it worth it?
    I judge this experience as a complete success.  I developed an app that I like to use.  I learned about a new development and deployment process - eclipse, git, Google Play store.  I got to write some Java code.  I had a lot to blog about.

    Basically, I was creative and produced something.  This, for me, is one of the most satisfying ways to spend your time.  While consuming content (watching television, reading blogs, or listening to podcasts) is fun and enjoyable, it is much more fulfilling to struggle and create something, even if your audience is incredibly small.

    The future
    I think the app that I developed has all of the central components that I envisioned for it.  Nevertheless, I have a few updates that I'd like to make to my app.  These include adding another view that will make it easy to visualize data, making my app more tablet friendly, and providing better ways for a user to save their data.  I think these are minor updates that shouldn't take me too long.  After these features are implemented, I think I will begin working on a separate app.  I plan to work on a very different type of app so that I can learn how other apps function. 

    Finally, in a somewhat related note, I think I will get a Nexus 7 for Christmas.  It will make development on tablets easier and I hope it will open my eyes on new  tablet friendly apps that I can develop.  Also, it's just cool and I want one.

    Wednesday, November 14, 2012

    Android sqlite database questions

    Android apps can easily use sqlite databases for data storage. Here are a few questions and answers about sqlite databases on android accessed via the SQLiteOpenHelper class.

    1. What happens to the database associated with a given app, when the app is uninstalled?
    If you create the table using internal storage, the database is wiped out. 
    If you created the table on external storage, the data is preserved.  
    - Another way to clear out a database is to go to Settings --> Apps --> Go to an App, and then click "Clear data".

    2. How do you make changes to a database, like adding columns or an index?
    In your class you should declare a variable for the version number like:
    private static final int DATABASE_VERSION = 1;
    When you want to make an update, change the database version to 2.
    You will also need to override the onUpgrade function like this:
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) 
    {
    // Depending on whether an old version existed
    // and what version you are going to,
    // you can customize what tables should be
    // added, deleted or modified.
    if ( oldVersion == 1 && newVersion == 2 )
    {
    // Do something.
    }

    // Call your onCreate function if you want ...
    onCreate(db);
    }
    While this may seem obvious, I don't think you can 'downgrade' your database version number. At least for me this caused my app to crash.

    Also, if you call another function from onUpgrade or onCreate, make sure to pass the 'SQLiteDatabase db' argument to that function as well.  Creating another db reference will cause errors.

    More questions to come if I ever learn anything else ...

    Saturday, November 3, 2012

    Android App Updates

    A couple of thoughts/questions about best practices for rolling out android app changes.

    1. Is there a way to publish a new version of an app, but have it released or activated for only a limited set of users?  Or just for me at most?
    One way to test a new version is to circumvent the Google Play store.  You can distribute your apk to testers any way you like and then you can use an app like Airdroid to install new versions of your app.  This is especially useful if you want to test how upgrades rather than clean installs. 

    2. How often should I push out updates? 
    It'd be coolest for me to push out frequent incremental changes.  This is better for testing and backing out changes if needed.
    However, I don't want to annoy my users with constant updates. 

    3. Do most android users set automatic updates to be on for their apps? How can I find out whether my users have turned this feature on?
    I'm open to any suggestions. I wonder if Google collects such stats ...

    more questions to come ...

    Thursday, November 1, 2012

    Google reader

    I am a big fan of Google Reader.  With that said, I've been using it for about a year now, and that's just enough time for me to begin complaining about it.  

    Duplicates.
    Some feeds suffer from duplicate posts.  It would be nice if Google Reader could skip articles where the title and text are exactly the same.  I imagine that these are appearing because the meta-data is different or the feed provider made a duplicate post, but as a reader, this is pollution.

    Articles, videos, podcasts ...
    I wish there was a way to filter out non-text based articles that are basically links to a video or audio link.  I suppose some people want to see these, but I generally don't want to.  I imagine this is difficult to do, because just about any article could have links to external links.  Maybe there should be a filter that excludes any 'article' that has less than 200 words or something like that?

    Pointers ...
    Similar to the gripe above, some feeds contain only a title and a snippet of the article.  I wish Google Reader could capture the whole article to save me from having to click into the article and then requiring multiple clicks to get out of the article.

    Monday, October 29, 2012

    Duplicate Apps


    Apple or Android!  I was at a friendly birthday dinner the other day, and this topic was brought up, and things got ugly.  I've never been much of a "fan" in any respect of my life.  I love sports, but I don't have a favorite team.  I love technology, but I'd switch between one brand to the next without any sense of betrayal or loyalty lost. 


    With that said, I am an Android user (both phone and tablet) and even more so, an Android developer.  Needless to say, I'm biased.
     
    One difference between Apple and Android is the app ecosystem.  In the Apple world, before an app can be published for distribution, it must pass a review process by Apple.  In the Android world, no such barrier exists.  In comparisons between the two phone types, this is often mentioned as a plus for Apple.

    Since Apple reviews apps before publication, the apps in their store will tend to be of higher quality.  Inferior apps, that drain system resources for example or simply duplicate the same features as another app, will be rejected from the Apple app store.  In contrast, when I searched for 'notepad' in the Google Play store, I got 4493 possible notepad apps. From a user's perspective, this may make the Apple seem experience better.

    This feeling is pretty different from the developer's point of view (at least my point of view).  In the Android world, we are free to publish whatever we make.  There isn't a seemingly arbitrary judge who deems whether our app is good or not.  Furthermore, we are free to use free tools, which makes the bar to enter even easier to cross.

    So, it seems that Apple will have a nice curated selection of apps, and Android will have a mish-mash of good apps hidden by a mountain of poor apps.  Thankfully, the Android app world has a pretty good way to help users find the best apps.  User-reviews.  These reviews make it pretty simple to identify the cream of the crop apps and skip the poor ones.

    I see the Android app world as being similar to the internet.  Anyone can create any kind of website or app.  The best sites and apps will eventually be found and used, while the poor ones will not be.

    Which ecosystem do you want to live in?  Do you want to be in a world with curated content (maybe like the New York Times choosing which 1000 articles are sent out each day)?  Are do you want to be in world like the internet, where there is good content, almost completely hidden by mountains of bad stuff.

    Harden and me to the Rockets

    Because of Yao Ming, I used to follow the Houston Rockets pretty closely.  But my interest in the team and their viability as a contender, has waned since Yao's retirement.

    The pick-up of Jeremy Lin earlier in the year did little to capture my attention.  The story of the Rockets seemed to be tragically uninteresting.  Yes, Lin would be a young talent surrounded by other young talent.  But the team felt a bit, incomplete.  This team was almost destined to lose in the first round of the playoffs, if lucky, in a completely forgettable way. 

    But now that James Harden has been traded to the Rockets, everything has changed.  Harden and Lin are incredibly interesting.  Young, trendy, smart and they can ball.  I have no evidence to suggest that they will play well together, but I have a feeling that they will mesh.  Both are pretty good spot up shooters, and both are good at driving and kicking out to spot up shooters. 

    As a sign of my new found enthusiasm, I have just re-subscribed again to red94.net, a pretty great Houston Rockets blog that I used to read regularly.  I suggest you do the same.






    Houston Rockets Jeremy Lin Player Tee - Men (Google Affiliate Ad)

    Sunday, October 28, 2012

    Lather, rinse and repeat

    Here are the steps I take when I want to update my Android app.

    - Uninstall the app on my phone.
    - Create a new git branch.
    - Make updates.
    - Test on emulators.
    - Commit changes to git branch.
    - Use Eclipse to publish a new signed version.
    - Use Airdroid to upload the new apk and install it onto my phone.
    - After testing for a day, I publish the change to the Google Play Store.
    - Push changes to github.

    Anyone have a similar workflow, or could suggest improvements to my workflow?

    Saturday, October 27, 2012

    Windows

    Recently, I've been helping my wife shop for a new ultrabook that would run Windows 7 or perhaps Windows 8.  At the same time, in the upcoming weeks, my work computer will be upgraded from Windows XP to Windows 7.  With all this upgrading, I have to say I'm pretty excited about the newest Windows products.  Even though we probably won't buy the new Surface tablet,
    Surface - see http://www.microsoft.com/Surface/en-US/surface-with-windows-rt/help-me-choose

    the possibility of Windows producing something interesting again, is well, exciting.

    Tuesday, October 9, 2012

    To the cloud

    I'm thinking about building another Android App. 

    For this app, I'd like to do some cloud-based things.
    1. Sync my user's data to the cloud.
    2. Use cloud computing to do some powerful user-specific analysis.

    The two most robust options seem to be either Amazon Web Services or Google's Cloud solution.  Here are some points for why Google's App Engine looks good for me.

    Cost - "With App Engine, you only pay for what you use. There are no set-up costs and no recurring fees... App Engine costs nothing to get started. All applications can use up to 1 GB of storage and enough CPU and bandwidth to support an efficient app serving around 5 million page views a month, absolutely free."

    Handling Users - "APIs for authenticating users and sending email using Google Accounts"

    Data storage - Google Cloud SQL provides a relational SQL database service for your App Engine application

    Development experience - There is support for development with Eclipse and Java, making it a natural extension to work with my Android Apps.

    I'm working through this installation/tutorial now.

    App Usage Monitor

    What is the App Usage Monitor?

    It's an Android app that I have building since mid 2012. This app measures how much time you spend using a given Android app. More specifically, it measures how long you have a given app opened in the foreground. 

    What else is the App Usage Monitor?

    This is the first Android App that I have developed, and it started as a way for me to learn about developing android apps.  I thought it was pretty informative, so I decided to publish it for others to use.  I have documented my experience building this app in this blog.

    Can I export the data?

    I am working on it. The latest version of the app syncs data to a cloud backend. Once this cloud backend is working correctly, I hope to provide a lot of cool functionality, one of which is easy exporting of data.

    Feedback

    Please feel free to leave a comment or email me directly, email.dhan@gmail.com. If you are a happy user, please spread the word by reviewing the app on the Google Play Store.

    Saturday, October 6, 2012

    Saving output somewhere else

    I wanted to allow users to save text data that is on their phone to third-party applications like to email or on Google Drive.  The best way to do this seems to be using ACTION_SEND intents as described here.

    Code like this, will put the text you want to send into the body of an email message or will create a new document on Google Drive.
    public void send_data() 
    {
    // Create an intent to send data out
    Intent send_intent = new Intent(android.content.Intent.ACTION_SEND);
    send_intent.setType("text/plain");


    String data_to_send += "Sending this data string";
    send_intent.putExtra(Intent.EXTRA_TEXT, data_to_send);

    startActivity(send_intent);
    }
    Or, you can put the text data into an attachment with something like this.
    public void send_data() 
    {
    String FILENAME = "sample.txt";
    FileOutputStream fos;
    try
    {
    // Set the file as world readable so other apps can read it.
    fos = openFileOutput(FILENAME, Context.MODE_WORLD_READABLE);

    // Update the file and close it.
    String data_to_send += "Sending this data string";
    fos.write(line_to_send.getBytes());
    fos.close();
    } catch (IOException e ){}

    // Create an intent to send data out
    String full_path_file = getFilesDir()+"/"+FILENAME;
    Intent send_intent = new Intent(android.content.Intent.ACTION_SEND);
    send_intent.setType("text/plain");
    send_intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+full_path_file));
    startActivity(send_intent);
    }
    This all works well, but when I try to open the document in google drive, I find that it isn't a native Google drive document, and the only thing I can do is view it.

    I will update later again if I can find a way to improve this.

    Thursday, October 4, 2012

    Git, Eclipse, Can't we all just get along?

    I've been using vim and cvs for all of my programming life. I'm still using them.  But I thought it was time to step into the 21st century. So here I am, building android apps with the modern Eclipse IDE and the trendy git versioning system. 

    Thus far, I have been impressed.  Git is powerful and Eclipse is one smart tool; autocomplete alone feels like magic.  But, it hasn't all been easy. 

    Here are the two scares I had:

    1. In eclipse, I created a branch.  I made my edits, and then I asked eclipse to merge the branch back into the master. I've done this before, but this time Eclipse had issues.  I don't remember the error message, but there were errors everywhere.  So, I asked Eclipse to switch back to the branch I was working on. Oops. Eclipse said No to that too.  Ok.  I'll restart Eclipse.  Crap.  Eclipse opens and the project is empty.  I ask to switch branches, nothing. Eclipse says that there were merge errors and I'm not allowed to switch branches.

    I went back to the terminal. I opened the folder where my git repository is, and there was nothing there. After a moment of stupid panic, I ran 'ls -a' to see the hidden files.  Aha, there was '.git'. So I ran 'git branch', saw my branches, and checked out my last good branch.  I merged files using the command line and all was well again.

    I'm not sure what I did. I don't know why eclipse decided that the best way to do a merge was to hide all my files. It was probably something that I did.  Oh well. Ok, I'll just merge from the command line and not within Eclipse anymore.

    2.  All has been going well. I code and debug in Eclipse.  I create and merge branches in the terminal.  But one day, I open the project, and I have lots of errors. 100s of errors.  After going crazy for a bit, trying to build, clean, changing build paths and so forth ... I was ready to give up. Screw these shiny magical tools.  I never know what the heck is going on.  Well, I realized after a bit that Eclipse had wrecked my imports.  I deleted the ones that were there and re-added the ones I needed manually.  Who knew that Eclipse or Git would decide to change my imports?  I have no idea what happened.  Oh well.

    I guess, what doesn't kill you ... gives you something to blog about.

    Sunday, September 30, 2012

    Adding ads to my app

    I signed up for admob, and then I followed the steps in this tutorial
    I had some issues with the adview libraries not being found, so I moved the insert out of the xml and into the code as detailed in this stackoverflow post.


    I don't have much more to add on this subject for now ...

    Saturday, September 29, 2012

    Releasing version 1.0 of my App

    So after writing the code for my app, testing on my phone, setting the bar for the number of features I want to include to its bare minimum, I'd love to publish my app in the Google Play Marketplace.

    Here's my running notes on what I'm doing.
    I'm following the instructions in Google's guide to App Publishing.  While it would be best to follow every step, I'll probably just do some of the recommended steps just to get this out there, and then go back and improve on some of my mistakes later.

    Register for a publisher account.
    I give google my name, my email, 25 dollars, and they give me the ability to post applications.  Sounds fair. The only snag I ran into was that my name was already taken. I added a middle initial, and then I was accepted.

    Check out the developer console.
    As a new publisher, with no apps, there isn't really much to see in the console.  This will be the place where you upload your app.

    Completing the publishing checklist.
    Well, there are 16 steps on this checklist, which is a bit much for me. 
    The first one of significance to me is to 'build and upload the release-ready APK'.

    Update your manifest xml.
    I updated the package_name, because it was something from something like MyHelloWorldApp to com.dhgg.appname...  This hierarchy should ensure that your app package name is unique.
    I also updated the project name in eclipse, so that the apk name better reflected this app's name.  
    I updated the minsdkversion and targetsdkversion to 10 (Android version Gingerbread), which covers a decent amount of the Android population.
    I checked for debugging tags like android:debuggable, but I had already removed those.

    Building the apk with eclipse.
    I used eclipse to set up the keys and build the apk file.  I wasn't too sure about all of the terms, but the key things I had to input were:
    a file name for the keystore, which holds key info,
    an alias, which is the thing I'm prompted for
    and passwords which I set to be the same for the keystore and alias.
    At this point, I have a release ready apk file.

    Uploading to Google Play
    In addition to the apk app file, you also need 2 screen shots and a high resolution 512x512 high resolution icon.  
    I also added a title and a description of the app. I expect to update all of these in the future.  I didn't really try too hard to make any of these images or the description especially nice, because I just wanted to publish it successfully.

    After agreeing to keep my app as a free product and some other quick fixes, I published the app.

    Here is my android app: the App Usage Monitor.

    Thursday, September 6, 2012

    2012 Presidential Race

    The 2012 presidential race is well underway.  Here are my notes on what's going on:

    The Bain way.  Mitt Romney, the Republican candidate, is one of the founders of Bain Capital.  Oddly, this prosperous company and Romney's financial success have been used by the Democratic Party as political liabilities.  The Democrats have been portraying Romney as a money-hungry selfish capitalistic animal. This seems very odd to me.  I think Mitt should just say,
        "I made a lot of money, all legally, because that was my job, and I have always excelled at my job.  The next job I would like to do, is to become President.  In that role, I'd work, just as I have before, to make the United States of America as prosperous as possible ..."
        Maybe I'm biased, because I read about Bain Capital before I heard about Mitt Romney, but I would have been excited to work there, if given the opportunity.  Thus, saying that something is done the "Bain way" as a derogatory thing feels very odd to me.

    Wednesday, September 5, 2012

    Charlottesville, Virginia

    The Pigeon Hole.
    We went here for lunch, and we loved it.  The restaurant looks like it was once a house.  It has outdoor seating on the lawn and the porch and indoor seating on the first floor.  It is located in the 'Corner' district, thus it is mostly filled with college students.
    The menu isn't extensive, but every dish we saw looked well made and individually prepared with care.  We tried the egg and cheese sandwich, hash browns, scrambled eggs, grits, pancakes, and huevos rancheros.
    The restaurant has a very young, hipster, fresh vibe, yet it still felt very wholesome.

    The Whiskey Jar.
    We went here for a good drink, and we found it.  They also had live music with indoor and outdoor seating. 
    This is in the downtown area at one end of the walking mall.
    If you find the music to be too loud or the bar too crowded, there are a bunch of other bars in the area.

    Blenheim Vineyards.
    If sitting in a college-town or in a lively bar isn't your thing, Charlottesville offers this winery (established by Dave Matthews).  This charming little winery is serene and beautiful.  The caretakers are kind and warm.  The food is natural and wholesome. The wine (I'm not an enthusiast) is unpretentious and delicious.

    Thursday, August 23, 2012

    Blogging

    I have made changes to this blog.

    Namely, I have created pages.  I tried tags for a while, but they never felt right for me.  Tags are meant to organize and help someone search through posts, but they always felt sort of flimsy and cheap to me, but I'm not sure why.

    A while back, I found myself writing quite a bit about Android development, so I decided to move that into its own page.  Today, I decided that travel should be its own section as well, so I moved it into its own page.  You can navigate to those sites using the buttons at the top of this page.  Tomorrow, if I find myself writing a lot about another topic, I'll repeat the process.

    I think one of the effects of making topic specific pages is that the ads presented by Google will be much more specific to the subject.  Also, I think the navigational bar at the top of the screen look more organized and polished.

    Background Processes

    For many apps, background processes are needed to accomplish some tasks.

    Here, I will setup a class that runs a background process.

    To set up the file in Eclipse, navigate to the package you want to add this to, and right click on src->"package_name", where package_name is something like com.example.project_name.  From there, select New->Class.  In the popup:
    I set the name of my class to "Service_handler".
    I set the superclass to "Service".
    I then added some methods, so that the basic framework looks like this:
    public class Service_handler extends Service 
    {
    public IBinder onBind(Intent intent)
    {
    return null;
    }

    public void onCreate()
    {
    System.out.println("onCreate");
    }

    public void onDestroy()
    {
    System.out.println("onDestroy");
    }

    public void onStart(Intent intent, int startid)
    {
    // Grab a "log_msg" from the caller
    String message = intent.getStringExtra("log_msg");
    System.out.println("onStart "+message);
    }
    }
    Also, add this to the xml manifest file, within the application tags.
    <service android:enabled="true" android:name=".Service_handler" >

    Now you start the service with code added to your main activity, like this:
    public void onCreate(Bundle savedInstanceState) 
    {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my_first);

    Intent myIntent = new Intent(getApplicationContext(),
    Service_handler.class);
    myIntent.putExtra("log_msg", "hello_from_activity");
    startService(myIntent);
    }
    If you used the code above you should see this text in the logCat output, "onStart hello_from_activity". 

    Driving out of NYC

    In New York City, public transportation, whether subway, bus, rail or taxi-cab, is superior to driving a car - in most situations.  In the remaining instances, like going to the suburbs for a friend's birthday and then picking up some groceries, having a car of your own is often better.

    Here are the options for getting back and forth to long island when you don't own a car.

    Public transportation (Taxicab, subway, LIRR)
    - Subway is $2.25 per ride.
    - Long island rail road  is about $8.25 per ride (more or less depending on distance).
    - Taxicab to and from train stations or to and from subway - $12.

    Rent a car from Hertz, Avis, Budget, Alamo, etc ...
    - No sign up fee.
    - Typically, you have to refill the gas.
    - On weekends, the rates are around $200/day.

    Zip car
    - You need to sign up and there's a fee.
    - There is an annual fee of $60 / year.
    - Gas is free.
    - Weekend rates of $85 / day.

    Hertz On Demand
    - You need to sign up in and get approved. I just applied, so I'm waiting on their response. (Update: it took 10 days for them to send me an email saying that I was approved and that they were sending me a vehicle entry device.  Then, another week went by before I got the device).
    - There is no sign up fee and no annual / monthly fee.
    - I think gas is included.
    - Price quotes are hard to find.  I've heard that they're trying to undercut Zip Car prices.  I will update after I become a member. (Update: For the upcoming weekend, I found rates for about $18 for 1 hour and about $140 for about 8 hours.).    

    Relay Rides
    - This is a car sharing, where you directly contact another car owner.
    - Free sign up and instant access.
    - Typically, you will have to refill the gas you use.
    - Rates decided on by the car owner.  I saw rates as long as $40 /day and as high as $200 / day.

    Sunday, August 19, 2012

    Atlantic City -- Noodle Bars

    I have been to two noodle bars in Atlantic City, one in 'Show boat' and one in 'Borgata'.

    In my experience, the Borgota looks cleaner, the food is less greasy and is the better one to go to.  In the Borgota, I always get the Pork Sa Chiu Noodle Soup, to which I add a few spoon fulls of hot sauce.  However, the wait for a table at the Borgata can be rather long and preferred guests can cut the line, which sucks, depending on your perspective.

    Rucola - in Brooklyn, NY

    Rucola restaurant, in Brooklyn, NYC, is intimate, trendy and cool.   Most importantly, the food is delicious and affordable.

    It is a cozy restaurant where most of the patrons are in groups of four or less.  Nonetheless, I can attest that the restaurant can accommodate large parties, as I came with a party of 14.  We had a pre-set meal that began with fresh toasted bread and an appetizer dish containing meats (some type of pepperoni and prosciutto) cheese (some hard and some soft), nuts and jam spreads.  Next, we had two types of salads, one mostly lettuce and the other containing an assortment of mixed vegetables.  For the main course, we had a sampling of roasted chicken, grilled fish, pasta in pesto sauce, another pasta, and other cooked vegetables.  The meal was finished with two desserts, which I didn't really eat, but the others seemed to enjoy.   They also have a quirky drink list of beers and cocktails.  

    Overall, this is a great place to eat.  It is a great place to go if you want to feel like a true Brooklyn-ite / Boerum Hill- ite.

    Saturday, August 11, 2012

    Bill Simmons - London Chronicles 6 - Dwight Howard - Mail bag

    The sports guy reacted to the Dwight Howard to the Lakers, Bynum to the Sixers, Andre Iguodala to the Nuggets and pu-pu platter of players to the Magic trade with a pseudo-mailbag article.

    Here's my analysis of his article.
    It begins with a blitzkrieg of amazing Olympic events that Simmons has recently experienced in London.  He basically lists off events and Olympic personalities with a series of sentences that all start the same way: "I spent the ...", "I knocked Wimbledon ...", "I caught a ...", "I watched the ...", "I devoured more ...", "I lived vicariously ...", and "I saw five ...".  The good thing about this technique is that readers can understand the article perfectly, even if they zone-out while reading any of these example sentences. 

    The article then says it will be a mail-bag article, and so we expect to see a series of questions from readers followed by replies from the sports guy.  However, the mail-bag is only two questions long and is basically used to introduce the recent Dwight Howard mega-trade.   As further proof that this is not a true mail bag article, Simmons does not end the article as he usually does - with a particularly outlandish question from a reader followed by the reply, "Yup, these are my readers".  

    The article is mostly a series of judgments on who is a "Winner" and "Loser" in the trade.  Simmons makes his judgement explicit by starting each section with a heading like "Winner: The Lakers" or "Loser: Orlando".   Starting each section with the same format has the same effect as starting each sentence in the the first paragraph in the same style: namely, readers can jump around the article and  read or skip what they like. 

    I always wondered how he digests a sporting event and publishes an article so quickly.  After a bit of analysis, I can see that Simmons uses defined sentence patterns and article sectioning to quickly introduce a range of topics or examples.  He often assumes that the user is aware of the event that he is writing about (a fair assumption) and thus wastes little effort in providing background and instead focuses on his reaction to the event.

    Syntax highlighting in blogger


    Here's how I post code snippets with syntax highlighting in blogger.

    1. Go to edit template
    Put these lines under the <head> tag:
    <link href='http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css' rel='stylesheet' type='text/css'/> <script src='http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js' type='text/javascript'/>

    2. Change the body tag.
    From <body ... >
    to   <body onload='prettyPrint()' ... >

    3. When you make a new post, edit html and put these tags around your code:
    <pre class="prettyprint">
    // your code goes here.
    </pre>

    Here's some sample prettified code:
    int main(int argc, char * argv[])
    {
    printf("Hello world. I'm using prettyprint.\n");
    }
    Note: If you change the template in blogger, the changes to the template will probably be lost, so you will have to repeat steps 1 and 2.

    If you want to post xml code, you will need to 'encode' the xml first.
    1. Enter the code with one of these tools.
    http://centricle.com/tools/html-entities/
    http://www.spacefem.com/tutorials/makecode.php
    This does some simple things like turning "<" into "lt", which stands for less than.

    2. Put the encoded code into the prettyprint tags mentioned above.

    Wednesday, August 8, 2012

    Hustle

    Since as far back as I can remember,  my role on sports teams has been the hustle guy. Often this is a euphamism for the least skilled player who needs to work extra hard or else he would provide no other value for the team. And for me, the euphamism is spot on.

    However, I don't see it as a negative stigma. I see it as me having some skill in one area, namely hustle.  Moreover, while I might have been naturally gifted with some amount of this talent, I practiced hustling so much that I definitely have become better at it. 

    Seeing hustle as a skill that I must practice and hone, led me into an altercation today. In my rec-league basketball game, our team was up by about 15 points with less than a minute and a half remaining.  By all estimates, this game was over from a win-loss perspective.  But for me, since the game was still technically going on, I was hustling hard on defense, and accidentally fouled the opposition. While he was taking his free throws, the referee made a comment to me about taking it easy and not to foul at that moment.  But this pissed me off. I can't stop hustling. If I did, I would get used to that, and my one skill would deteriorate.  I didn't have time to explain to the referee that I needed to hustle all of the time, so I ended up being mad, and writing this blog post instead.

    Tuesday, August 7, 2012

    Android Tracking Time - Part 3

    In a previous post, I extended the basic hello world app from the android development site.

    In short, I could keep track of how long my application was in one activity or another by saving the times when either onResume(), onPause(), or startActivity() was called.  By keeping track of these event milestones, I could calculate how long my main activity was in the the foreground or not.

    At this point, I think I have a fairly good understanding of the Android App life-cycle as an app is created, resumed, paused and closed.  At this point, I think it might be a good idea to learn how I can store data that will persist beyond this life-cycle.

    Monday, August 6, 2012

    Android + Eclipse + Egit

    So, after making some very small progress in my app development, it's become clear to me that I need 'version control'. 
    Version control is a way for developers to keep track of code changes, to merge changes with other team coders, and to make experimental changes without fear of messing up previous good work.  A primitive way that version control could be done is as follows:

    1 - Write code.
    2 - Copy all files into a folder called version0.
    3 - Make code changes.
    4 - Copy all files into another folder called version1/.
    5 - Repeat steps 3 and 4, but update the folder name as you go.

    This type of homemade system has flaws.  For example, you will end up wasting a lot of space as each folder has the complete set of files.  Thankfully, this old problem has been looked into and existing version control systems already exist.  CVS, SVN, GIT are a few that I have actually used.  Among these CVS is the oldest and GIT is the most modern.

    For Android development in eclipse, there is support for all of them.  After some internet research, I decided to go with GIT.  The process involves using eclipse to install the egit plugin. From there, I followed the wiki guide to create a repository to hold my code changes.  At the moment, I expect to use only the most basic superficial set of features that egit will give to me: committing changes into the repository under the main master branch, comparing my current version to old versions, and reverting to old versions from time to time.
    Now that this is all set up, I can develop under the sweet protection of version control.

    Update:
    I ended up doing a very simple branch and merge that I wanted to note here.
    Here is the workflow.

    1 - Create a new branch.
    2 - Code, test, save, commit the change to the new branch.
    3 - Switch back to master branch.
    4 - Merge the new branch into the master.

    There is something nice about working in a completely separate branch, knowing that you won't mess up your previous work, that is liberating and puts your mind at ease. I guess I'm a fan of branching.

    Android Tracking Time - Part 2

    Continuing from a previous post, I've now updated my app to track how long I've taken to return from one activity (started from my main activity).
    Here's what I did:
    Create variables to hold onto the times when messages are sent and returned.

    public class MyFirstActivity extends Activity {
    public static long time_msg_sent = 0;
    public static long time_msg_returned = 0;
    public static long time_diff = 0;
    // rest of code like onCreate(), etc ...
    }
    Just before the second activity is started, set one variable with the current time.

    public void sendMessage(View view) {
    // do code to prepare Intent ...

    time_msg_sent = System.currentTimeMillis();
    startActivity(intent);
    }
    Add an onResume method, which is called when the first activity returns from the second activity. In this function, I added logic to calculate the elapsed time. The check for 0 and the reset back to 0 is needed because onResume is called during other points of the activity life cycle.

    public void onResume() {
    if ( time_msg_sent != 0 ) {
    time_msg_returned = System.currentTimeMillis();
    time_diff_s = (time_msg_returned - time_msg_sent) / 1000;
    time_msg_sent = 0;
    }
    super.onResume();
    }

    Sunday, August 5, 2012

    Batman: Dark Knight Rises

    This movie was the third one with Christian Bale as Batman and Christopher Nolan as the director.  It was a high-paced, entertaining, action movie, whose plot-line was somewhat difficult to follow (mostly because the lead villian was impossible to understand).  As I reflect now, I know there are many details that I can hardly remember, even though I watched it today.

    So, I am going to reflect on the general feeling I have as I left this movie: it was about legacies.  Bruce Wayne understood that his body was aging and thus he couldn't fight the good fight for much longer.  Would Batman be remembered as an evil vigilante or a selfless hero?  In the real world, Christopher Nolan presented his final piece of his Batman trilogy.  Would the movie live up to the past two?  My feeling is that the legacies of both are intact.  Both the character and the director delivered.

    With that said, there are few things about the movie that I'm unsure about.

    1. When Bruce Wayne is in the jail/hole/dungeon why can't he use the rope to climb out?  If he could, why can't all the prisoners use the rope?
    My answer: Although it wasn't clear to me, there must be a prison warden and guards.  They need to give the prisoners food, and they must regulate usage of the rope as a safety tool only and not an escape tool.

    2. Why doesn't the clan of evil-doers kill all of the cops that they've trapped in the tunnel system?
    My answer: The cops must be hiding within the tunnel system, and it's too large for the bad-guys to find (even though the bad-guys were living in the tunnel system and seemed to know it well).

    USA women's swimming versus USA women's gymnastics

    My wife has been watching a lot of Olympics these days.  I don't share the same enthusiasm that she has for the games, but I watch with her nonetheless.  This year, the USA women's swim and gymnastics teams, in particular, have been captivating.

    The great 'sportsguy' has already weighed in on which of these sports is the better sport to watch in person, but I couldn't help but wonder about another question.  Who would you take, the women's swim team or the women's gymnastics team, in a fight?

    The gymnastics team is insanely quick and strong, but tiny.  The swim team is long and powerful, but I have no idea how coordinated they are outside of water.  A battle royale between these two teams is something I could be very enthusiastic about.