Saturday 7 December 2013

An investigation regarding the effects of NoSQL on the four inherent problems of Software Engineering

So as you all know, I am currently in my final year of BEng (Hons) Software Engineering. In my final year, one of the courses that I am studying is Programming Frameworks. This course introduces to the academic side of Software Engineering and covers topics like quality plans, quality control, advanced methodologies, planning, frameworks etc.

My coursework for this course was to prepare a quality plan for writing an academic paper and then write the academic paper. The main topic of the academic paper was to compare and contrast one of the three concepts with an academic paper "No Silver Bullet - Essence and Accidents of Software Engineering" written by Fred Brooks. I prepared the quality plan, wrote the academic paper and submitted the coursework last month. I received a really good mark for it - 88% and thus I thought that I should share the academic paper that I wrote in LaTeX. You can download the academic paper from here.
Let me know what you think about the paper in the comments below.

Thursday 17 October 2013

What to do when app downloads in Windows 8/8.1 store get stuck at "Pending" or "Downloading" stage?

So I had this problem today. Well to be honest, I had this problem before as well but I decided to fix it today. Earlier today, I upgraded to Windows 8.1 and I was hoping that the upgrade would resolve this problem. Well, it didn't. After surfing through the web, I found the solution. So, here it goes:

First of all, you need to be in safe mode. Open the charms bar, click on the power button, hold the shift key and while you're holding it, click "Restart". This will restart Windows in troubleshooting/recovery mode.

From the menu that has been presented to you, click "Troubleshoot". Now select "Advanced options" and from the subsequent screen click "Windows Startup settings". Finally, click "Restart" button.

Now, if you have Windows 8 installed, you will have an old command prompt styled menu from which you can select "Safe Mode with Networking" by pressing navigational arrow keys. However, if you have Windows 8.1, then you will have to press number 5 key on your keyboard to go into "Safe Mode with Networking". Once you're there, fire up command prompt. Type in:
cd %systemroot%

Then type:
ren SoftwareDistribution SoftwareDistribution.old

That's it. Restart the computer by using the charms menu. This time, don't hold down the shift key.

When Windows normally boots up, open the store, wait a few seconds and try updating/downloading apps and it should work just fine.

Friday 27 September 2013

Changing keyboard layout in Ubuntu Server (Linux, How to)

So I recently installed Ubuntu Server in a virtual machine and I had problems with my keyboard layout. I use UK layout while the default that comes with Ubuntu Server is US layout. As you can imagine, this caused problems and I had to go hunt for a solution. Finally, I found one and here it is:

You need to reconfigure keyboard configuration. Type the following:
sudo dpkg-reconfigure keyboard-configuration

If that doesn't work, you might need to install console-data package. Install it by typing:
sudo apt-get install console-data

and then try first step again.

If everything was fine, you should see this:
Using this you can select brand of your keyboard. I am running this virtual machine on my Acer laptop and as you can see it is listed there. You can use up/down/page up/page down keys to navigate through the list. When you have picked one, press enter to go to next screen.

You should now see this:
This is the language selection screen. Navigate through the list, select your language and as you did in previous one, press enter to move on to next screen.

This is the screen where you select your keyboard type:
Assuming you're using a qwerty keyboard for PC, you should just leave the first one selected and press enter. However, if you are running this on a mac or your keyboard is of different kind, you are free to choose whatever applies to you from the list and continue by pressing enter.

The next screen allows you to map a key on your keyboard to alternate grammar key (Alt Gr).
I have never used this key in my life for alternate grammar, however, hoping that I may use it at some point, I would map it to right-alt key (which actually is Alt Gr key). As usual, select one from the list and press enter.

Next one is compose key. Same drill. Pick one and press enter:
Compose key, if I remember correctly, allows you to type ASCII for certain characters when you press and hold it. This key on windows is left alt key however, here you can choose whatever you want for ubuntu server.

When you press enter, the wizard will quit. So that was the keyboard configuration screen which allows you to configure your keyboard pretty neatly. Have fun!

Saturday 14 September 2013

Assigning static IP address to your Raspberry Pi (WiFi)

When I first bought my Raspberry Pi, I had this problem. My router and TV are in different rooms and I don't have a ethernet cable. This restricts networking ability of my Pi which is quite annoying. I searched for articles on assigning static IP addresses to Raspberry Pi but most of them were talking about assigning it for eth0. I, on the other hand wanted wlan0 static IP.

Now, I could have just got a long ethernet cable and solve this whole problem but I was just annoyed and was constantly asking myself "Why isn't this working over wifi". So finally, after significant digging around, I found the solution. Here it goes:

First of all, take a backup of /etc/network/interfaces file:
pi@raspberrypi ~ $ sudo su -
root@raspberrypi:~# cp /etc/network/interfaces .


Now, in order to make this work, we need some information first. We need to find out the new static ip address that you want, gateway, mask, network and broadcast address. Assuming that you have a working wifi connection on your Raspberry Pi, type:
root@raspberrypi:~# ifconfig

From the output, the bit that we are interested in is:
wlan0     Link encap:Ethernet  HWaddr 00:00:00:00:00:00
          inet addr:192.168.1.99  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:19153 errors:0 dropped:24512 overruns:0 frame:0
          TX packets:25553 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3724822 (3.5 MiB)  TX bytes:31437802 (29.9 MiB)


The highlighted line will give you information about your current IP, broadcast and mask address. Take a note of the last two. So, in my case:
address: (this is the IP address you wish to reserve as static eg. 192.168.1.69)
mask: 255.255.255.0
broadcast: 192.168.1.255

To find out information about the last two bits, type:
root@raspberrypi:~# netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 wlan0
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 wlan0


In my case:
gateway: 192.168.1.1
network (a.k.a destination): 192.168.1.0

Now that we have all the information that we need, edit the /etc/network/interfaces file using nano. Putting all the bits and pieces together, it should look like:

Press Ctrl + O to save.
Now, since I was doing this whole process over SSH, I had to write a script to restart wifi because if I didn't, as soon as I turn it off, it would also take away my SSH access rendering me powerless. You can do the following in either case. Create a new file called restartwifi.sh using nano in root home directory:
root@raspberrypi:~# nano restartwifi.sh

Now, I am aware that this script can be improved but this is what I had before and it has worked without any problems. Press Ctrl + O to save the script. Then press Ctrl + X to exit.

Make sure you edit permissions to make the script executable. Run:
root@raspberrypi:~# chmod +x restartwifi.sh

If you're not root, you'll have to prefix above command with "sudo". 

Now comes the moment of truth. Run the script to reset your wifi by typing following command:
root@raspberrypi:~# nohup ./restartwifi.sh &

If you're in putty session, you'll immediately go offline. If you've done everything correctly, you should be able to ssh into your Pi, after couple of minutes, on your chosen IP address.

Wednesday 4 September 2013

How to fix the display issue where edges of your screen are cut off every time you connect your PC to a HDTV

So I have this problem every time I connect my laptop to my Samsung HDTV. I thought this was an issue with driver/video card but I wasn't convinced because I wanted a solution. Finally, today, I managed to find a solution for this. Here's how you can solve it:

Go to display driver settings. In my case, since my laptop has two graphics cards - Nvidia 640m and Intel HD 4000 and since the primary display driver is Intel, I went to Intel HD Graphics Control Panel.

Click on Display to view display settings.

Ensure that you have connected your computer to TV using a HDMI cable. If you have, you should see something like "Digital television SAMSUNG" in the combo box under Select Display. 

Make sure that you have selected "Display Settings" tab and "Basic" twisty has been expanded. Under "Scaling", select "Customize Aspect Ratio". In the preview section, you will see two bars (horizontal and vertical) appear. You can adjust the aspect ratio using those. As you can see from the screenshot below, 63 vertical and 65 horizontal works perfect for me. Once you're done experimenting, hit apply.

Additionally, you might want to save those settings under a different profile. You can click on save profile button to do that. Give it a meaningful name and you're done. That way, you can keep different profiles for different monitors/TVs.

Tuesday 3 September 2013

Google Now shows you bus times!

So today I learnt that Google Now can show you bus times. I think this is cool as a student using public transport.

Although, you have to be at or near the bus stop to view its times. It can pick that up from a calendar entry/email/search as well. It would've been  nice if I could search for a bus stop to view its times but as it turns out, you can't.

So I guess this isn't convincing enough to make me uninstall my bus checker app but it's a start.

Thursday 18 July 2013

Using find command to search for a particular directory in unix

I was looking for a particular directory today on my computer and I didn't know how to do it. After spending some time searching for it, I found the following command:

find [parent directory] -type d -name [directory name]

So in my case:

find /home/vader -type d -name wrapper_scripts

Optionally you can also use:

find /home/vader -type d | grep wrapper

Wednesday 26 June 2013

Controlling LED brightness using potentiometer and arduino

I was doing experiments with my Arduino today and this was one of them. I have commented the code well so it should be easy to understand. Here you go:
/*
SETUP
Connect led to analog pin 10, shorter end to ground.
Potentiometer setup:
(From left to right)
1. +5V
2. Analog pin 0 (A0)
3. Ground
*/

//Set LED pin to analog pin 10.
const int led_pin = 10;
//Set potentio meter pin to analog pin 0 (A0).
const int pot_met = 0;

void setup(){
  //Set led_pin to be the output.
  pinMode(led_pin,OUTPUT);
  //Initiate serial (optional).
  Serial.begin(9600);
}

void loop(){
  //Use the readPotentioMeterBrightness method to read brightness value.
  int sensor_val = readPotentioMeterBrightness();
  //Output the value to serial (optional).
  Serial.println(sensor_val);
  //Set LED brightness to value that we acquired from potentiometer.
  analogWrite(led_pin,sensor_val);
  //Pause for 250 ms.
  delay(250);
}

int readPotentioMeterBrightness(){
  //Read analog input and store value in integer variable val
  int val = analogRead(pot_met);
  //Adjust the value to be in range 0 to 255.
  val = map(val,0,1023,0,255);
  //Ensure value is between 0 and 255. 
  val = constrain(val,0,255);
  //Return value
  return val;
}

Thursday 20 June 2013

Copying symbolic links (UNIX/Linux)

At some point, you might come across a situation where you have some files and a bunch of symlinks (symbolic links) in a folder and you wish to copy the data that is pointed at by the symlinks and not just blank links. If you are using Redhat Enterprise Linux, this should automatically happen when you call the cp command. However, on UNIX platforms or Linux distributions, this is not the case by default. In those cases, you will have to issue the following command:

cp -L {file(s)} {destination folder}

The -L option in cp command forces it to follow (dereference) symlinks and copy the data that is pointed at by the symlink.

In case you do not want to follow symlinks, you can issue the following command instead:

cp -P {file(s)} {destination folder} 

Wednesday 19 June 2013

Mounting ISO images on linux

So I learnt this today and decided to share it with you guys. If you have an iso image and want to mount it on Linux, simply execute the following command in terminal:

sudo mount -o loop mydisk.iso myfoldername

So in my case, I had iso file called 2012photos.iso on my desktop and I wanted to mount it on folder called 2012pics which was on Desktop as well. I executed:

sudo mount -o loop /home/manthan/Desktop/2012photos.iso /home/manthan/Desktop/2012pics

Sunday 16 June 2013

The application was unable to start correctly (0xc000007b)

So I found this error when I started Lotus Notes this morning. After looking through some forums, I found that I needed to re-install Microsoft Visual C++ 2010 (Redistributable) from here.

This error is usually caused by C:\Windows\System32\MSVCR100.dll being corrupted. Reinstalling VC++  fixes it.

Saturday 11 May 2013

Managing password expiry for a user account (Unix/Linux)

I find this very useful on several occasions so here we go. Login as root and execute the following:
passwd -x -1

So if you want to remove password expiry from bob's account, type:
passwd -x -1 bob

Notice that -1 parameter after -x represents number of days before the password expires. Since we do not want the password to expire, we have set it to -1. However, you can set it to any value you want. So, if you want your password to expire after 90 days (i.e. 3 months) for bob's account, type:
passwd -x 90 bob

Tuesday 7 May 2013

Checking memory (RAM) size on Solaris

If you want to check how much RAM your Solaris machine has, here's how:
/usr/sbin/prtdiag -v | grep -i memory

You can also try:
/usr/sbin/prtconf | grep -i memory

Friday 3 May 2013

Writing Code - Building a chat application in Java - Session 1


Hey Guys! In this series, we will be building a chat application in java. I think this will be a great chance for you all guys out there wanting to do something hands on in Java.

Thursday 2 May 2013

Removing password expiry from your unix machine (Linux and Solaris)

Here's a quick one. If you have a server and you do not want the password for a user to expire (as it can screw some things up while its active), you need to execute the following commands as root:

passwd -x -1

where is the username whose password expiry you wish to remove. For instance, in my case, if username is dm014, I executed:

passwd -x -1 dm014

I have tested this and it works flawlessly on linux and solaris.

Wednesday 1 May 2013

Compiling C++ easily on Linux (Easy C++ build system)

I was developing some C++ stuff on my Linux virtual machine and wanted to create something that would make it easy for me to compile C++ code. So I wrote up some bash code and added it into .bashrc as a function. Here's the code:

function cpprun(){
        echo "Checking if output directory exists..."
        if [ ! -d "./output" ]; then
                echo "Creating output directory..."
                mkdir "./output"
                echo "Output directory created."
        elif [ -f "./output/cpprun.o" ]; then
                echo "Backing up previous output..."
                mv ./output/cpprun.o ./output/cpprun.bak.o
                echo "Backup finished."
        fi

        echo "Running g++ compile..."
        g++ -o ./output/cpprun.o *.cpp
        if [ -f "./output/cpprun.o" ]; then
                echo "Compile finished."
                echo "Running output..."
                echo "-----------------"
                ./output/cpprun.o
                echo "-----------------"
                echo "Run finished."
        else
                echo "Compile failed."
        fi
}


Add this to your .bashrc script and then you should be able to compile your C++ code by typing cpprun in the base directory.

Saturday 20 April 2013

Changing mysql username and password used by phpmyadmin

So, I had to do this the other day and I got a bit confused. After poking around a bit, I finally found it. If you have xampp installed, go to the install directory. In my case, this directory is C:\xampp which is the default directory. Locate the phpmyadmin folder and open it. Locate the config.inc.php file within the phpmyadmin folder. Open up the file. You need to make change in the following two lines:

$cfg['Servers'][$i]['user'] = 'root'; 
$cfg['Servers'][$i]['password'] = 'password'

The underlined parts are the ones that you've got to change. This file contains a lot of admin stuff so make sure you look around a bit and understand what it does.

If you don't know what you are doing, ensure you take a backup of the file before changing things.

Sunday 14 April 2013

How to prevent class redefinition errors in C++

I have just started learning C++ and have been getting a lot of these errors. I finally found a solution to this after spending some time on the internet.

Say for instance you have a class called "Animal" and g++ complains that this class is being redefined. Just add the following two lines at the very top of the Animal.h file:
#ifndef ANIMAL_H
#define ANIMAL_H


and add the following at the very bottom of the file:
#endif

So, if your class is called SomeClass, then it will be SOMECLASS_H instead of ANIMAL_H. You should have these in every header file. It prevents that header file from being redefined more than once.

Saturday 13 April 2013

How to tell which Linux partition a directory is on?

This is really simple. First of all, you need to know the full path to that directory. "cd" into that directory and type:
pwd

and it will display full path of the directory you are in. Remember that or even better, copy it to the clipboard. Type the following command to know the name of the partition:
df

where replace with the full path of your directory. This in my case becomes "df /data/android/sample".

If you are already in the directory, you can type "df ." and it will give details about the partition you are currently on.

The output should be something like:

Filesystem    1024-blocks      Free %Used    Iused %Iused Mounted on
 /dev/hd4            32768     16016   52%     2271    14% /


The highlighted part is the name of your partition.

Saturday 12 January 2013

Pizza Ordering System source (Session 2)

Hey Guys! Thanks for watching my video. In case you haven't, the video is down below:



I hope the video as helpful to you. Please comment below the video or this post for any suggestions/queries. You can download the source code by following the link below:
https://www.box.com/s/civvyq1d2wzz69xydqi4