Assigning Static IP Address on Ubuntu Using Command Line

I had to manually set the IP address of my Ubuntu installation. However, I didn’t install GNOME which should have provided the graphical interface.

To assign a static IP address using the command line, do the following. Edit the /etc/network/interfaces file.

sudo nano /etc/network/interfaces

Look for the interface you want to configure. In my case, I want to set eth0. Currently, it is configured to use dhcp. Change the dhcp to static. Afterwards, provide the necessary information.

iface eth0 inet static
	address 192.168.1.2
	netmask 255.255.255.0
	gateway 192.168.1.1
	dns-nameservers 208.67.220.220 208.67.222.222

The address is the IP address you want to assign to the interface. The netmask is the network mask of the IP address. The gateway is the IP address of the gateway. Usually, this is the IP address of the router. The dns-nameservers is the IP address of the DNS resolver. If you have more than one address, just separate them with a space. Continue reading

Fixing Invalid Environment Block of GRUB

My headless Ubuntu Server suddenly stopped working. It turned out that the boot up process got stuck with an error message of Error: Invalid Environment Block.

I was able to continue with the boot process by just pressing any key. I logged into the system and issued the following commands. Make sure you are root or you can just append sudo prior to each command.

cd /boot/grub
rm grubenv
grub-editenv grubenv create
grub-editenv grubenv set default=0
grub-editenv grubenv list
default=0

The solution was from this website.

Just to be sure, I just had to recreate the GRUB menu.

sudo update-grub

That’s it. Try rebooting the system.

Generating QR Code in Ubuntu

If you want to generate QR (Quick Response) codes in Ubuntu, you need to install the qrencode package.

sudo apt-get install qrencode

After the installation, you can use the command line to generate QR codes. It produces PNG files which contains the code.

qrencode -o output.png "Your text goes here"

This is the output of the statement above:

output

However, if you want to scale the size of the image, you can use the -s option. Continue reading

Python Network Sub-Netting Calculator

I had an assignment in my Computer Networks class. It involves sub-netting. Instead of solving everything manually, I opted to write a Python script to automate the process for me.

The idea here is just to take a network address and the prefix of the network. It will check first if the network address is valid. If it is not, it identifies the correct network address and begins the operation there.

I implemented my Network class using Python. It encapsulates all the needed methods.  Continue reading

Converting String to Integer in C++

If you want to convert a string data to an int in C++, you can use the atoi() function. This function is defined under the cstdlib library for C++.

#include <iostream>
#include <cstdlib>

using namespace std;

int main(void) {
	string data;
	int year;

	cout << "Enter birth year: ";
	cin >> data;

	year = atoi(data.c_str());

	cout << "Age is: " << (2014-year) << endl;

	return 0;
}

The assumption is that, of course, data can be converted into an integer. The c_str() method of the string object converts the string into an array of characters.

There are other functions that you can use to convert from string to float or long. Read more here.

I read something about the stoi() function but when I tried it, it did not work. According to forums, it has something to do with the MinGW compiler wherein you have to patch it.

Automatically Formatting Reference to ACM Style in Microsoft Word

If you don’t want to do the bibliography of your paper manually, you can let Microsoft Word do the formatting for you. The assumption here is that you have the BibTeX source of the citation of a reference material.

Installing Reference Manager

What I use to manage all my references is JabRef. It is a free reference manager that you can use. Download it here. Install it on your system afterwards.

Adding Reference to Database

Google Scholar and other online digital libraries have the feature that allows you to copy the BibTeX source in citing the document. For example, in Google Scholar:

search

Click on the Cite link below the search result. Continue reading

Samsung Galaxy Note 10.1 (2012 Edition) — N8000 4.4.2 KitKat Upgrade

I own a Samsung Galaxy  Note 10.1 (2012 edition) which is 3G and WiFi enabled. I was able to update it to KitKat. I live in the Phlippines and my device is not locked to any mobile networks.

Here are some screenshots:

2014-06-16 19.37.08

It was a really big update file. It was around 800 MB and it took me around 3 hours to finish downloading. Or maybe my Internet speed was just crappy?

2014-06-16 23.07.06

After downloading the file, I was prompted if I wanted to install the update. Continue reading

Measurement of Effectiveness of a Queuing System

We discussed this in our Computer Modelling and Simulations class.

Assuming we have a Burger restaurant and we want to identify how many servers will be needed to accommodate all the customers.

This Measurement of Effectiveness (MOE) provides a detailed information about the probability of having a queue, the probability of how many customers will have to wait and the utilization factor.

The following code seeks to identify the most optimal (cheapest) number of servers for a system that has a queue.

To be able to compute for the total cost for a particular number of server, the waiting cost and the service cost should be identified. The waiting cost is the opportunity cost of losing a customer per time period per unit. The service cost is the cost per time period for each server. Continue reading