Skip to content

Writing a Calculator Program Using Bison and Flex


We had a laboratory exercise in my Automata class. I just want post my solution to the problem. Here are the instructions:

You must have bison and flex installed on your system. I recommend that your environment is Ubuntu since it has the  make program.

Write a calculator program that allows the use of real number constants, variable names consisting of one-to-two letters followed by zero-to-two digits.

The operations allowed are:

  • + (add)
  • - (subtract)
  • - (negate)
  • * (multiply)
  • / (divide)
  • ^ (raise to power)

You can use grouping symbols ( ) to group operations that need to be done before others. Read more…

Retrieving System Information Using the Terminal on Ubuntu


If you want to retrieve all the information about your system on Ubuntu, just issue the following command:

sudo dmidecode

If you are not comfortable with working with the terminal, you can just install some GUI tools available.

Resizing Multiple Images (Batch) on Ubuntu


First, install the imagemagick package using the terminal.

sudo apt-get install imagemagick

Next, go to the directory where you placed all your images.

mogrify -resize 50% -format jpg *

The following code will resize all the pictures to 50% of their size maintaining their aspect ratio. The file extension of the output would be JPG. Be careful, though, because this will not delete the original files.

For more information, see the official documentation here.

Removing GRUB from Dual-Boot Windows XP


If your current setup is as follows: dual-boot for Windows XP and Ubuntu, probably you might have GRUB installed as well.

If you want to remove Ubuntu from your system, you could just format the partition where it is installed. However, chances are, the GRUB is still there. To be able to remove it, just follow the following steps I came across the Internet.

Using your Windows XP Installer, go to the Repair (Recovery Console)

fixboot

Press y to confirm.

fixmbr

Press y to confirm.

fixboot

Press y to confirm

exit

And there you have it, GRUB will be removed from your system.

Playing Audio Files on Ubuntu Server 12.04+


My Ubuntu Server has audio files in it. I want to play those via the terminal (remotely). My speaker is plugged in to my server.

The first thing that you need to install is the alsa server for the sound the work.

sudo apt-get install alsa

After installing, you have to add yourself to the audio group.

sudo adduser yourusername audio

Restart the system for it to take effect.

sudo reboot

Read more…

Auto Mount Partition During Startup on Ubuntu


To auto-mount a partition during startup, you have to add a new entry in your /etc/fstab file.

sudo nano /etc/fstab

Just follow the format of an existing entry.

# <file system> <mount point>   <type>  <options>       <dump>  <pass>

To identify the UUID of a device, just issue the command:

sudo blkid

The important thing to take note here is the mount point and the type. The mount point is a directory in your system where you want the partition to be made available.

For example, I set it to /mnt/ext

This means, if I want to access the contents of that partition, all I have to do is go to the /mnt/ext directory, assuming the directory is existing.

The type is basically the file system of the partition.

GParted on Ubuntu via SSH


It is assumed that the computer that you are using for the SSH is also Ubuntu (or any system that can support the X11 Forwarding).

My setup:
Remote Computer is running on Ubuntu Server
Local Computer is running on Ubuntu Desktop

On your local computer, issue the command:

ssh -X 192.168.1.4

replace with the necessary IP address of your remote computer.

Make sure gparted is installed. If not, install it first.

sudo apt-get install gparted

After the installation, simply run the application:

sudo gparted

A window should appear. It looks something like this:

Screenshot from 2013-01-01 02:46:11

Then you can now manipulate all the hard disks of your remote computer. Be careful when trying to modify your partition tables.

Installing Transmission Web Client on Ubuntu Server 12.10


If you want to download torrents on your headless server, you can install Transmission Web Client. You can manage all your torrents using a web browser.

Do not proceed as a root user. Log in as a user with admin privileges.

Update your software sources first.

sudo apt-get update

Install the transmission package.

sudo apt-get install transmission-daemon

After the installation, create the directory where you want to put all your downloaded files. Let’s just create a Downloads directory inside your home directory. Read more…

Fixing Locale Problem on Ubuntu Server 12.10


This solution worked for me. I have a newly installed Ubuntu Server 12.10 and every time I install a new package, it would display some error messages, like:

...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
...

To fix it, I issued the following command:

sudo apt-get install --reinstall language-pack-en

This will fix all the locale problems and will re-install the English language pack.

Other possible solutions can be found here.

Installing Webmin on Ubuntu


Webmin is a web-based interface for system administration for Unix. Using any modern web browser, you can setup user accounts, Apache, DNS, file sharing and much more. Webmin removes the need to manually edit Unix configuration files like /etc/passwd, and lets you manage a system from the console or remotely. (Reference: http://www.webmin.com/index.html)

The first thing to do is to download the latest version from their official site.

wget http://www.webmin.com/download/deb/webmin-current.deb

Afterwards, install the package.

sudo dpkg -i webmin-current.deb

If there are some dependency packages that are not installed, just issue the following command. This installs the needed packages then webmin afterwards.

sudo apt-get install -f

You can now access Webmin afterwards through: https://localhost:10000. Notice it uses the secured http protocol and it is using port 10000.

You can login as root with your root password, or as any user who can use sudo
to run commands as root.

Follow

Get every new post delivered to your Inbox.

Join 1,360 other followers

%d bloggers like this: