Thursday, December 22, 2011

ASP.NET MVC 3: How to update EdmMetadata ModelHash when manually adding a field to a database

Having developed web applications for 8 years now, I've gotten very used to adding fields to existing web applications. It is not an everyday thing. Maybe not even a every month thing. But it is definitely a every major release thing. With that in mind, Microsoft's MVC 3 seems a bit incomplete in what they are recommending you do every time you need to add a field to a existing MVC web application.

Option 1: Microsoft's suggested solution? Add a few lines of code that will automatically drop the table, re-create it, then seed it through an Initializer class if it detects that the schema has changed. This may be fine for development, but since most people actually looking to do this is working on a production web applications, this is a bad idea even to propose as one of the ways to add a field to your web application. And you must be extra careful when implementing this on a simple table. Imagine you or someone updated the schema of a table that has a lot of valuable data, but you just want to update a few tables with a few rows of data in it and you could easily seed it. You turn this feature on and that valuable data vanishes without a trace for that customer.

Option 2: If you try to search for the solution, the number one recommended solution is to disable checking of changes to the schema. This isn't a bad suggestion. Just turn the whole darn thing off. You and maybe a handful of people are care about schema changes anyway. Why have this elaborate schema checking system in place anyway? The answer is that the customers have compliance requirements, and they are required that their web application meets those requirements. And a common one is that they be notified of schema changes to their database.

Better Solution: What MVC does is that it runs a consistency check by hashing the schema definition. And they don't provide a well documented way to update this hash value. What they should do is let the user put the database in a learning or training mode. So that if the schema changes, it will update the stored hash value to the new value. Then when you are done adding the field, you can switch off he learning mode so that it throws up the normal server error when someone has maliciously (or unknowingly) changed the schema without alerting the right people. So this is my solution to make all that happen:

Step 1: Open Global.asax.cs in your MVC web application.
Step 2: Add these lines to the top of the file:
using myMvcProjectName.Models;
using System.Data.SqlClient;

Step 3: Add these lines to the main class for your MVC web application (the class is probably named MvcApplication).
private myDBContext db = new myDBContext();
public void Update_EdmMetadata_ModelHash()
{
string newHash = System.Data.Entity.Infrastructure.EdmMetadata.TryGetModelHash(db);

SqlConnection sqlConn = new SqlConnection(myConnectionString);
SqlCommand sqlComm = new SqlCommand("UPDATE EdmMetadata SET ModelHash = '" + newHash + "'", sqlConn);
sqlConn.Open();
sqlComm.ExecuteNonQuery();
sqlConn.Close();
}

Step 4: Add this line to the top of Application_Start, to run the new function to turn on "learning" mode. Just comment it out when you are done:
Update_EdmMetadata_ModelHash();

Italic = change these values accordingly.

Monday, December 12, 2011

The reason why the Galaxy Nexus has been delayed

The real reason? Billions of dollars of potential revenue for the foreseeable future with NFC money transactions. What Google wants to do is thin-out your wallet by getting rid of all your plastic, but in a good way. I certainly would prefer not to carry around the debit cards, credit cards, club membership cards, and clothing line cards if I didn't have to. There might have been some appeal in the past, maybe 10 years ago, to carry around as much plastic as possible. But that time is long gone as it has become a nuisance to carry the right card to the destination you are heading to. Instead, Google is predicting that swiping cards will be a distant memory in just a few short years with NFC chips that is built into newer phones. Instead of using a plastic card, you will just have a digital copy of your card on your phone, and all you will have to do is touch the smartphone to the credit card receiver. The amount of cards you can carry will be limitless, and you don't have to carry anything extra in your pocket. A real win for the consumer.

Under our noses, Google has positioned themselves to be the first successful and soon the only NFC payment service people will want to use. Even though NFC payment services have been in existence for a while, these companies are still struggling to gain any market share or convince consumers to start using NFC instead of plastic. Google, on the other hand, has smoothly made our Google Checkout accounts able to accept NFC payments (renamed it as Google Wallet), and is about to enable the NFC capabilities into android devices that we already own and carry with us all the time. And this is happening at the right at a time when the adoption of NFC payment devices at retail locations is exploding or about to explode. Well played Google. They are poised to take a percentage from every one of our credit card transactions in the future. They are one move away from saying "checkmate." And us, as consumers, are about to love Google for enabling this service.

But who is holding up the show? Verizon. And understandably so. Verizon would rather not have Google Wallet pre-installed on the Galaxy Nexus, and instead would rather have their own NFC payment app installed, and want any other NFC payment app blocked from making it on the device. So this is the real reason the Galaxy Nexus, already stocked at retail locations, is not being sold at the moment. This landmark decision is so big that Verizon is willing to lose many customers daily to AT&T as AT&T is turning on their LTE networks like gangbusters at major metropolitan areas on a daily basis.

The way I see it, Verizon is fighting a losing battle.
A) People don't like using included apps provided by the carrier, aka "bloatware". They are usually not refined, and better 3rd party solutions exist. It has become a reflex to uninstall bloatware as soon as a new phone is turned on.
B) Even if by a slim chance Verizon gets everything they ask for, gets Google to agree to remove Google Wallet, and block any other NFC apps from accessing the NFC chip, it can easily be circumvented by rooting. To add to that, what is going to stop Google from wanting users from rooting their device so that they can get Google Wallet onto their devices? Google will be on the side of the consumers, not Verizon.
C) A low level root protection could be enabled on the Galaxy Nexus and if it actually worked and held, there would be a backlash of biblical proportions by tech review blogs that it would be the worst decision Verizon can make that all the money they spent to get exclusive licensing of the Galaxy Nexus and the first one to have ICS, will be negated, maybe lost due to the impact on sales.

In conclusion, as much as Google has become "big brother", I trust Google a billion times more with the integrity of my payment transactions. Speak to anyone who has dealt with Verizon's hidden charges, erroneous charges, cancellation charges (even after you've fulfilled your contract). The way they handle themselves in your face is criminal. Basically, you are likely to get some erroneous charges when you first sign up for their service. You call, and the person that answers your phone call is already pissed off at you before you even start speaking. Then after a long heated argument on why you shouldn't be charged for something you didn't order and would never use, they make it sound like they are forgiving you by removing those charges. Then when you get your bill, you realize it is still high because they are charging you $15-$25 of hidden fees and taxes. You call them about it, and they say they have no reason to control that because it is a tax by the government. Federal, state, and local. No other carriers do this as they pay these fees which is included in your service fees. Then say after 2 years, you're done with their contract, you decide to cancel. They send you a mystery bill. When you call them on why you are getting charged for service you no longer are using, they once again are pissed off before you even start speaking. Then they ask to go talk to the manager. And they come back and say that they are giving you a break and that the manager has agreed to reduce your bill to half the amount as a favor. This is a bill you shouldn't even be paying. Then the only option of paying your bill is over the phone. And guess what, Verizon charges $5 for phone payments. This is how they run their business. It works for them because a lot of businesses like using Verizon as their carrier and businesses are unwilling to go through this kind of hassle. They instead just pay. Do you want a company Verizon acting as the bridge for everyone of your transactions in the future? Absolutely not. I trust Google more.

Saturday, December 10, 2011

Play KROQ on your Android

Wow, this took me a while. I think I spent about 3 hours total on how to get this to work properly.

The most obvious solution would be to look up KROQ a radio app, like TuneIn Radio on the Android Market and you will see that it says it is restricted by the content owner. Which wasn't a shocker. So I assumed that whoever owns the content, CBS, probably provides their own apps. So back on the android market, I google KROQ and find 2 apps. radio.com and Yahoo Music Radio. Long story short, it seems like KROQ's stream has some DRM on them. And the radio.com and Yahoo Music Radio doesn't know how to decode them! Ha! Pretty hilarious! It just plays garbled music. On top of that, even if it one day is updated so that it knew how to decode it's own stream, it would play it at very low quality. Worse than AM quality. In a nutshell, it is just fail after fail on all levels. Go to these apps, and you just see 1 star review after another. Don't they want people to listen to their station? I don't get it.

A quick solution is to go to kroq.radio.com on your android browser, and then it will play a nice high quality stream. The player on the page is flash based, but it is no problem for Android devices. The problem is when the phone's screen turns off, your browser goes to sleep. A wasteful solution is to make sure the browser keep the phone awake. Unfortunately, the screen is the most power hungry thing on your android. A tough price to pay for listening to radio. And even if you can plug yourself in to a power source, keeping your AMOLED screen on when you really don't need it is basically wasting the life of the beautiful screen. You wan't your screen to keep nice and bright for 2+ years right?

I was able to find a low quality stream on a forum. But how can I play it? The best solution was to find something like a shoutcast client that keeps the audio stream open when the phone goes to sleep. I found an app called XiiaLive Lite. There wasn't an obvious place to put my own streams in at first. Searching for KROQ didn't yield any results. But the feature is there under favorites. Now that I had KROQ playing on my phone with the screen turned off, I was still disappointed with the quality. Just finding this one low quality stream was no easy task and took quite a while to dig through google. But the interesting thing was the low quality stream link pointed to something called streamtheworld. That sounded interesting. I googled "streamtheworld kroq", and jackpot.

Solution:
Just add this to XiiaLive:
http://provisioning.streamtheworld.com/pls/KROQFMAAC.pls

Looking at the stream information, it looked like it is going to be a very reliable source as well as there are about 20 backup streams that it can failover to. Now I have a high quality audio stream of KROQ playing on the android device when the screen is asleep. I imagine that streamtheworld tries to offer streams of any radio station. Now all this could be avoided if the radio.com app worked the first time, and it allowed high quality streams. Hopefully that will be an option in the future. A note about WINAMP player that also plays shoutcast streams. It probably will not play the stream above because the WINAMP player is not capable at the moment to play high quality AAC streams.

Troubleshooting:
For some reason, when I kill the app, then go back, it won't start up the AAC stream above. If I play the low quality stream first:
http://provisioning.streamtheworld.com/pls/KROQFMDIALUP.pls
Then switch to the high quality stream:
http://provisioning.streamtheworld.com/pls/KROQFMAAC.pls
Then it starts playing the HD stream again. Strange. Best to have both of these favorites in there in XiiaLive.

Tuesday, November 8, 2011

Traded in my AT&T Samsung Galaxy S2 for a Skyrocket

First things first. XviD hardware decoding performance on the Skyrocket is really terrible where the Galaxy S2 always did this flawlessly. Surprisingly the DivX and 1080p and 720p MKV are flawless on both devices. Zooming into very large webpages are choppy on the Skyrocket. You will not notice any difference on small websites. The bigger screen is a bit nicer I must admit. Flash video seems to run without hiccips on the Skyrocket where the original S2 seemed to struggle with this at times. On the other hand any flash app that demands all the horsepower you have will indeed be significantly slower. For example I used to be able to play bejeweled Blitz on Facebook on the S2 and it used to make sense to do so. On the Skyrocket don't bother. It will be too laggy for it to be playable. Just giving people a point of reference with these examples. One nice thing you may notice on the Skyrocket is that the microSDHC card is removable without removing the battery. Lastly, 3D is noticably choppier. It does not matter to me at this point because I dont play any 3D games but I will be looking to play GTA III when it comes out. It may or may not make a difference. I just wish they improve the XviD performance.

Sunday, October 30, 2011

Samsung Galaxy S2 Vs. Galaxy Nexus

Galaxy S2 has a Faster CPU
Dual Core Exynos 1.2ghz is A LOT faster than Dual Core 1.2ghz TI OMAP 4460

Galaxy S2 has a Faster GPU
Not only the Galaxy Nexus has a slower/older GPU, but it is a slower GPU on a device with a lot more pixels. Bad combo. Expect noticeable difference on any moderate GPU intensive app. People are saying how the Galaxy Nexus runs graphic tests slowly because it is not optimized. This is true. Keep in mind that pretty much the Galaxy Nexus is the only phone with 1280 x 720 resolution right now, and the apps, to get the full potential of the screen will have to be optimized. Realistically all apps will not be optimized at first for the Galaxy Nexus. And slowly they might become optimized. And some may never be optimized because it is up to the developer. Also, after optimization, remember it has more pixels to process with slower hardware than the Galaxy S2.

Galaxy S2 has a better rear Camera
8MP > 5MP
Sure it is not all about megapixels, but did anyone say 8MP on the S2 was bad? Not at all, it is fantastic. 5MP sensor on the Galaxy Nexus might be a great sensor but it is a downgrade in image quality from the 8MP galaxy S2 sensor. I'm sure the Galaxy Nexus 5MP sensor is better than a lot of other 8MP sensors out there though.

Galaxy S2 has a better front facing camera
That is 2MP on the S2 and only 1.3MP on the Galaxy Nexus. Again, it is not all about megapixels, but speaking from first hand long term experience of having a older Samsung Galaxy S with a 1.3MP front facing cameras, the 1.3MP camera has been one of the most unimpressive cameras I've ever encountered. Galaxy Nexus is most likely using the same 1.3MP camera. I can say that the 2MP Galaxy S2 front facing camera is a lot better than the older Galaxy S front facing camera by comparing the quality of the image using the mirror feature on the OS.

Galaxy S2 has Super AMOLED Plus (Better than Super AMOLED (Pentile) on the Galaxy Nexus)
Might be less important because of pixel density, but take it from a user who has used a Galaxy U (a Galaxy S with a higher pixel density because of the smaller 3.7" screen...~252 PPI) and used it for a whole year. You would think with a higher pixel density like that you can't see the checkerboard pattern? Wrong, it is visible. Clearly visible when white lines are visible on the black background. Are there white lines common on black background on android devices? Duh! But you'll get used to it like you get used to scratches on your glasses. Maybe ICS will mask the ugliness with the blue glow.

Galaxy S2 has microSDHC (comfirmed to be compatible with microSDXC) slot while Galaxy Nexus has none.
So right now, you can put an additional 64GB card on the Galaxy S2 on top of the 16GB. The Galaxy Nexus will be locked to 16 or 32GB. Galaxy S2 might one day support up to 2TB, but more realistically, people will be carrying 128GB and 256GB cards during the lifecycle of the Galaxy S2 device.

Galaxy S2 has been announced to get Ice Cream Sandwich Android OS 4.0 update.
Sure if you get the Galaxy Nexus, you can have ICS for 6 months maybe. But is it worth the sacrifice of hardware? Software you can upgrade. Hardware cannot be changed.

Galaxy S2 has native DviX/XviD/MKV support. On Galaxy Nexus you will need to do software decoding which is much slower. A lot of times the HD videos are too slow for watching videos.
The Galaxy Nexus will be able to play 1080p h264 files, but it will certainly not be able to play any 1080p mkv or divxes like the Galaxy S2.

Galaxy Nexus has a bigger screen. I hear it is awesome by all accounts.

Galaxy Nexus has a much higher resolution
I bet people are drooling with the thoughts of watching 720p videos natively on the device. But they are forgetting that it has to be encoded in h264. So basically you have to shoot the video yourself, or encode it yourself because 720p h264 is not as popular of a format than 720p and 1080p mkv files that Galaxy Nexus doesn't support. This will be a serious letdown for many thinking they can just download any HD content and watch it on their device.

Galaxy Nexus has a lag free camera
A lot of people are speculating ICS 4.0 will bring a lag free/near lag free camera to a lot of devices. So this may be only a short lived advantage, just like ICS being a reason to buy a Galaxy Nexus.

In conclusion, the Galaxy S2 is superior almost every way possible. Where Galaxy Nexus is better, it seems to be crippled by Samsung choosing to go with inferior screen technology (SAMOLED instead of SAMOLED+), a weaker GPU, and the decision to only support a limited set of HD codecs (no mkv support). As for Samsung Galaxy Nexus offering features that are only possible because of it having Ice Cream Sandwich (Android OS 4.0), the S2 has been cofirmed to get this upgrade in the future. Again, smartphone software can be upgraded, smartphone hardware cannot.

Wednesday, September 28, 2011

Amazon Prime? I am sold.

Amazon Prime, 2 day shipping and unlimited streaming? Wow. I'm cancelling Netflix and going exclusively with android based products from now on. I was on the verge of deciding to keep my prime after the free trial because I loved the 2 day shipping, but it was expensive. I was also pondering the cancellation of Netflix. But with unlimited instant streaming, Amazon Prime is a no brainer. True, Netflix has better content, but it isn't great either. I just wanted a little bit of streaming of content I would never consider downloading, but wouldn't mind firing up if it were to stream instantly. Prime for video will do. And the free 2 day shipping is really saves you money and time on things like office products if you can hold out for 2 days, plus with the added benefit of purchasing items you can't get elsewhere and getting it quicker.

Tuesday, August 2, 2011

Does iCloud mean we will never get 64GB iPhones?

With iCloud, Apple is trying to pitch an idea that you don't need more internal storage. This could potentially mean that Apple can continue to charge premium prices for 32gb iPhones while charging for iCloud services as well. Until when? Until forever. Yay Steve! You did it again.

All this while the price of memory cards per gigabyte is falling to virtually nothing and storage capacities skyrocket to infinity. This gives propaganda material for Apple to continue to never support memory card slots. They make 128GB SDXC cards now, and that is just the beginning of what SDXC will be capable of in the next few years (up to 2TB).

Who needs that much memory? Not everyone, but I would use it. I'm sure many others feel the same way. So why not have the option? It would be beneficial to the customers. What is sad that I can already see the fanboy's typical response arguing that Apple is doing smart business. Apple's brand is so strong these days that people are willing to argue for the benefit of the company, and against the benefit of the customers.

Sunday, June 26, 2011

Garmin intentionally retards its device when your maps get over 2 years old.

Having a 5 year old GPS, I've noticed something interesting. 2 years after I got my Nuvi, and my GPS kept telling me that my maps were more than 2 years old, I noticed my nuvi 360 doing something peculiar. A third of the time, it would just fail to lock on to a GPS signal no matter what I did, until I restarted it. After I updated the maps and the software, the problem went away.

2 years after that I'm noticing the exact same thing happen. It wouldn't be so bad if they weren't charging for these map updates.

Friday, March 25, 2011

My Dad's Eulogy

I had the honor of delivering my dad's eulogy. This is what I said:

I’ve always known my dad to have distinct qualities about him. He was someone who talked about his big dreams one day, and then executed those dreams sometimes the very next day. Because of this, he ran many successful businesses, gained a lot of experience and skill from being involved in many different fields. He also loved nature, photography, music, antiques, and golf. He spent many years practicing golf. One day he told me that he wanted to play in an open golf tournament. When I asked him about it a month later, he told me that he decided not to play in the tournament because couldn’t justify the registration fees because of the needs of his family. He did say that the person who won first place was a semi-pro golfer that he knew; someone who he had already played and won against in the past. Sadly, he never played much golf after that. I’m not sure if he shared this with anyone else but myself, but I’m happy that I can share this about him today. He was an amazing guy.

I learned something about him just as I arrived home this week. My brother had got him a new computer. And he had been learning how to use Windows 7. It turns out that he had been using the Internet to find and get in touch with his friends from high school and college. They had created a discussion board and had been exchanging stories.

He also had been using the Internet to find and download some of the songs that he loved during his youth and adult years. He had amassed a pretty impressive collection. I was so happy to hear how he got to experience some of the ever improving ways to connect with his past through the Internet just before he left us.

Over my entire life, when I finally thought I had my dad figured out, I would realize later that I completely had him figured wrong. He was someone who had a different perspective on a lot of things and how things should be done. Why he said and did some things will always remain a mystery. But the one thing I am certain about is that his love and willingness to provide for his family was absolutely the most one can receive from a father.

He was selfless when it came to caring for himself VS caring for his family. It was incomprehensible at times. He bore the weight of every family member’s struggles completely on his shoulders probably every day of his life. It didn’t matter that our family members didn’t know that he was trying to solve everyone’s struggles. It didn’t matter to him when we told him that we’ll be fine and we wanted him and mom to enjoy life. In his mind, he knew he could do it, and no one needed to try to convince him otherwise. His commitment in trying to provide for his family is always something that I never questioned. And it is something that immediately comes to mind when I try to think of his best qualities.

I feel that because he felt this extraordinary commitment to his family, he lived a very hard life when he didn’t have to. But I finally understand now because providing for his family, anything and everything at any time, was his passion in life.

If I could change anything, I wish I could have been more receptive of his offers for help. I could have said, “Wow, that’s great dad, I love it” every time, instead of telling him that I didn’t need it. It would have been just that easy to communicate to him just how much we appreciate and need him in our lives.

If my dad is listening, I would tell him thank you. I’m sorry for always having been so difficult. I love you. And I miss you.

(The part that I edited out the last minute. I was going to tell this story first then say everything else.)

I would like to share with you a memorable vacation we had together as a family. It was Memorial Day weekend of 2005. It was the first time in almost 20 years that my family felt comfortable enough to close their shop for more than a day. We planned a 3 day trip to Las Vegas. We even bought tickets to see a show. We decided to take my sister’s car because it was the only car that could seat all of us comfortably.

The traffic was unusually thick that morning near Barstow around 9AM. We sat through an hour of traffic moving less than 5 miles per hour. My dad always loved to play with the gears on a car, even on a 7 year old Toyota Camry with an automatic transmission.

My dad loved music too. While sitting in traffic, my dad wanted to listen to my iPod at full blast with the earplugs on. A little while later, the grueling traffic cleared, and everyone cheered as my dad floored the gas pedal.

What he didn’t realize was that he had left the car in 2nd gear. Because of the earphones, he didn’t hear the engine struggling as the engine exceeded the limits in 2nd gear. It didn’t help that there were 5 adults in a car with a small engine.
Two seconds later, there was a loud pop under the hood and the car shook. I was really hoping we ran over something, but when black smoke rushed into the cabin of the car, I knew we had a serious problem in our hands.

We quickly pulled over. As my dad opened the hood, flames shot out and the front part of the car caught on fire. As my sister, brother, and I ran to a safe distance, my mom and dad were worried about one thing; getting the cooler full of kimchee out of the trunk. As people driving by were screaming “get away, it’s going to explode!” they rescued the kimchee to safety.

The car quickly became engulfed in flames, and just when I was thinking our grand vacation to Las Vegas was over, a fire-truck was coming towards us from the middle of nowhere. As the firefighters finally extinguish the car and start tightening up their water hoses, a tow truck appears. The tow truck has just enough room to fit all of us in the tow truck; even the cooler full of kimchee.

We’re towed back to Barstow and drop off the car at the towing service office. As we try to borrow a rental car, we’re dealt another challenge. The rental car office tells us that they cannot help us because they have no more cars available.
Every time we met a challenge, we all thought that our first and only family trip in the last 20 years was over. But my dad reassured us that we can still make it and that he’ll figure out a way. And that’s exactly what he did. A few seconds later, someone walked in to return a 4 door sedan. It was just what we needed. Miraculously, we’re back on the road in 2 hours from the start of the ordeal. We got to Las Vegas, had a blast, and of course we enjoyed the kimchee too.