Install Visual Studio 2012 on Mac (Boot Camp)

After struggling for almost a week to install Visual Studio 2012 on Windows 8, via Boot Camp, I finally found the reason why my computer froze whenever I tried to install Visual Studio.

Here are the steps you should do:

  1. Update Windows 8. You have to install ALL the latest updates.
  2. Install Visual Studio 2012.

This way your installation should go smooth. If you have any questions, please leave a comment.

Euler’s Sieve: Prime numbers generator

Here’s a very simple algorithm that generates a list of all random numbers up to “n.” You just pass it an bool array of size “n+1″ and “n” itself. The algorithm marks elements with prime indices in the array as true, and sets the rest to false.

void euler_sieve(int n, bool *a) {
	// Initialize the array
        a[0] = false;
        a[1] = false;
	for (int i = 2; i <= n; i++) {
		a[i] = true;
	for (int i = 2; i <= n/2; i++) {
		/* If the current elements is prime, 
		 * mark all its multiples as not prime
		if (a[i]) { 
			for (int j = i + i; j <= n; j += i) {
				a[j] = false;

UVA 100: The 3n+1 problem

Here’s my C++ code:

// This program computes the maximum cycle length over all numbers between i and j.


using namespace std;

int cycle_length(int);

int main() {
	int a, b, temp; //The 2 numbers and a temp slot for swapping
	int max = 0; //Maximum cycle length
	int length; //Cycle length of the current number
	stringstream ss; //String stream acts as a buffer to write the output to
	bool swapped = false; //A, B swap flag

	// For every pair of numbers compute the maximum cycle length over all numbers between i and j
	while(cin >> a >> b) {
		if(a > b) { // If a < b, swap them
			temp = a;
			a = b;
			b = temp;
			swapped = true;

		for(int i = a; i <= b; i++) { // For each number in the range calculate its cycle length
			length = cycle_length(i);

			if(length > max) //New max length encountered
				max = length;

		if(swapped) {
			ss << b << " " << a << " " << max << endl;
			swapped = false;
		} else
			ss << a << " " << b << " " << max << endl;

		max = 0; //Reset the max

	cout << ss.str();

	return 0;

int cycle_length(int num) { //Calculates the cycle length of num
	int len = 1;

	while(num != 1) {
		if(num%2 == 0) //If even, double
			num /= 2;
		else //If odd multiply by 3 and add 1
			num = num *3 + 1;


	return len;

[Java] Add background music to JFrame

You can call this method to play loop-able background music. Don’t forget to change the path to the wav file. I’ve to warn you, only WAV files work!


        public void startBGMusic() { //Plays the background music
            //make a new AudioPlayer.
              AudioPlayer myBackgroundPlayer = AudioPlayer.player;

              ContinuousAudioDataStream myLoop = null;
  			//use a try block in case the file doesn't exist.
              try {
              AudioStream myBackgroundMusic = new AudioStream(new FileInputStream(new File(getClass().getResource(
              AudioData myData = myBackgroundMusic.getData();
              myLoop = new ContinuousAudioDataStream(myData);
              catch(Exception error) {JOptionPane.showMessageDialog(null, "Invalid file!");}

              // play background music.

Selection Sort Algorithm

Although it may not be the best array sorting algorithm, it’s good enough to sort small arrays. Here’s my implementation of the algorithm in C++ :

void selectionSort(int a[], int length)
    //Three variables that will be used later
    int min, minAt, temp;

    for (int i = 0; i < length-1; i++) //Outer loop to go through the passes
        //Suppose that the first element is the minimum
        min = a[i];
        minAt = i;

        for (int j = i+1; j < length; j++) //Inner loop to go through the elements in each pass. Notice that we don’t touch previously processed elements
            //If an element smaller than the minimum is encountered, then set the minimum to be equal to that element
            if (min > a[j])
                min = a[j];
                minAt = j;

        //Finally swap the current element with the minimum that was found
        temp = a[i];
        a[i] = a[minAt];
        a[minAt] = temp;


If you are studying CS and you don’t know what ACM is, then you’re missing a lot. ACM ICPC is the Associate for Computer Machinery’s International Collegiate Programming Contest. The older guys want to recruit more members to form new teams. If you’re interested, don’t miss the chance and contact them ASAP.

Blackberry Curve 8520 Review

A few days ago, I purchased a Blackberry Curve 8520 from a Vodafone store. At the first look, the phone was glamorous and feature-rich; however, after test driving it for a short time, I have to admit that it also has downsides. In this entry I’m going to be covering the ups and downs of this brand new smart phone.

The phone has a black sleek look that makes you fall in love with it from the first glance; however, this isn’t everything amazing about it. I find the phone loaded with features that I’ve never seen in any other mobile phone. For example, you can associate your contacts with their Facebook profiles. This feature will amaze you if you’re one of those people who can’t live without social networks. Another great feature of the phone is its customizability. You can control almost each and every feature the phone has to offer (save for a few that we’ll discuss later). For example, you can set the alert tone for the Windows live messenger, another one for the ICQ messenger, and so on. The themes are also very customizable. Unlike other mobile phones, the Blackberry gives you the ability to add widgets to the home screen to suit your needs. For example, I like to have my RSS feeds on the Desktop, so I plan to write a Java widget for that (yes, it’s that easy. The Java API is amazing!).

One more feature that I like about this phone, is its App World. This is similar to the App Store in the iPhone and the OVI store in Nokia phones. The App World has a wide selection of free and paid applications. There are applications like the facebook application and the MSN messenger that are not available on any other mobile phone with all these features. Those special applications will bring the whole world into your pocket!

The phone has great media capabilities. Actually I prefer its music player over Nokia’s player. It looks more like the iPod music player, which I like. The phone’s 512MHz processor and 256MB RAM maintains smooth video playback. This allows you to view all your favorite videos at high frame rates.

Nothing comes without cons, and this phone is no exception. Actually there are trio of things that I don’t like about this phone. The first one is that you can’t use a WIFI connection without that data service turned on. This means that even if you won’t use the EDGE or GPRS connection, Vodafone will still charge you because you have the data service enabled. Another feature that I don’t like is that a lot of applications don’t work over WIFI. This accumulates unnecessary bandwidth usage on your bill; however, you can still find alternatives to these applications that work well over WIFI. The last thing I hate about this device is tat RIM, that company that makes it, doesn’t offer a Desktop manager for Linux. They only offer it for Windows and Mac. It’s quite an awful thing, yet I’ll have to get a long with it.

In a conclusion, the Blackberry Curve is a great PDA with Push email capabilities that will allow you to about everything with the push of a button.

Windows 7 SuperMode!

Want a single Control Panel that controls each and every thing in your windows 7? Very easy, just make a new folder anywhere and name it “GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}” (without the commas). Now you have an all in one control panel that enables you to control all features from a single place.