Sunday, July 29, 2012

2012 Olympics - USA vs France - Basketball

International basketball is one of my favorite things to watch.  I love how NBA players, whose games I know well, adjust to new roles on the team as they react to unfamiliar players (both teammates and opponents).  The games often resemble a pick-up game, where we're all trying to figure out who's got game.

For some players their roles are no different from when they play in the NBA.  Kevin Durant is a scorer, Tyson Chandler plays defense, and Kobe Bryant takes difficult shots.  But for others, a person's role changes slightly, and the difference can be dramatic.  The challenge for the underdogs (i.e. anyone playing against USA) is to alter USA's game-plan enough that they're still searching for the right way to play, before the relatively short game and tournament has already passed them by.

Unfortunately, for France, USA started on a winning trajectory that needed no modification.  USA forced turnovers, went on fastbreaks, finished alley-oops, and ran to an easy victory.  We'll see if any other teams can force USA into more uncomfortable situations.

Tuesday, July 24, 2012

Android tracking time

After some research, I've decided to extend the hello world app, which was based on the android developer site, by adding some time based functionality.

I think understanding how time works in Java and Android will be a useful tool for me when building applications.  The concept of time is used in many applications to trigger time-based events.  Keeping track of how much time elapses is also important for monitoring and improving the performance of an application.  Finally, understanding how pre-existing Java classes deal with time will be a good introduction, for me, to the Java way of thinking.

In the original app, we start up a main activity with a text box and a button.
After text is entered in the text box, and the button clicked, a second activity is started, with the text message appearing in the second activity.

As a learning experience, here are some things I hope to build into my application:
1. track how long the user has the application in the foreground.
2. track how long the user is in the main activity.
3. Track how long the user is in the second activity (which is started by the first activity).

Sunday, July 22, 2012

Hello world ... and then ?

After finishing a few tutorials at the official Android development site and reading through some of their guides, I have the feeling that building any app is possible but intimidating.

For even the very simple app that I have in mind, it seems as if I'll need to understand and set up several components:
running a separate background process,
opening and sending data to other activities,
receiving broadcast messages,
storing data,
etc ...
and on and on.  I'm not sure what I should try to tackle first, but I will post updates, if I ever make any progress.

Yao Ming

He is my favorite Asian celebrity.  He is greater than Jackie Chan, the late Bruce Lee, Margaret Cho, and Jeremy Lin.

He was a center in the NBA who surpassed all expectations and for brief moments was the best player at his position.  He excelled in a few things, most of all, being tall and shooting with great accuracy.  He never truly overcame his deficiencies, lack of lateral speed and an abundance of nagging injuries.

My favorite part of Yao is that he seemed thoughtful.  When asked about criticisms made by another famous center, Shaquille O'Neal, a player who deserves his own post, Yao spoke eloquently and defused negativity.

Thursday, July 19, 2012

Replacing apps with websites

What is an app?  Well, it's a program that you might have downloaded that's occupying some memory on your device.  On Android, apps will run as a separate process, but that process can start up other processes (including other apps) and run other background services.   I don't know about other operating systems, but I guess they do something similar.

For example, most weather apps will have a main process that displays the user interface.  But in order to provide the local weather, these apps start or tap into an already running location providing service.  These apps might also start up background services that periodically check the weather.     Thus, your weather app auto-magically knows where you are. It can alert you when a thunder-storm is expected and it always has fresh up-to-date data waiting for you.

Of course, the convenience of an app comes at a cost.  The app takes up some space on the phone, uses CPU which uses battery, and eats up some mobile data.  All of these are rather small costs, but when it comes to a small device like your phone - every resource is limited and should be conserved.

In the case of a weather app, I've tried a few.  Some use more resources, some had more customizations, some looked better, and some weren't free.  And in the end, I hated them all.  The solution that I like for now, is this:

I created a bookmark to - m.weather.com/36hour/12345 - (I changed my zip code to 12345) and placed it on my home screen.   With this bookmark, the memory footprint is as low as possible, I'm semi-sure that it's not running rogue processes, and it gives me what I want.  I'm thinking that this type of switch, bookmark to site instead of app, might be something to consider for a few apps I'm not happy with.

Tuesday, July 17, 2012

Need a Dumb-phone

My smart phone, a Samsung Verizon Android Galaxy Nexus running the Ice Cream Sandwich operating system, has become my latest obsession.

Specifically, I've been trying to figure out why I am always running out of power.   

Suspect #1 is the screen.  It's big, it's bright, it's super-amoled, and, according to my battery discharge chart, it's the largest consumer of  my power.  The solution for this is simple; turn down the brightness and decrease the screen timeout time.  Now that the screen's radiance is gone and the screen turns off seconds after you turn it on, you should see an immediate improvement in the phone's power performance.

Suspect #2 is data communication.  This includes the phone searching for and using 2G, 3G, 4G, wifi and bluetooth networks.  The solution for this is to turn them all off.  If that is a bit harsh, turn your network down to the oldest technology.  Who cares if you have 4G, use 2G.  While it may take you twice as long to download your email, hopefully it'll also cut your power consumption by one-half.  I have no idea if that's the case.

Suspect #3, apps.  These wonderful tools which entertain, inform, and increase your productivity do not run on love.  In the course of processing data, saving your settings and communicating with the cloud, apps use power.  The only reasonable thing to do for this issue is to kill all running apps.  I recommend uninstalling all apps.  When you want to use an app - plug the phone into the charger, download the app, use the app, and then uninstall. 

After you take care of the 3 suspects mentioned above, you will be left with a phone with maximum power capacity.

This brings me to my latest app idea.  There should be a simple toggle app that will turn my phone into a dumb-phone.  When turned on, all you can do is make phone calls.  Well, maybe the app would also allow texting.  We're not barbarians after all.

Monday, July 16, 2012

The Big 88

I went to my grandmother's 88th birthday party today.

We had a lunch buffet at Mizumi.  The waitstaff was patient and kind.  The food, a sushi buffet, was tasty and varied.  And the price was reasonable.

My grandmother had a great time.  After dinner, she had a little sing-along with her friends.


Sunday, July 15, 2012

Skip the emulator, go straight to the phone.

If you are just learning how to build android apps, and if you have access to an android phone, here is my advice:

Skip the emulator and use the phone.

The emulator is a good concept and essential for testing, but its performance was too limited on my laptop.  It took minutes to load up, used up a significant amount of system resources, and occasionally froze the whole system.  I attempted to optimize the settings to improve the performance of the emulator, but the difference was insignificant.  While there is some benefit to meticulously going over each of the emulator's settings to find if any was the trigger that would give my emulator decent performance, it was all in vain.

The better way is to plug in a phone and to debug directly.  Now, the time from opening up Eclipse to seeing a running project on my phone is just a few seconds.  Given that my phone is comparable to my laptop in computing strength (it even has more RAM), this isn't entirely surprising.  Also my laptop now has more free resources available for further development.

While using an emulator is something I do not recommend for the beginner android developer, I expect to use it more if I ever get close to releasing an app.

Saturday, July 14, 2012

Ubuntu Hibernate

As I get involved with Android development, I have found that I need the ability to hibernate my computer.  By hibernating, I don't have to restart the android emulator every time I begin to develop.  Since I'm developing in very short bursts, less than an hour at a time, skipping the emulator start up process saves me a significant fraction of time.

Unfortunately, hibernating in Ubuntu is notoriously unreliable, and it wasn't working ony my system.  This problem seems to be hardware specific, so I don't know how much this might help someone else, but I'll document what I did nonetheless.

I set up a swap partition whose size was greater than the RAM size.
I updated the uuid of the swap partition in the fstab file "/etc/fstab".
The uuid can be found by running sudo gparted.

I tested the stock hibernate program.
However, when I tried to awake the system from the hibernated state, Ubuntu would start with a check disk error and the system was not preserved.
The command for the hibernate program is sudo pm-hibernate.

I installed uswsusp which somehow magically handles sleep and hibernation.
sudo apt-get install uswsusp

I tested uswsusp, and it restarted with all my open programs well.
sudo s2disk

I replaced the stock hibernate statement with s2disk.
In file "/etc/acpi/hibernate.sh", I replaced pm-hibernate with s2disk.  

I added hibernate back into the menu in the UI.
Create this file /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
Then add these lines.
[Enable Hibernate]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes
After a system restart, the selection to hibernate was in menu, and it has been working fine ever since.

Tuesday, July 10, 2012

Hello android world

It's been a few days since I started building an android mobile app.

Unfortunately, I don't have much to show for it.  After starting up the IDE, the android emulator, and my super simple program, I found the program to be ridiculously slow.  The emulator took a few minutes, my computer lagged, and then warning messages of low memory sprung up.  This led me to a detour, where I eventually resized the partitions on my computer (who knows if it even helped the performance on this 5 year old laptop).

After dinner, I'll give it another try.  I'll restart the emulator, and, if God is willing, I will see those two magical words that confirmed I've written a working program -- Hello World !

Update:  I've finally gotten my hello world program to work.  
I'll need to refine this development process, but I think the plan of attack is best done via these steps:
1. Start emulator [from command line probably is best, but I've been doing it from eclipse].
2. Go eat dinner, have coffee, and then check if the emulator is up and running [it takes a few minutes on my home laptop].
3. Open eclipse. Build a clean project. Run the project using the emulator that is running.
I hope iterative development will involve a somewhat simple procedure of making code changes, building, re-starting the app, and not something insane like restarting the emulator.

Update: Using a real phone is fast.
After developing with the emulator for a while, I decided to plug in my Samsung Galaxy Nexus phone, and my app was installed and the activity launched in a few seconds.  This was much faster than the emulator.

Update: More RAM is good.
Rather than just buying a new computer, I realized that I could add 1 GB of memory to my computer, a HP DV2000 laptop.  This would give double my memory from 1 to 2 GB of RAM. For about 20 dollars, I bought and easily installed the memory.  I haven't done any rigorous testing, but the additional RAM has definitely helped development, as testing with Eclipse and an emulator is not that laggy.

Thursday, July 5, 2012

Android development - tool time!

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.

In this post I will introduce you to the tools I use to build Android Apps.  All of the software I use is free to download and use.  I recommend using this setup because it works for me, and it is a rather standard one.

1. Computer
There is no getting around this. You need a computer to develop apps. I use a laptop, the dv2000 HP laptop.  I think I bought it in 2007 or 2008, so it's getting a bit dated.
If I had one recommendation, you should use a computer with a decent amount of RAM.  When I began developing Android Apps, I found that my computer was ridiculously laggy whenever I tried to do any Android development.  I decided to update my RAM from 1GB to 2GB of RAM, and it made a huge positive difference.  Here is a link to the same RAM I bought and installed. 

2. Ubuntu operating system
There really isn't too much special about using this operating system over another with regards to Android development.  I think you could work just as easily on any other operating system.  With that said, I do have the ability to boot into Windows, and yet I prefer Ubuntu for these reasons: Ubuntu boots up faster, it seems to use less resources when it is on, and I like using the bash shell.

3. Eclipse IDE (integrated development environment)
There are other IDE's but Eclipse is pretty much the standard for Java development.  Also, Eclipse has a number of plugins for Android development that are really useful. Most importantly, using the essential Android development toolkit is pretty seamless with Eclipse.  Here are some posts on my experience of using Eclipse and Git.

4. Samsung Galaxy Nexus Android Smartphone
This is the phone I use in day-to-day life.  While having an Android phone is not essential to developing Android Apps, it makes things much easier.  First, you can directly install apps that you are building and that makes testing easier.  Also, if you have a slow computer like me, using the phone as a second test apparatus will reduce the strain on your computer.

5. Asus Google Nexus 7 32GB Tablet
For Christmas this year, my wife bought me the Nexus 7 tablet.  It arrived very early, so I got to play with it yesterday.  In terms of building Android Apps, it will serve the same purpose as my smart phone.  Basically, it will allow me to test on one more device much more easily.  I can then ensure that my app looks good on small and large screens now. 

Please leave a comment if you'd like some more info about my set up.  If you'd like a full post about setting up your Android development, please let me know.

Progress

Basketball has been part of my life since roughly the sixth grade.  But over the last few years, my shot has gone from bad to completely broken.  I'm not sure why things have gotten worse.  There's probably a lot of reasons for this trend - my role as a ball distributor, extreme shot selection down to layups and free throws, and obviously lack of natural athleticism.

Just as things couldn't have gotten worse, I started going to the park after work and on weekends virtually every day.  Instead of joining one of the pick-up games, I chose to camp out at one the empty baskets and exclusively work on the old jump shot.  I threw up ugly shot after shot.  And to my surprise, I've noticeably improved.


This small bit of progress in a rather meaningless part of my life has been inspiring.  I hope to start on my next project, where I can create or improve something.

Wednesday, July 4, 2012

Paris trip

This is a summary of my trip with my wife to Paris in May of 2012.

Thursday

Our trip began, in New York City, with a subway ride to Penn Station, New Jersey Transit train ride to Newark, and a shuttle to our terminal. We arrived comfortably early, printed our boarding passes, and had our bags examined, weighed, and deemed acceptable to carry on. Because my wife is a preferred flier of silver or gold status, we were even able to board the plane before the masses, which made boarding the plane stress free.
Our first mission in Paris was to get to the hotel. We bought tickets to use the RER train to take us to the Saint Michel Notre-Dame Station. It was about 10 Euros for each one-way ticket. After a quick ride, less than half an hour, it only took us about 15 more minutes to walk with our rolling luggage bags from the “Saint-Michel Notre-Dame” station to our hotel, Hotel Abbatial.

Our room was not ready for checking in when we arrived, so we left our bags with the hotel and took a walk to the Ile d’Cite, where Notre Dame sits. We walked around a bit and eventually returned to the hotel to check in.

After a nap, we decided to go to the Eiffel tower. We bought a ten-pack of subway tickets, and then rode the subway to the tracadero area. On the way, from within the subway, I had my first ever look at the Eiffel tower, and it was impressive. When we got to the Tracadero stop, we walked into a restaurant and had steak, fries and beer. Afterwards we saw the Eiffel tower, saw the Eiffel tower light up, walked around a bit, and then went home.

Friday


First thing Friday morning, we walked over to the Lourve. When we got there, a bit before 9 am, a line of around 100 people or so was already waiting to enter. At 9 am, when the museum entered, the line quickly moved and we were inside the museum in about 15 minutes. The tickets are about 10 Euros each, or they are covered by the Paris Museum Pass. We used Rick Steve’s Audio Tour to help navigate the museum and we only explored the Denon wing. This wing holds the famous Mona Lisa.

We exited the Lourve about 2-3 hours later. We walked through the Palais Royal courtyard towards the Champs Elysses Boulevard. On Champs Elysses, we had Italian food for lunch. We also walked through Laduree, a fancy chocolate shop, which has macaroons (which is a fancy chocolate/snack. We didn’t buy anything there. We also went to the original Louis Vuitton, and we bought a wallet. My wife assures me that with the exchange rate, and tax rebate, we somehow made money.

We continued to walk to the end of Champs Elysses to the Arc De Triomphe. We took some pictures on the street, but we didn’t go up. Unfortunately, this was the low point of the trip. Here, my wife had her phone pick-pocketed. Since we knew the phone was passcode locked, we tried to keep our spirits up, but this definitely brought down our mood. We took a subway to our next planned stop, Centre Pompidou, but lacking energy and a bit distraught about the stolen phone, we decided to go back to the hotel, so that my wife could check accounts and change passwords with the hotel wifi connection.

We then returned to the Latin Square area near our hotel and went to a pub. We sat outside and saw many people walk by and stop to stare into the bar as there was a big soccer match on. We had absinthe, where we melted sugar on top of, cherry beer, and I found my beer of choice, kronenbourg 1664. We ended the night with a trip to Mc’Donalds where I ordered a Royal with cheese.

Saturday

We went to the Orsay museum. The ticket was about 10 euros, but it was also covered by the Paris Museum Pass. This time, the line was even longer than the Lourve, and entrance took about 30-40 minutes. The orsay is a beautiful museum, built in an old train station. We were thoroughly impressed with the collection of art from Van Gogh, Degas, Renoir, Monet, etc … We used Rick Steve’s audio tour. However, the pieces were not located where the audio tour expected them to be. Whenever we were able to match a painting to the audio tour, it the audio guide was informative and entertaining. For dinner we found a highly rated Pho place. It was ok, but eerily empty.

Sunday

We went to Saint Chapelle chapel. For about 10 euros again, we entered saw some huge stain glassed windows and left utterly disappointed. For free, you can walk through security, stand next to the chapel, and see one of the stain glassed windows. Then you can leave and save yourself some money.
We then walked all the way to the 7th arrondisement (one of the neighborhoods) to the Rodin museum. We ended up getting salads in the museum restaurant, which was affordable, just as a downpour struck. In another odd pricing scheme, we paid 1 Euro for the garden entrance and about 7 euros for the museum. In retrospect, the garden would have been sufficient as you can see the “Thinker” sculpture and the “Gates of Hell”. Inside the museum, you will find the original thinker with better descriptions. But, if you are on a budget, just go into the garden for 1 Euro. If you are hungry for more, you can buy the museum entrance fee after.

Afterwards we took a subway to Sacre Couer and Montmatre. We walked the steps to the chapel at the top of the hill, took some pictures and went into the town area for some food. We ate some sandwiches and found the area to be completely tourist overriden. The area once set aside for painters was now overtaken by a restaurant.

For dinner, we found a korean restaurant in the neighborhood.

Monday

We tried to go to Belgium on a day trip, but it proved to be too expensive. If you plan on going, it is probably best to buy a ticket at least one day in advance. We returned to our hotel area and had breakfast. After a nap, we took a walk to the Pantheon. It was about 7 euros, which is also covered by the Paris museum pass. We saw Foucalt’s pendulum and a number of tombs for some famous French people.

Tuesday

We went to the Marais Market and walked by the Bastille. We then walked to the Promenade Plantee, which was completely unimpressive.

After a few days of sightseeing, we decided to go to the Luxembourg gardens for a picnic and relaxation. At night, we took a boat tour on the Seine river. This was cheap and nice.

Wednesday

Flew home.

I'm sure we did more on Monday and Tuesday, which included shopping for souvenirs, drinking wine and beer, and eating delicious touristy Greek gyros. However, I didn't take good notes and I don't recall the details now.

Monday, July 2, 2012

Phone calls, texts, etc ...

The other night, my brother called with bad news.  My mom, who had just gone through her last rounds of Cancer treatment, had slipped and broken two bones in her ankle.

I imagine this is just me, but every time the phone rings, I often find my brain filling up with dread.  "What is wrong now?", I can't help but feeling.  I think this feeling is creeping up more often, because of work.  At work, every phone call I get is bad news.  A phone call means that something is wrong or broken and needs immediate attention.

I think the only way to combat this feeling is to get in touch with my friends and family more often.  That way, the probability that any random phone call is bad news becomes smaller and smaller.