Wednesday, July 8, 2015

Getting to know parallel programming

Parallel Programming was one of the interesting concepts I get to learn and try hands-on during my grad school in UPLB. The ability to do a task "shared" by multiple resources is surely handy when it comes to finishing large tasks in a limited amount of time. One of the things we had to do was sorting (descending or ascending) a set of random numbers by first creating a bitonic sort. It runs really fast and can be done using MPI, specifically, mpich2. Here's the content of the paper I did for the exercise:

 Bitonic Description:

Bitonic sorting is a divide-and-conquer strategy which utilizes a comparator network Bitonic sort to produce the bitonic sequence and the Bitonic merge to produce the sorted sequence.[1]

Elements are rearranged into a bitonic sequence first before finally producing the sorted sequence. A bitonic sequence is a sequence which monotonically increases then monotonically decreases.  The split of the input into these two bitonic sequences is called the bitonic split. Afterwhich, recursive bitonic splits in shorter sequences are done(bitonic merge)  until the subsequence is of size one. This will then produce the sorted sequence, monotonically increasing. [2] 

 The bitonic sort runs in O(n log 2 n) on a serial computer but runs only O(log 2 n) in parallel.[2]

Algorithm:
 1.       In the main function, the values to be sorted are stored in a one-dimensional array, arrayNum[]

2. Setup the MPI variables: process_rank, num_processes and call the necessary MPI functions:     MPI_Init(&argc, &argv);   MPI_Comm_size(MPI_COMM_WORLD, &num_processes); and     MPI_Comm_rank(MPI_COMM_WORLD, &process_rank);

3.  for i=0 to dimension size  {
   for j=i  to 0 {
      bit1 = get the (i+1)th bit of the process_rank  and do binary operation & with 1
      bit2 = get the jth bit of the process_rank  and do binary operation & with 1
      compare bit1 and bit2
         if bit and bit2 are equal
          call compare_exchange_min(…) and store returned value to retrieve
        else
          call compare_exchange_max(…) and store returned value to retrieve
  arrayNum[process_rank] = retrieve;   
    }
}

4.    print the value of the array to verify sorted values
          
      5.  In compare_exchange_min():
Exchange values with its partner process number by calling MPI_Send() then MPI_Receive


Sample Run with 16 input elements:

Input:
 arrayNum[16] = {95, 90, 3, 8,  9, 23, 18, 40, 12,  0, 60, 5, 10, 14, 20, 35};
The array elements are in bitonic sequence at 5th iteration: 
Pass 5:  arrayNum[16] = {3, 8, 9, 18,  23, 40, 90, 95, 60,  35, 20,  14,  12, 10, 5, 0};

Output:
arrayNum[16] = {0, 3, 3, 8, 9, 23, 18, 40, 12,  0, 60,  5, 10, 14, 20, 35};

The actual code can be found in my github repo:                     https://github.com/ashlynkim/academe/blob/test/bitonic_sort.c

The figure below shows the process of the Bitonic Build followed by the Bitonic Merging using the test case used in the experiment.  The Bitonic Build will output the elements in bitonic sequence (increasing to decreasing values). The bitonic merge will output the sorted sequence (increasing values).




References:
[1] Lang, H.W. Bitonic Sort. http://www.iti.fh-flensburg.de/lang/algorithmen/sortieren/bitonic/bitonicen.htm Last updated: 05/18/2010                         
[2] Grama, Ananth, Anshul Gupta, and George Karypis. Introduction to parallel computing: design and analysis of algorithms. Redwood City, CA: Benjamin/Cummings Publishing Company, 1994.
                                

Sunday, May 3, 2015

U-City in the Philippines

U-City or Ubiquitous City is one of the topics we tackled in class. Here's what I would envision a U-City in the Philippines would look like. (Credits to the images I copied and manipulated from Google)


This would probably take years to happen, if it does happen. Hopefully, during the advances we do in instilling IT in all aspects of living, there will still be a balance with the natural environment. Not only would it be a U-City but a Green City as well.

Thursday, March 5, 2015

Setting up Dynamic Web Project and Apache Tomcat 8 in Eclipse Luna

Eclipse Luna, surprisingly, has no Dynamic Web Project option in New  Project.
Here's the steps to add this option: 

Adding Dynamic Web Project

1. Open Help> Install New Software 


2. Under Work with: select the url for luna releases: http://download.eclipse.org/releases/luna
then filter by "web". Select the "Web, XML, Java EE and OSGi Enterprise Development



3. Click next and Agree to the terms. 

4. Check by going to File> Project >Web  you should find Dynamic Web Project




Setting up Apache Tomcat Server

Surprisingly, (again) the server runtime for tomcat is not initially installed. 

1. Follow the same procedure above but instead of writing "web" in no.2, look for "JST Server Adapters" and "JST Server Adapters Extensions" instead.

2. Install the two and check by Adding new server at the Server tab below the Eclipse screen: 

3. Choose whatever Tomcat you have installed. 

Note: Tomcat must already be unzipped to a directory in your computer: 
ex. "C:\apache-tomcat-8.0.20"

Settings for Tomcat: 

1.Double-click on the tomcat server. It should be stopped before performing any changes on the settings.

2. Change the deploy path from "wtpwebapps" to "webapps"



Sunday, March 1, 2015

What makes e-commerce sites successful?

How 'bout some strategy? Here's some observable methods how companies use e-commerce to their advantage.

Company: Dell - One of the leading manufacturers of computers. 
Website: http://www.dell.com/


What they got: 
1. A service called "We will match it".
- They will be able to match the price to whatever deal you came across with. There are certain terms and conditions but the thought that you can bargain with your purchase because another has it with a cheaper price makes online transacting with Dell, well, a bit more human.
I quote "If you find a lower-price advertised on the internet for an identical electronic product (except contract mobile phones) or a similarly configured Dell, HP or Lenovo, computer; Dell will match that price.*"
2. Their emphasis on Support    
- Front page of the site has this word multiple times. They offer hardware and their services as a package. This only shows how customer-oriented they are. 
3. Product Features and Promos
- Similar to any product-based company, they encourage users to see the latest products by having them on the front page. They also allow promotions or deals on some products as well as offer coupons for a limited time.
4. Localization
- Having a custom website for a specific country is a good strategy to be able to reach out to people. Customers who wishes to see the products available immediately, (minus the time of shipping for global stores) would prefer looking at a local websites for possibly two reasons; one, the products in the local site would probably mean in-stock products (less waiting time for deliveries) and two, the language.

Company: Facebook 
Website: https://www.facebook.com/


What they got: 
1. Venue for advertising
- Being a social network, its much easier to reach out to a wider audience with Facebook. And Facebook knows it! Which is why the concept of Facebook Pages was born. Giving companies a chance to advertise themselves creating their own pages which in turn brings in the ads that do add revenue to the company
2. Facebook Ads
- Companies such as Yahoo!, airbnb.com, and many more are now embedding their own links in Facebook. I don't really know how much you pay for an ad but there are sure a lot of them now in Facebook. 
3. Customization
- Every wonder why you get ads of particular category especially after liking some of them? Facebook customizes the way ads are being brought to your page by taking advantage of the preferences you have saved in the website. One example would be if you liked an ad of a coffee brand, there will be more ads of coffee popping in your page. Or if you read yahoo news by clicking on the links, it will show you yahoo news more often. In this way, you will likely check out the ads of other brands or related brands.

Company: alibaba.com
Website: http://www.alibaba.com/


What they got:
1. Specific Goals
- Their goal can be immediately perceived from their "About Us" link. They want to serve as the global marketplace for traders and consumers. They not only use B2C but also B2Bas well. The following are the noteworthy goals:
   a. Be the future infrastructure of e-commerce where all merchants and customers meet
   b. Expand their products and customers (From the looks of it they already have from the merchants selling from India, US, China, and many more)
   c. Live up to 102 years.
2. Training
 - Aside from serving as the platform, they also offer trainings for merchants who wish to take full advantage of the site
3. Easy to navigate site
- Given the number of services and products the site has to feature/advertise, they used categories for easier searching. They also have a means of getting quotations for similar products from different merchants. Also, you can directly communicate with the merchant for inquiries.

Company: Samsung
Website: http://www.samsung.com/ph/home


What they got:
1. Graphic-Heavy Site
- This is quite important for a company who boasts on great picture resolutions on televisions, mobile screens and cameras. Their website must immediately reflect on what their product is all about
2. Previews and Teasers
- They have teasers on their latest products, a video or a "something-to-look-forward-to" type of ads that will grow the users curiousity.
3. Considering lifestyle
- They offer products for different kind of consumers, such as specific products with features that will be helpful for a businessman or for a student.
4. Product comparison
- A compare feature which allows comparing two products with different specifications is included in the site.
Speaking of strategy... how can a blog earn?



Couple of things have turned up on how to earn using your blog:
1. Ads - yes tried and tested but is pretty much passive. This can be taken from PPC (Pay-Per-Click) like Google AdSense or  CPM ads (Cost-Per-Thousand Impression) like Tribal Fusion.
2. Sell - use your blog to sell a service or a product.

Thursday, February 26, 2015

What's this Firefox ad doing in Yahoo?

I was reading the Yahoo! news this morning when I noticed something odd at the far upper right side of my browser. yep, it definitely said "Upgrade to the new Firefox."



That got me stumped! I always thought Mozilla to be a Google partner.  hmmm..
My curiosity got the best of me and finally led me to this article.

"Firefox users in the US will now see Yahoo as their default browser, but Google may have allowed itself to be outbid" 

Having read that, I opened the Firefox browser immediately and was expecting to see the Yahoo! search engine as the default. I'm not sure if it is in the more recent Firefox versions but mines was ver. 35.0.1. I opened the options button to check and Google was still the priority search engine. (The article did mention it would be applied in the US, China and Russia). Probably will eventually happen in the newer versions.

Search engine is not obvious here
Yep! It's still Google


And because of that, I got three takeaways from the article I read.

1. Firefox was no longer the no. 1 browser. Chrome is.



2. "Google was paying 0.3 cents per Firefox search." Wow!

3. Firefox doesn't show up in the top nine browsers for mobile and I found myself saying, that's true! My smartphone don't have Firefox. Or.. maybe it's in the tenth spot.. :)


 As for the Firefox ad in the Yahoo! site? Must be a prep for Mozilla-Yahoo relationship. Just saying.

Wednesday, February 25, 2015

Before there was Facebook..

I guess I could start with the title.

 Before there was Facebook..

1. People meet people (in person)
    Lots of people do meet eye-to-eye and get to talk, real talk, with the other person. Sure, yeah, you get to meet more people in Facebook but seriously, how many of them have you had a good chat online?

http://www.hearinglikeme.com/sites/default/files/pictures/cafe.jpg

2. Spoken words and body language were used more often
    The mouth was undoubtedly needed in conversations for people to express themselves. Also, looking at another person's body language allowed people to really know what a person is saying. Can you tell if a person is really okay just by the person's status in Facebook as "I'm okay" ?

http://www.oral.fi/

3. It was noisier
    An after-effect of no.2, yes, there were much more noise in cafes and restaurants than the predominant click-clicking nowadays.

http://vanishingnewyork.blogspot.com/2010/09/10th-and-greenwich.html

4. Photos were printed
    Photo album sales must be non-existent now, if not really low . You would take a photo to be printed or shown to other people when you meet but now all they have to do is find it in your Facebook wall.

http://www.thirtyone.ph/2014/02/moments-album.html

5. The only time you see a thumbs-up is when you form it using a hand
    Thumbs-up still had the same meaning then and now but it must be one of the biggest trademark of Facebook that even surpassed the social network. Ate at McDonalds.. Like! Going trekking.. Like! Had a leg injury :(... Like!

http://previews.123rf.com/images/piksel/piksel1306

6. It was harder to stalk someone
   Pro or con, it was harder to track a person's activities without Facebook, or any social media. Given, of course, the person do post his/her activities in Facebook. Now, you don't have to hire a Private investigator, you can do all the snooping yourself.

www.today.com
vs.

Given that, I'm sure there are a lot more  I haven't mentioned. If you do have one or more in mind, do write them in the comment box below and I would love to hear 'em.

Tuesday, February 3, 2015

Examples of E-commerce business model

There are different business models out there and here are three sites which I have briefly described according to the categories listed in class according to different markets:


website: www.amazon.com 
(Transactional e-commerce site)


site objective: Online shopping mall with shipping services

site definition: It is a platform used by consumers to post items to sell which other customers can readily avail by paying online and have the items delivered to them.
target customers: All customers able to purchase online.
target site/goal and site design/contents appropriacy: The design of the website is fit to the need for fast searching of items. The products have pictures for added description, user feedbacks and the very useful virtual shopping cart.

website: www.toyota.com 
(Brand building site)





site objective: Leveraging products by featuring the existing products and providing customers the capability to customize their own car design

site definition: The site provides information about the different available cars and estimate retail price. It also has a list of available car parts, services and careers. The site also provides customer service for questions, comments or requests. 
target customers: Car lovers
target site/goal and site design/contents appropriacy: The site must be able to handle good pictures and load them really fast which is what the site does. It has a simple layout to not overwhelm the customer with information. 


website: www.yahoo.com
(Portal, publisher or media sites) 


site objective: One-stop site for information globally and locally.  
site definition: Yahoo is a site that captures news, stories locally and around the globe. It provides relevant local news to different people depending on location of users. For example, if the user is found to be in the Philippines, the user has an option to be provided with news primarily from the Philippines. In addition, it also is an email provider.
target customers: People who loves information
target site/goal and site design/contents appropriacy: The site is enabled for fast loading of large amount of pictures and text. The slide-sorter format at the front page which is like a feature gallery widget is a good way to recommend the most recent posts. The links to categories are also conveniently placed in front for easier access. There is also added statistical information such as trending topics and popular videos.

Other sites under other categories:
1. Transactional e-commerce site
   - www.gossard.com
   - www.thomascook.com
   - www.amazon.com

2. Service-oriented relationship-building websites
   - www.silicon.in
   - www.pcsglobal.in
   - www.accenture.com

3. Brand building site
   - www.hsbc.com
   - www.tango.com
   - www.guinness.com
   - www.vauxhall.com

4. Portal, publisher or media site
   - www.yahoo.com