Thursday, February 21, 2013

Setting up Android Development under Ubuntu 12.04 - Howto.


Getting Eclipse to run:

Surprisingly Eclipse does not work "out of the box" with Ubuntu 12.04.  At least it did not on my own box.  This sort of thing is kind of bad, a hurdle like this right at the start could prevent some people from figuring out the rest of the process of making their own mobile apps on a Linux distro.

When I tried to run Eclipse I just got an error message.  I uninstalled eclipse and reinstalled it and got the same error.  Eclipse is broken out of the box on Ubuntu.

I installed the java 7 from oracle, but not sure if that had anything to do with the fix.  http://thedaneshproject.com/posts/how-to-install-java-7-on-ubuntu-12-04-lts/

So I looked up the error from the log file it told me about and found this info: http://stackoverflow.com/questions/10970754/cant-open-eclipse-in-ubuntu-12-04-java-lang-unsatisfiedlinkerror-could-not-l

Specifically this command:
  • 64 Bits System: ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86_64/
  • 32 Bits System: ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86/

Installing ADT 

Once I finally got Eclipse running I installed Android Development Tools (ADT) using these directions: http://developer.android.com/sdk/installing/installing-adt.html

It was tricky on the small screen of my netbook to see the selection to click.  I had to hold down on the alt key while I clicked on the window to pull it down, then grab the top of the window to make it bigger, then the selection came into view and I could click it, and finally use the alt key to move the window up so I could click on the next button.

After ADT is installed, allow it to restart Eclipse, then it asks which Android SDKs to install, and I opted for both 2.2 and the latest.  You can use some option to install different ones at any later time.

Creating a Test App:

After all this I created a test android application under the File->New menu option.  By default the app just says hello world.   I made the font a little bigger so it would show up on screen shots and photos better.

Create an AVD so you can run the emulator.

I created an Android virtual device (AVD) using the AVD manager button. The first time I did it I didn't have enough free space and it failed, but it didn't give an error message, it just sat at a screen that had "A N D R O I D _" with the underscore blinking and then did nothing else.   I cleared out some drive space, deleted the first AVD I created, cleared the project, and created a new AVD with more memory and sd card space.

The emulator is so slow and bad that it might be faster to  transfer the app to the hardware device using http each time I want to run it.



Exporting the App and serving it to the mobile device.

The process of getting the app to the device is non-obvious.  You have to export the project to a file, using a keyfile to sign the project.  I created a new key for my projects, filling out the forms as best I could.  Finally I exported the project to a directory and then placed the FirstTest.apk file onto a local web server.  http://stackoverflow.com/questions/4600891/how-to-build-apk-file/4600933#4600933

Downloading and installing the app on the mobile device.

On my mobile device I went into settings->security and enabled unknown sources.  Then I started the internet browser on the device, went the URL where the file was located on the web server, downloaded the file, went into the download area and installed the file, then opened my application.  Whereupon I was presented with "Hello World!" in glorious black and white.



Conclusion.

So that is the process of
  1. Installing Eclipse on Ubuntu 12.04
  2. Adding the ADT to Eclipse
  3. Creating a Hello World project.
  4. Getting the emulator to run the app.
  5. Sending the app to the mobile device.
  6. Running the app on the moblie device.  

Where do we go Next?

Now that we have a development environment and work flow that we know works, we can start designing applications that actually do something useful.

Final piece for the setup. 

Because the emulator was so bad  and it was so awkward to install apps, I figured out how to connect up the device directly to Eclipse using these directions: http://developer.android.com/tools/device.html#setting-up

After following the directions on that page and configuring the Tab to allow usb debugging under settings->Developer->Debugging  Allow USB debugging by checking the box.  It looks like we can even debug the apps through Eclipse directly on the hardware device, which is handy.  Now I can almost instantly start and run an app directly on the Tab itself, right from inside Eclipse rather than deal with the emulator. 

MIT App inventor.

I am also checking out app inventor here: http://gigaom.com/2012/03/05/with-this-tool-even-you-can-write-android-apps/  This promises to be a no fuss way to develop simple apps.  Might even be a method to quickly flesh out an app, then transfer it to an Eclipse project to finish/extend full functionality.


Tuesday, February 12, 2013

Numberic Integation methods for calculus - Trapazoidal approximation method.

You can integrate functions without using calculus, but it would be amazingly difficult to get good results by hand.  You would have to grind through functions putting in values for each interval you were trying to calculate and then total those values up and divide by the change in x over the interval by 2.  But what we do have now are computers that will happily run through a million calculations before you can take your finger off the enter key.  Maybe you want to double check an integration you are doing to see if the results are in the ball park, a sanity check, if you will.

These functions will require you to tweak them if you go changing them around, and no guarantee is made for their accuracy.  I have not systematically tested them for anything and do not warranty them for any use other than possibly to double check a homework assignment or two. 

The first program I tied I got amazingly close to the results in my calculus book.  


.#include <stdio.h>
#include <stdlib.h>

// return x squared
double f (double x){
        return (x * x );
}

int main (){

        long double b = 1;      // interval begin
        long double e = 2;      // interval end
        long double n = 1000000;        // number of steps., denomenator
        long double r = 0;      // result

        long double c=(e-b); // The change in x per unit
        long double ca=c/n/2; // The multiplier for final result
        long double ba = b * n + c; // the begining numerator
        long double ea = e * n;     // the ending numerator

        for (;ba<ea; ba+=c)
                r += f(ba/n);  // sum all the intervals
        r *= 2;  // double all the interval values.
        r += f(b) + f(e); //handle the first and last interval
        r *= ca; // apply the final multiplier
        printf("Answer is %.20Lf \n", r);
}
Save the above as program.c 
Compile it with gcc program.c -o name 
Then run it with   ./name
 I got this as my answer:
Answer is 2.33333333333350000744


The following code is similar to the above code, but I changed the square function to return the result of a polynomial. I don't have a good way of running this as

#include <stdio.h>
#include <stdlib.h>

// return a polynomial
double f (double x){
        return (2 * x * x +4*x -5);
}

int main (){

        long double b = 1;      // interval begin
        long double e = 2;      // interval end
        long double n = 1000000;        // number of steps., denomenator
        long double r = 0;      // result

        long double c=(e-b); // The change in x per unit
        long double ca=c/n/2; // The multiplier for final result
        long double ba = b * n + c; // the begining numerator
        long double ea = e * n;     // the ending numerator

        for (;ba<ea; ba+=c)
                r += f(ba/n);  // sum all the intervals
        r *= 2;  // double all the interval values.
        r += f(b) + f(e); //handle the first and last interval 
        r *= ca; // apply the final multiplier
        printf("Answer is %.20Lf \n", r);
}

This gave me a result of   5.66666666666699991731  but I am not sure how to check if that is right.  I will integrate the function, and then calculate for the interval using those numbers to see if it gives similar results.

I  am not sure if this program will work with fractional intervals, will require additional testing to see if that works.


A more accurate method is to use Simpson's rule, Approximating using Parabolas, which I will attempt to perform in the next few days.

I updated the interval calculation to work right when the range is not an interval of 1.

Monday, February 11, 2013

Case Study 1 – Pandora and the Freemium Business Model

-->

Word Count: 1648

Q1: Compare Pandora’s original business model with its current business model. What’s the different between “free” and “freemium” revenue models?
In the beginning Pandora tried to get music subscribers by giving people 10 free hours, then asking them to pay $36 a month after that for the service. Of course no-one was willing to pay so much for a service that they could get for free by switching on an FM radio (Laudon and Traver 103).
After that model failed they tried several other options until they decided to use the “freemium” model they are using today. With a freemium service the basic service is available for everyone for free, but with strict limitations in bandwidth and ads between songs which results in a lower quality listening experience (Laudon et al. 103).
The premium service is priced at just $36 a year, 1/12 of their previous asking price. Three dollars a month is much more easy for a consumer to justify. The premium service offers higher bandwidth songs and no advertising (Laudon et al. 104).

Q2: What is the customer value proposition that Pandora offers?
Investopedia.com defines a value proposition as “A business or marketing statement that summarizes why a consumer should buy a product or use a service. This statement should convince a potential consumer that one particular product or service will add more value or better solve a problem than other similar offerings.” (Investopedia.com) So I went to the About page on Pandora to find the value proposition.
What Pandora does for its customers is provide access to music through the “Music Genome Project.” This project was started by the founders of Pandora and offers a way to classify music so that similar music by different artists will group together into what they call a personalized radio station (“About”).
The music is evaluated by professional musicians for genre, and then within each genre 200-500 different data points are set for each song by the music professional. A function is used to identify the distance between songs so that similar songs can be included in a customer's playlist. A user can apply additional weights to promote or demote certain bands so they will play more or less often on their radio station. This really is impressive technology that would be almost impossible to replicate by another company (“Music Genome Project”).

Q3: Why did MailChimp ultimately succeed with a freemium model but Ning did not?
The case study claims that freemium works best when there is a very large audience for your service and you can offer paid upgrades to make it worthwhile for people to pay to get the additional added value (Laudon et al. 104).
MailChimp works as a free service because anyone that sends the same email to multiple people is a prospective client. The light user might be someone sending out a church newsletter as an email every week, with a volume of just dozens of emails. A high end user could be a corporations using the service to send a hundred thousand emails to its customers and needing to track the conversion rate of the emails, or now many of the people clicked a link in the email, and how many actually purchased something because of the email (Laudon et al. 104).
Ning didn't work as a freemium service because not everyone needs to start their own targeted social networking site. If you need something like that then you are willing to pay for the services up front in order to get the features you need to grow your site (Laudon et al. 105).

Q4: What’s the most important consideration when considering a freemium revenue model?
This is really the most important part of the case study and the section where I learned the most about what makes a business model a possible freemium candidate.
Large potential audience.
This is the most important thing. In order to grow as a business you need to attract many people, millions of people, to your service. These free users are the pool of people you will be converting to paying customers (Laudon et al. 105).
Low variable cost to add additional free users.
One of the amazing things about the Internet is that you can provide service to people at a cost approaching zero dollars. You can do this with automation and by pacing the computing power you are using to spread it across all the free users. If you have to buy a music license or a new computer for each user you add, then you are not going to stay in business for long (Laudon et al. 105).
Easy to use.
Let's say you do attract people to your web site by the millions, in order to get people to use your service, it has to be easy to use. You can't afford to have each new customer call customer support in order to use your service. The service must work “out of the box” for each new user and walk them through every step automatically. This is one of the things that Google plus did wrong. At first the service was very simple and easy to use, but it rapidly grew in complexity until now I can't even see my own lists of posts anymore and have no clue what 90% of the selections even are anymore (Laudon et al. 105).
Network effect helps to add and keep users.
If you can get your service spread by word of mouth, so that one person gets all their friends to sign up too, and then it is very difficult to leave a site because all your friends and business associates are there, then that is the network effect in operation. This is something that social media sites like Facebook really key into (Cornell.edu “... in Terms of Network Effects”).
High customer retention rates.
It doesn't help you if you get a million people to try your free service and then never visit your site again. You want to make your site “sticky” so that when someone visits the site it is so easy to use and offers so much convenience that users keep coming back, keep using the service, and enthusiastically tell all their friends about your site (Laudon et al. 105).
Value of service to customer grows over time.
Once people are on your site and using your service, you want the value of what you are doing for them to increase over time, so that the longer someone is on your site, the more difficult it is to leave and the more likely they are to use your site for their primary portal to the Internet (Laudon et al. 105).

Q5: Pandora’s stock (P) has dropped 27% since its initial public offering (IPO) in 2011. What recommendations do you have for the Pandora management?
I hate to have to say this, but I do not believe that playing music over the Internet is a viable long term business that can sustain itself. The license costs and bandwidth costs are just too high when you reach a billion freemium users (Pandora Media 15).
I think that what they need to do is to position themselves as the alternative to the apple store on android devices. By becoming a music store that only provides brief snippets of music they will eliminate both the license fees and most of the bandwidth costs.
They can also license their music classifying database through a web interface to other companies that have a need to provide music recommendations to their customers.
The patent they hold is a very interesting general method of using experts to classify items and then using automation to see what is most like that item. This could be used for many other categories. Either by licensing the technology to other people, or doing the tech in house and providing web service access to the information (Glaser, “Consumer Item Matching...”).

Q6: Would you recommend Pandora’s stock to future potential investors? Why or why not?
Pandora is paying more and more for it's music licensing as it adds additional free users. At some point in the future these variable costs will rise above the amount of money the company makes from advertising and subscription fees and the company will have to convert as much of its existing user base to the premium service as it is able to do so. Its ability to convert existing users to the premium only service will determine the company's ultimate success or failure (Pandora Media 6).
Additionally Pandora has never had a year where it has made a profit, and it has accumulated a lot of debt from losing money every year of operation. It would take years of profitability before it could do more than just pay off its backlog of debt (Pandora Media 15).
There has never been a business like what Pandora is attempting to do on the Internet. The business model is unproven. A traditional radio station has decades of experience that investors could relate to in order to evaluate how well the company is doing (Pandora Media 6).
So based on these three key facts, I would not recommend purchasing stock in Pandora.

Works Cited.
Cornell.edu. Freemium Services in Terms of Network Effects. 11 Feb 2013. Web. 16 Nov. 2011. <http://blogs.cornell.edu/info2040/2011/11/16/freemium-services-in-terms-of-network-effects/>.
Glaser, William T. Consumer item matching method and system. Google Patents. 10 Feb. 2013. Web. 21 Feb. 2006. <http://www.google.com/patents?id=LI54AAAAEBAJ&dq=7,003,515>.
Investopedia.com 10 Feb. 2013. Web. <http://www.investopedia.com/terms/v/valueproposition.asp>.
Laudon et al. Kenneth C., and Traver, Carol, Guercio. E-commerce 2012. Pearson Prentice Hall. 2012.
Pandora Media, Inc. Security and Exchange Commission. Prospectus. 2011.
Pandora.com. About. 10 Feb. 2013. Web. <http://www.pandora.com/about>.
Pandora.com. Music Genome Project. 10 Feb. 2013. Web. <http://www.pandora.com/about/mgp>.





Additional interview about the startup and evolution of Pandora:

Sunday, February 3, 2013

Where is My Jet Pack, Dammit!

When I was a young lad we didn't have flying cars and jet packs, but we knew it wouldn't be long before they were as affordable as our regular cars... Now we know we are never getting them. 
 I want my jet pack, Dammit!

Web server has valid certificate now.

When I installed the mod_ssl module to my AMI Linux server on Amazons EC2 cloud service a default key and crt was generated, but it was for the long Amazon host name that you could never use for a business.  

Now, this is just a learning site for school, so being a poor college kid I didn't want to fork out the cost of eating for a month to get a certificate.  I did a google search for top cheap ssl certificate providers and found this link: http://webdesign.about.com/od/ssl/tp/cheapest-ssl-certificates.htm   

I started at the free end of the list and began working my way up.  Luckily https://www.startssl.com/ was able to help me out and give me a free cert that is good for a year.   The directions here are: sign up, and follow the directions on their site to get a certificate and key and download it to your local directory.  Every certifying authority (CA) is different, you just have to follow their procedure, and if you are paying cash, they will walk you through the steps with live support.

I followed the directions, replied back to several emails they sent me to confirm I was real, and then downloaded the files it told me to download.  The one last step was to convert the ssl.key file to an ssl2.key file with this command:
openssl rsa -in ssl.key -out ssl2.key
You had to enter your password that you gave when you had them create the key and it created the ssl2.key without a password so that you can run it on a web site and not have to retype in the password at the console anytime the server or Apache starts or restarts.

I put everything I got from Startssl.com into a single directory I called webssl.  Then I scp'ed the directory over to my AMI box with this command:
scp -i TestingForClass.pem -r webssl  ec2-user@ec5-64-131-21-85.compute-9.amazonaws.com:~
That is all on one line.  Of course that is not the actual address to my server, you will have to put in your own  instance address to connect to your box. The -r is because I am copying a directory and the  colon tilda on the end is telling the server on the other side to put that directory into my /home/ec2-user/  folder.   And the -i is the same private key you use to connect to the box with ssh

The I ssh'ed into the box with:
ssh -i TestingForClass.pem ec2-user@ec5-64-131-21-85.compute-9.amazonaws.com

Time to setup SSL!

I backed up the  ssl.conf file to my home directory with this command:
cp /etc/httpd/conf.d/ssl.conf ~/ssl.conf
This is in case I blow it and need to fall back and punt and just put the original file back in place and think about what I am doing before I try again.  The most important thing about doing anything on a computer is being about to undo it before you get into too much trouble.
sudo vi /etc/httpd/conf.d/ssl.conf
Look for something that looks like:
#   Server Certificate:
# Point SSLCertificateFile at a PEM encoded certificate.  If
# the certificate is encrypted, then you will be prompted for a
# pass phrase.  Note that a kill -HUP will prompt again.  A new
# certificate can be generated using the genkey(1) command.
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
Comment out this last line and add a new line right below it that says this:
SSLCertificateFile /etc/pki/tls/certs/ServerName.crt




The section should now look like this:
#   Server Certificate:
# Point SSLCertificateFile at a PEM encoded certificate.  If
# the certificate is encrypted, then you will be prompted for a
# pass phrase.  Note that a kill -HUP will prompt again.  A new
# certificate can be generated using the genkey(1) command.
#SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateFile /etc/pki/tls/certs/grokthink.crt




Right below it is another section:
#   Server Private Key:
#   If the key is not combined with the certificate, use this
#   directive to point at the key file.  Keep in mind that if
#   you've both a RSA and a DSA private key you can configure
#   both in parallel (to also allow the use of DSA ciphers, etc.)
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
Comment out this last line and add a new line right below it that says this:
SSLCertificateKeyFile /etc/pki/tls/private/ServerName.key

The section should now look like this:

#   Server Private Key:
#   If the key is not combined with the certificate, use this
#   directive to point at the key file.  Keep in mind that if
#   you've both a RSA and a DSA private key you can configure
#   both in parallel (to also allow the use of DSA ciphers, etc.)
#SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
SSLCertificateKeyFile /etc/pki/tls/private/
ServerName.key

That is it!  Save and quit that.

Now that the server is configured to use the key, now we have to put the key into the right places:   

sudo cp ~/webssl/ssl2.key /etc/pki/tls/certs/ServerName.key
sudo cp ~/webssl/ssl.crt /etc/pki/tls/private/ServerName.crt
Now we want to make it so that those keys match the security of the other entries in that directory:
sudo chmod 700 /etc/pki/tls/certs/ServerName.key
sudo chmod 700 /etc/pki/tls/private/ServerName.crt
And finally restart the server.
sudo /etc/init.d/httpd restart
At this point I was able to do an https://ServerName/ and got a secure valid connection in both Firefox and Chrome browsers.

And we are done!

The only thing that concerns me is why there were additional files from the cert provider, we only needed the password removed ssl2.key and  the ssl.crt file to make this work.