Why you should always have hard drive monitoring

I have this weird habit of monitoring my hard disk drive’s health every time after traveling (since bumpy rides can have adverse effect on your laptop’s hard drive). For this very purpose, I always have Acronis Drive Monitor (http://www.acronis.com/en-us/homecomputing/download/drive-monitor) installed on my system.

I have been using Acronis Drive Monitor (ADM) on my system ever since I bought it in November 2014. Recently however, it started showing critical warnings on my disk. It was showing bad sectors on my drive. My hard drive health (as indicated by ADM) fell from 100% to 68%.

Consequently, I ran the inbuilt Windows chkdsk (check disk) utility on each drive. For my C: drive however, it required a reboot.

Upon rebooting, the scan and repair process hung on 19% for a good two hours, clearly indicating disk damage.

What are bad sectors and disk failure?

Bad sectors are a normal phenomena on all types of hard drives. Mechanical hard drives (HDD’s) however, are more prone to bad sectors and disk damage from vibration/jerky rides as compared to solid state disks (SSD’s). In fact, it is even normal for your hard drive to ship with bad sectors. With billions of storage cells, it is normal for some to be damaged during the manufacture and shipping process. For this reason, hard drives come with in built functionality in the firmware which ‘remaps’ bad sectors to spare sectors (hard drive actually have spare storage cells). This remapping stores the record of damaged cells and the firmware is intelligent enough to hide the damage from the computer as much as it can (it doesn’t let the computer/operating system know of the remapping and handles it itself!).

It should not be forgotten though, that these spare cells are limited. They will run out one day and the damage will start to show up to the operating system. From this point onwards, the operating system, and more specifically, the file system will take over the task. NTFS for example, stores the record of bad sectors.

When you perform a quick format, these bad sectors are not detected/remapped by the file system (NTFS, FAT, etc). When you perform a full format however, these bad sectors are taken into account and marked unusable. This is exactly why Windows recommends that you do a quick format ONLY if you have done a full format recently. Read more about it on http://superuser.com/a/688764/10165.

What are the signs of failure?

Hard drives rarely fail instantly. Degradation is a gradual process. Most modern hard drives come with a feature: S.M.A.R.T. Monitoring. This enables utilities to query the hard drive for its health (like ADM). Unfortunately, Windows does not include an inbuilt feature to monitor S.M.A.R.T. health of disk drives. Most users do not even know that their hard drive is failing.

What to do in case of these signs?

This is the most important part of this post. Usually, backups are recommended, however, few users actually practice it. You should always store important data on the cloud, however, you can never fully rely on the cloud and you keep most frequently used/modified data on the hard drives.

If you do not have external backup drives, then these signs can save your life. You have two options:

  1. Instantly replace the drive, copying over almost all data without an issue
  2. Perform a full format on all drives to mark the bad sectors as unusable

Remember that option 2 will only temporarily extend the life of your hard drive (the degradation has started and whatever caused the bad sectors to appear in the first place are still there).

Performing full format on the root drive

Full formats are easy on the secondary drives (D, E, F, etc) however, in order to perform a full format on the C: drive, the procedure is slightly different since you cannot do it from within Windows.

Start off by booting from the Windows install disc. On the partitioning screen, press SHIFT+F10 to pop up a Command Prompt.

In the Command Prompt, type in the following commands:

diskpart ::opens the diskpart utility
list disk ::lists the connected disk drives
select disk 0 ::usually 0 is the ID of the local hard drive
list partition ::lists the partitions on the selected drive
select partition X ::X should be the number of the C: drive
format fs=ntfs ::performs a full format

You can then close the utility by typing in ‘exit’ twice. Then continue the install as usual.

Always have disk monitoring installed in case you keep valuable data on the hard drive. It will help you backup in time and save you from the day when your drive suddenly gives up, leaving no option but to panic.

Summary

Hard drive monitoring is a relatively easier way out for most people who either do not have backup media, or are too lazy to configure backups.

Drive monitoring has no effect on the performance of your system and S.M.A.R.T. monitoring requires just querying the hard drive for it’s health on regular basis.

Five must-have tools that will ease your life as a developer

1. An (excellent) code editor

This goes without saying, and you must already be having one, but I personally prefer Visual Studio Code (https://code.visualstudio.com). It is the only editor that managed to convince me after Adobe Brackets and Atom (both of which have considerably slow startup). Visual Studio Code is customization with syntax themes, syntax highlighting for almost every language, and extensions. Oh, and like both Atom and Brackets, it supports editing an entire project at a time and has the “Search in Project” feature to search all files easily.

vscode

2. A file difference analyzer

I, personally find myself comparing similar (or almost similar) files in order to analyze code from open source projects. I used to do two subsequent commits on GitHub and see the difference until I realized I could do that right on my computer, but no, not using those shell commands. KDiff3 (http://kdiff3.sourceforge.net) will certainly be a handy addition to your desktop.

3. Folder size viewer

I frequently download open source projects like Firefox, etc. The first step is almost always understanding the code. Understanding the code is way easier when you have an idea about what resides in the sub folders, and how much they weigh. Unfortunately, Windows removed the folder sizes in Windows 7 since they take too much time to compute (and with growing hard drives, came bigger folders which took even longer). Folder Size (https://sourceforge.net/projects/foldersize) is an excellent utility that let’s you toggle Folder Size pop ups right from your task-bar. You can only enable it when you want and disable it with a single click. The perfect combination of ease and performance.

foldersize

4. A (good) unzipper

This also goes without saying as you surely would be having one right there, but 7-zip file manager stands out. To my surprise, it is still not the most common unzipper yet and I have no clue why. I agree WinRAR is an excellent piece of software but I prefer 7-zip for various reasons. Firstly, it is free and open source and integrates cleanly into your environment without issuing any trial or purchase dialogs. 7-zip almost seems to me like an integrated Windows component once installed. That’s not all! It comes with an in built file manager which has certain advantages over the Windows Explorer. Over the past few months, I found out that Windows wouldn’t allow me to delete certain files extracted from archives which had illegal file names (Windows shouldn’t have allowed them to be created in the first place). Sometimes, files are created on rare file systems which allow longer filenames and are zipped into archives. When you extract them, Windows will not issue a warning, however, deleting them would be a menace. 7-zip file manager comes to the rescue.

7zip

5. Git Bash

If you are a Linux user, you must find the Linux BASH more comfortable than the Windows Command Prompt. Git Bash comes packaged with Git (https://git-scm.com) and is the perfect shell for your Windows desktop. You can right click any folder and open  Git Bash there. It supports both Windows commands as well as Linux commands (both ‘ls’ and ‘dir’ are supported). It even includes basic utilities like vim, etc! Needless to say, you can control your Git repositories with ease.

687474703a2f2f692e696d6775722e636f6d2f6e4574426a52322e706e67

Computer Science vs Computer Software Engineering

I’m often asked this question, what’s the difference between Computer Engineering, Computer Science and Computer Software Engineering. I’d like to answer this question once and for all.

See, Computer Science and Computer Software Engineering may have common links, but Computer Engineering has nothing to do with them, even remotely.

Computer Engineering is a category of Electrical and Electronics Engineering where you mostly deal with computer hardware, its design and function. It does involve software, but only to a very basic level that we call firmware. Firmware is small software that is loaded onto microcontrollers (microchips) to control their function. Of course, it is the most fundamental piece of software that is needed to run a system, but at the same time, it is very basic as compared to that involved in the other two fields.

Computer Software Engineering, as its name says, is the design of computer software. All daily applications that you use are a product of computer software engineering. Software Engineers use programming languages like C++, C# and Java to make their applications. Do remember that software that is a result of Computer Software Engineering is generally compiled and is platform dependent. In other words, it knows on which operating system (Windows, Linux, Mac OS X) or hardware (Intel x86, x64, AMD, etc) it is supposed to be run. This software is standalone and would generally not require any other software to run it (dependencies are something else, e.g. Installing DirectX because some features of the program require it).

Computer Software Engineering can be considered easier than computer science in sense that you do not have to sit and derive the algorithms, but you should have technical knowledge of several programming libraries. Programming language, in itself is nothing but a platform for development. It’s programming libraries that give you additional functionality in that language. For example, to make the simplest Windows program, you should be aware of WinAPI. WinAPI (Windows Applications Programming Interface) is a library to interface software with the massive Microsoft Windows operating system. Windows applications are built using WinAPI libraries. UNIX software is built using X.org libraries. (I am not referring to Command line applications since they follow a general code and do not even require knowledge of WinAPI. It’s because they are supposed to be run inside the shell, or console of the operating system, and do not generate a window on their own.)

In order to show stuff inside your Window, you need to be aware of libraries specific to the type of software you build. DirectX and OpenGL for example, are two most common libraries for building applications with 3D graphics.

Computer Science, on the other hand, is a mainly theoretical field. You will often use software like MATLAB, Mathematica, Maple to visualize systems. Of course, it also involves programming, and of more or less the same level as Computer Software Engineering. As a Computer Science major, you will be doing mathematical modeling, physical calculations, algorithm design, etc. However, the software you make will generally be platform independent. In other words, your software will not be aware of the platform it is running on. MATLAB programs for example, will run on any computer system with a copy of MATLAB installed on it (although MATLAB itself is a product of software engineering).

When it comes to deciding your major, you should be aware in the first place whether you want to work at hardware level or software level. If hardware, then Computer Engineering it is. If it’s mostly software for you, then you should know whether you want to work mostly on the technical side or the theoretical side. Do remember that both Computer Software Engineering and Computer Science have complexities at different levels. Computer Science is better if you are good at mathematics and algorithm design. Computer Software Engineering is better if you are good at reading the documentation of different libraries and putting them to practical use to build software.

At university level, Computer Science majors will often be taught courses related to Software Engineering, and vice versa. Some universities may not even have a separate program for Software Engineering. Both fields share a lot in common, and by getting a degree in any of them, you can get a job in either field.

Installing and Using OpenBTS over USRP 1 on Ubuntu 16.04

This guide will help you gets started with OpenBTS on Ubuntu 16.04 (tried and tested on both 32 bit and 64 bit versions).

Some Background Information

First of all, I will be using a USRP 1 series board, although this guide will be flexible enough to allow you to use USRP 2 board as well.

Newer versions of GNU Radio (version 3.5.0 and onwards) do not contain USRP. We will downgrade to version 3.4.2 which is also a lengthy process. USRP is the only component of GNU Radio that we need. GNU Radio is a signal processing software and is not generally needed for simulating a BTS and making a call using two phones.

The script created by RangeNetworks is an excellent utility, but it ends up in problems with USRP 1 boards (although there is a command line option to build for USRP 1 boards). The reason being that USRP package is needed to support these boards and the only source of it is GNU Radio 3.4.2 or earlier. Unfortunately, downgrading some packages is the only way to support these boards.

Step 1: Download sources using RangeNetworks script and build them

The OpenBTS project consists of multiple software components hosted in separate development repositories on GitHub. The below mentioned Git repository contains a set of ‘dev’ or development scripts which make it easier to download the code, switch Git branches, and compile components. To download these development scripts into your new environment, run the following command:

# git clone https://github.com/RangeNetworks/dev.git

Run the ‘clone.sh’ script to clone the individual components from source on Github to your local folder:

cd dev
./clone.sh

At time of writing this guide, I issued this on Ubuntu 16.04 and most components did not cause problems. OpenBTS (which is one component) did cause problems since it requires USRP which only comes bundled with GNU Radio 3.4.2 and older versions and not the subsequent newer versions.

Before running build.sh, we need to change a few things. Comment out the lines 189 to 197. Your move may vary as this script may get updated on GitHub. For that purpose, I am reproducing these lines below. These lines are responsible for downloading and building OpenBTS. We will be downloading OpenBTS and GNU Radio separately so disable these lines:

if [ "$COMPONENT" == "all" ] || [ "$COMPONENT" == "openbts" ]; then
    echo "# openbts - building Debian package"
    sayAndDo cd openbts
    sayAndDo dpkg-buildpackage -us -uc
    sayAndDo cd ..
    sayAndDo mv openbts_* $BUILDNAME
    echo "# - done"
    echo
fi

Step 2: Install OpenBTS separately

Step 2.1: Installing GNU Radio 3.4.2

GNU Radio 3.4.2 can be downloaded and compiled from source, since the repositories for Ubuntu 16.04 do not contain this version. GNU Radio has a lot of dependencies. Let’s start with the first one.

Step 2.1.1: Install SDCC (Small Devices C Compiler):

sudo apt-get install bison flex texinfo gputils
wget https://jaist.dl.sourceforge.net/project/sdcc/sdcc/2.8.0/sdcc-src-2.8.0.tar.bz2
tar -xvjf sdcc-src-2.8.0.tar.bz2
cd sdcc
./configure
make
sudo make install

Step 2.2.2: Install older version:

Remove the latest GNU Radio installation which does not contain USRP:

sudo apt-get remove gnuradio

Install some more dependencies:

sudo apt-get install libusb-dev libpython-dev swig doxygen libgsl-dev libusb-dev

Then install the older version:

wget http://gnuradio.org/releases/gnuradio/gnuradio-3.4.2.tar.gz
tar –zxvf gnuradio-3.4.2.tar.gz
cd gnuradio-3.4.2

Then on a 32-bit OS:

./configure --with-boost-libdir=/usr/lib/i386-linux-gnu CXXFLAGS="-lboost_system" --disable-all-components --enable-usrp --enable-omnithread --enable-mblock --enable-pmt --enable-docs --enable-doxygen --enable-gnuradio-core --enable-gr-wxgui --enable-gruel --enable-gr-utils --enable-gr-usrp
make
sudo make install

And on a 64-bit OS:

./configure --with-boost-libdir=/usr/lib/x86_64-linux-gnu CXXFLAGS="-lboost_system" --disable-all-components --enable-usrp --enable-omnithread --enable-mblock --enable-pmt --enable-docs --enable-doxygen --enable-gnuradio-core --enable-gr-wxgui --enable-gruel --enable-gr-utils --enable-gr-usrp
make
sudo make install

Common Error(s):

intptr_t was not declared in this scope.

Go to line 96 of gnuradio-3.4.2\gnuradio-core\src\lib\filter\qa_gri_mmse_fir_interpolator_cc.cc and change intptr_t to long int

Step 2.2: Install OpenBTS 2.8

For older versions of GNU Radio, we need to downgrade our choice of OpenBTS as well. For this purpose, download OpenBTS 2.8.1 from https://github.com/RangeNetworks/openbts/releases

Step 2.2.1: Downgrade libortp-dev package

OpenBTS 2.8.1 will issue errors if compiling with the version of libortp installed by the devscript. We need to downgrade that as well. ORTP 2.0.0 is the latest package that has a supported version of the API used by OpenBTS 2.8.1.

Remove the latest package:

sudo apt-get remove libortp-dev

Install the older version:

wget http://download.savannah.gnu.org/releases/linphone/ortp/sources/ortp-0.20.0.tar.gz
tar -zxvf ortp-0.20.0.tar.gz
cd ortp-0.20.0
./configure
make
sudo make install

Step 2.2.2: Fix 2.8.1 files:

OpenBTS 2.8.1 throws a lot of compile errors during make. I’m posting them here for search purposes:

In file included from Threads.cpp:31:0:
Timeval.h: In function ‘void msleep(long int)’:
Timeval.h:36:43: error: ‘usleep’ was not declared in this scope
 inline void msleep(long v) { usleep(v*1000); }
                                           ^


SocketsTest.cpp: In function ‘void* testReaderIP(void*)’:
SocketsTest.cpp:50:11: error: ‘sleep’ was not declared in this scope
    sleep(2);
           ^
SocketsTest.cpp: In function ‘void* testReaderUnix(void*)’:
SocketsTest.cpp:70:11: error: ‘sleep’ was not declared in this scope
    sleep(2);
           ^
SocketsTest.cpp: In function ‘int main(int, char**)’:
SocketsTest.cpp:91:10: error: ‘sleep’ was not declared in this scope
   sleep(1);
          ^



ConfigurationTest.cpp:48:57: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
  CXXLD    ConfigurationTest
../sqlite3/.libs/libsqlite.a(sqlite3.o): In function `unixDlError':
/home/usama/Downloads/openbts-2.8.1/sqlite3/sqlite3.c:25667: undefined reference to `dlerror'
../sqlite3/.libs/libsqlite.a(sqlite3.o): In function `unixDlClose':
/home/usama/Downloads/openbts-2.8.1/sqlite3/sqlite3.c:25698: undefined reference to `dlclose'
../sqlite3/.libs/libsqlite.a(sqlite3.o): In function `unixDlSym':
/home/usama/Downloads/openbts-2.8.1/sqlite3/sqlite3.c:25694: undefined reference to `dlsym'
../sqlite3/.libs/libsqlite.a(sqlite3.o): In function `unixDlOpen':
/home/usama/Downloads/openbts-2.8.1/sqlite3/sqlite3.c:25653: undefined reference to `dlopen'




rnrad1Core.cpp: In function ‘rad1LoadStatus rad1LoadFirmwareNth(int, const char*, bool, libusb_context*)’:
rnrad1Core.cpp:433:25: error: ‘R_OK’ was not declared in this scope
   if (access (filename, R_OK) != 0){
                         ^
rnrad1Core.cpp:433:29: error: ‘access’ was not declared in this scope
   if (access (filename, R_OK) != 0){
                             ^
rnrad1Core.cpp:467:12: error: ‘sleep’ was not declared in this scope
     sleep(2);
            ^
rnrad1Core.cpp: In function ‘bool rad1_load_standard_bits(int, bool, std::__cxx11::string, std::__cxx11::string, libusb_context*)’:
rnrad1Core.cpp:524:25: error: ‘R_OK’ was not declared in this scope
   if (access (filename, R_OK) != 0){
                         ^
rnrad1Core.cpp:524:29: error: ‘access’ was not declared in this scope
   if (access (filename, R_OK) != 0){
                             ^
rnrad1Core.cpp: In member function ‘bool rnrad1Core::writeEeprom(int, int, std::__cxx11::string)’:
rnrad1Core.cpp:817:20: error: ‘usleep’ was not declared in this scope
     usleep (10*1000);                // delay 10ms worst case write time
                    ^



rnrad1Rx.cpp: In constructor ‘rnrad1Rx::rnrad1Rx(int, unsigned int, std::__cxx11::string, std::__cxx11::string)’:
rnrad1Rx.cpp:61:12: error: ‘usleep’ was not declared in this scope
   usleep(10);
            ^



rnrad1Tx.cpp: In constructor ‘rnrad1Tx::rnrad1Tx(int, unsigned int, std::__cxx11::string, std::__cxx11::string)’:
rnrad1Tx.cpp:80:12: error: ‘usleep’ was not declared in this scope
   usleep(10);
            ^



RAD1Device.cpp: In member function ‘bool RAD1Device::tx_setFreq(double, double*)’:
RAD1Device.cpp:124:15: error: ‘usleep’ was not declared in this scope
   usleep(10000);
               ^
RAD1Device.cpp: In member function ‘bool RAD1Device::rx_setFreq(double, double*)’:
RAD1Device.cpp:147:15: error: ‘usleep’ was not declared in this scope
   usleep(10000);
               ^



DummyLoad.cpp: In member function ‘virtual int DummyLoad::readSamples(short int*, int, bool*, TIMESTAMP, bool*, unsigned int*)’:
DummyLoad.cpp:99:12: error: ‘usleep’ was not declared in this scope
  usleep(100); 
            ^
DummyLoad.cpp:100:9: warning: converting to non-pointer type ‘int’ from NULL [-Wconversion-null]
  return NULL;
         ^
DummyLoad.cpp:103:12: error: ‘usleep’ was not declared in this scope
  usleep(100);
            ^
DummyLoad.cpp:104:9: warning: converting to non-pointer type ‘int’ from NULL [-Wconversion-null]
  return NULL;
         ^



OpenBTS.cpp: In function ‘int main(int, char**)’:
OpenBTS.cpp:141:44: error: ‘VERSION’ was not declared in this scope
  LOG(ALERT) << "OpenBTS starting, ver " << VERSION << " build date " << __DATE__;

To fix these:

  1. You need to include (#include) unistd.h in the following files:
    1. Timeval.h
    2. SocketsTest.cpp
    3. rnrad1Core.cpp
    4. rnrad1Rx.cpp
    5. rnrad1Tx.cpp
    6. RAD1Device.cpp
    7. DummyLoad.cpp (two files with this name)
  2. You need to issue the following command before issuing make:
    export LIBS="-ldl -lpthread"

Issue make again and you should be fine.

Configuring FA-Synthesizer “FA-SY 1”, 10 – 160 MHz External Clock

In this guide, we will prepare and configure an FA-Synthesizer “FA-SY 1”, 10 – 160 MHz external clock.

Note: The ‘Technical Guides’ category on this blog is meant to help out people working with a specific technology. I post up guides on equipment I use during some projects to help out other people working on similar technology. You are encouraged to share your knowledge in the comments, however, I may not be able to answer your questions since I do not own the technology in any way.

This clock is a relatively cheap option for use with USRP boards and other embedded hardware and offers a decent frequency range. For more technical specifications, go to the link above or consult the technical guide provided by the manufacturer (original guide is in German).

Step 1: Preparation

The clock ships with SMT components soldered, however, the through hole components are left unsoldered. You will have to solder them yourself. The following two images (again taken from the technical guide) will help you solder them in place.

soldering

Here is a list of the components you need to solder:

  1. IC Bed for ATTiny microcontroller (do not solder the microcontroller directly, or you will damage it!)
  2. BD244C Power transistor
  3. 2 x Breadboard wafers (or whatever you call them) on buses X1 and X2
  4. Grounding cable for power transistor (seen in blue in the picture on the right)

Make sure to solder the IC bed and power transistor in the right direction! See the picture again on how to do it.

Make sure to keep the legs of the breadboard wafers on the bottom so you can fix it on a breadboard later.

Step 2: Connecting a USB Cable

You need to solder a USB cable in order to connect this device to a computer to configure it later. The following picture, again taken from the technical guide, explains how to do it. The pin numbers on X2 are written on the reverse of the module. For your convenience, I have added the color of wires inside a USB cable as well.

pinout

Step 3: Connecting an oscilloscope and power

You now need to connect an oscilloscope and power supply to power up the module and see the output clock waveform. According to the following schematic, given in the technical guide, you need to connect pin 8 to 12V supply and the rest of the pins to ground. Then connect an oscilloscope on pin 4. All these pins are located on bus X1!

schematic

Step 4: Configuration

You have made it through the hardware part. Now download this utility: http://sdr-kits.net/USB/USB_Synth.exe

If the above link does not work, here is a mirror of the file.

Connect the device to a Windows machine and the driver will install automatically. Then this utility can be run to set the frequency. Observe the corresponding change on the oscilloscope!

Enjoy your new synthesizer clock!

Setting up an Android Development Environment using Eclipse IDE

As you read this, you are most likely to be tapping on a smartphone screen. In this era of smartphones, Android development is one of the most demanded skills out there.

First off, we will stick to Eclipse. We will first set up a generic Java development environment, followed by the necessary tools on top of it for Android programming functionality.

Before doing any installation, fetch all the necessary tools to your hard drive. Here’s a list of what you need:

  1. Eclipse IDE for Java Developers
    Download from: http://www.eclipse.org/downloads
  2. Java Development Kit (JDK), contains libraries for Java development
    Download from: http://www.oracle.com/technetwork/java/javase/downloads/index.html
  3. Android SDK tools (contains the Platform and Build tools)
    Download from:
    http://developer.android.com/sdk/index.html#ExistingIDE ; click “USE AN EXISTING IDE” > “Download the SDK Tools for Windows”.
  4. Android Development Tools (contains libraries for Android development; it is dependent on JDK)
    Download from: http://developer.android.com/sdk/installing/installing-adt.html, scroll to the bottom of the page, “Troubleshooting ADT Installation” section.

requirements

 

  1. First off, install JDK.
  2. After JDK installation, go to your Computer properties. On Windows 7, 8 and 8.1, right click on Computer/This PC, click Properties and then in the window that appears, click “Advanced system settings” in the left pane.
    Settings
  3. Go to the “Advanced” tab in the window that appears, and click the “Environment Variables…” button towards the bottom.
  4. Add a new variable in the “User Variables” section, with the name JAVA_HOME, and the value should be the address that points to your JDK installation:
    Uservars
  5. Do not close the window. In the System variables section, find the “Path” variable, and click Edit:Path
  6. At the end, append the path to your JRE installation (include the semicolon in the beginning and the /bin at the end).
  7. Save your configuration; extract Eclipse in a directory such as C:\ and create a shortcut for eclipse.exe on your desktop.
  8. At this point, your Eclipse has been set up for Java development. Move onto the next steps for Android development.
  9. Once the installation completes, the installer offers to start the Android SDK Manager. DO NOT start the Android SDK Manager.
  10. Install the ADT plugin in your Eclipse installation. There are two ways to do this. Either install it from the online repository, or download it first, and install it as an archive. I recommend installing it directly from the repository, because even if you are installing it from the archive, a lot of dependencies have to be downloaded from the internet during install. To install it directly from the online repository,
    1. Start Eclipse, then select Help > Install New Software.
    2. Click Add, in the top-right corner.
    3. In the Add Repository dialog that appears, enter the following URL for the Location:
      https://dl-ssl.google.com/android/eclipse/
    4. Click OK and follow the steps to complete the installation (you will need to accept the license agreement).
    5. If you downloaded ADT as an archive, follow the method here:
      http://developer.android.com/sdk/installing/installing-adt.html
  11. Fire up Eclipse. You will get a warning that the Platform tools and Build tools are absent.
    SDKNotPresent
  12. The required tools will be checked by default, just click the “install packages” button. (Do not compare your selected packages with mine, since the screenshot was taken during the installation, when some packages had already been installed).
    PackageList
  13. 13. If you get an error, close SDK tools, and run it from the Start Menu or the Start Screen in elevated (administrator) mode by right clicking on it.
  14. Wait for the installation to finish:
    InstallProgress
  15. Once it’s done, congratulations. Your computer is all set for Android programming. Fire up Eclipse to create a new project straight away.

Happy coding!

Virtual WiFi Miniport Adapter – Set your hotspot from your Windows PC directly

Connectify and Virtual Router have been around for a while, but did you know you could share your internet directly from your Windows machine as a Wifi hotspot?

From Windows 7 onwards there is this inbuilt feature, namely Virtual WiFi Miniport Adapter. You can broadcast your internet connection in access point mode and use it on any device. In this example, we will share a LAN connection on Virtual Wifi.

Open up an elevated Command Prompt or a PowerShell and issue this command:

netsh wlan set hostednetwork mode=allow ssid=YourHotspotName key=YourPassword keyUsage=persistent

You have enabled your Miniport Adapter. Now issue the following command:

netsh wlan start hostednetwork

Right click on the network icon in your taskbar and open Network and Sharing center. Chose “Change Adapter Settings” on the left side. You will see a new connection with “Microsoft Hosted Network Virtual Adapter” in its description:

1

This is your Virtual Adapter (and KOSMOS-2251 is my hotspot name).

Now right click the LAN connection (the one you want to share on the Virtual Adapter) and open Properties:

2

Move onto the Sharing tab and check “Allow other users to connect through this computer’s internet connection”:

3

You will have to mention the name of your Virtual Miniport Adapter here.

Next click settings and enable all services that you want to share. That’s it, you can use the internet on your hotspot from any Wifi enabled device around!

To stop the Wifi connection, issue:

netsh wlan stop hostednetwork

Enjoy.

Algorithm to Solve a User Defined Maze

Level of Mathematics Required: None

So I decided to make a “Pathfinder Robot” as my first semester MATLAB project. Not only did I learn lots of new stuff while doing it, I also ended up making my own algorithm for it. The usual one that is used is called A*. A* finds out the shortest path, but does not use the shortest number of moves. This one uses a different approach, to solve the maze in the shortest number of turns as well as the shortest path.

I will also upload in here the original program that I made later on.

1. Get the maze from the user. Also get the starting and ending points.

Get the maze from the user and save it in a 20 by 20 matrix of zeros and ones. Zeros denote the open area and ones indicate walls.
Get the maze from the user and save it in a 20 by 20 matrix of zeros and ones. Zeros denote the open area and ones indicate walls.

2. Break down your maze into horizontal and vertical segments. A segment is any uninterrupted path in the maze measuring 1 by n or n by 1 depending on whether it is horizontal or vertical, where n is any integer greater than 1. A 1 x 1 segment does not match our definition of segment here.

Red: some horizontal segments. Blue: some vertical segments Green and Orange: some NON segments
Red: some horizontal segments.
Blue: some vertical segments
Green and Orange: some NON segments

Do note that the orange “segments” were generated while segmenting the maze horizontally, and the green “segments” were made while segmenting the maze vertically. Do note that each of the orange parts WILL form part of some vertical segment and each of the green parts WILL form part of some horizontal segment. However, if a white box is locked by all 4 sides, then it will not form part of either a horizontal or a vertical segment.

This forms our complete definition of the segment for this program.

3. Each segment must be assigned a number. In this maze, we have 50 horizontal and 44 vertical segments. Store the information of each segment in a matrix. (The starting and ending points, for example).

4. For each horizontal segment, find out ALL the vertical segments that intersect it and save them into an array also.

5. Do the same for vertical segments. Remember a horizontal segment will ALWAYS intersect with a vertical and vice versa.

6. Run a recurrence process starting from the starting segment. Find out all possible pathways that extend from the starting segment. For example, if the starting segment has 6 intersecting segments, you have 6 possible moves in the first place. For each first move, find out all possible second moves and so on. On every level however, do keep checking if you have already encountered the destination segment. Break the loop then.

7. Highlight the path using the segments. This is tricky. You do not highlight the entire segment, only the part of it that lies between the segment before and after it in the sequence.

Important Notes

Do remember that your sequence of moves in every single possible route will be such that if the first segment was horizontal, the second will be vertical and the third will again be horizontal and the fourth will again be vertical. You can exploit this fact to prevent your robot from moving backwards (thats not what we want). Here’s how. Suppose this was your sequence (it’s stored in a array)

sequence={1, 4, 4, 51, 7, 9, 11}

Each element on an odd index of the array denotes a horizontal segment and each element on an even index denotes a vertical segment. Before appending a new horizontal segment to the sequence, check that the number does not already exist on an odd index of the array, and before appending a new vertical segment to the sequence, check that the number does not already exist on an even index of that array. 4 is used twice here, but its fine since one of them denotes a horizontal segment and the other denotes a vertical segment. We basically don’t want to encounter the same segment twice.

Do remember that as “full” as your maze is, the less the number of possible paths and the less the computation. However, if your maze has large open spaces, the number of intersections in that open space increase drastically and slow down your program. To solve this, move on to optimization.

Optimization

So your user left out lot’s of extra space in the maze. You do not want it. What do you do? Well, you simply cancel it out from your main program sequence by placing a “patch” on the maze. This “patch” is more of a “crime scene, do not enter” type of stuff. You move from the sides, you do not enter it.

Yellow: Trim from the outside Magenta: Trim from the inside
Yellow: Trim from the outside
Magenta: Void/Trim from the inside

First of all, “trim” the maze from the outside, leaving just a track of unit thickness around the maze (don’t block it all).

Next,

  • Probe the maze for any 4 x 4 regions of empty space.
  • Void out (magenta) only the central 2 x 2 of this space.
  • Expand this 2 x 2 first horizontally and then vertically, as much as you can, but again, leaving a track of unit thickness on the side of expansion. (That’s the reason we void out only the central 2 x 2 of the 4 x 4 region.)
  • DO NOT search for another 4 x 4 region unless you have expanded the first one as much as it could be.
  • Assign numbers to these patches as you create them.

There’s a possibility that the patches lengthen the route while decreasing the computation. See below:

Moving between the two blue dots involves just 2 segments, but because of the magenta patch, it now needs 4 segments.
Moving between the two blue dots involves just 2 segments, but because of the magenta patch, it now needs 4 segments.

Doesn’t matter. Once you are done, correct this for each patch (that’s what we assigned them numbers for). Just scan the sides of each patch and detect the points where the path moves away from the patch. There will be two such points, connect them together and delete the part that “wipes around the patch”.

Grey part shows deleted part of the route.
Grey part shows deleted part of the route.

Windows 8.1 Post Install – Do’s and Don’ts

Do’s:

  1. First of all, Windows 8.1 setup does not ask for your timezone during setup. Right click on your clock and set your timezone straight away, or you can run into problems that you can’t imagine.clock
  2. Windows 8.1 will frequently ask you to download and install .NET 2.0 and 3.5. But everytime you try downloading it, you will get the error 800F0906. This issue was present in the Preview editions and hasn’t been fixed so far. Here’s the universal workaround: mount your Windows 8.1 ISO and issue this command in Command Prompt or PowerShell:
    dism.exe /online /enable-feature /featurename:NetFX3 /Source:h:\sources\sxs /LimitAccess

    (where h:\ is the letter of the Virtual Drive containing Windows 8.1 Installation Media.

  3. The Lock Screen which has a very short default timeout (1 minute) will drive you crazy. By default, you cannot change its timeout in the advanced settings of your power plan. To change it, open Registry Editor.
    Navigate to the following key:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\PowerSettings\7516b95f-f776-4464-8c53-06167f40cc99\8EC4B3A5-6868-48c2-BE75-4F3044BE88A7

    Double Click Attributes and change its value from 1 to 2.

    Now when you edit the advanced settings of your power plan, you can see a new parameter under the Display sub menu, namely “Console lock display off timeout” (see figure below). You can set your timeout as you wish.

    consolelock

  4. Install DirectX.
    Quoting directly from Microsoft:

    Some applications and games require DirectX 9. However, your computer includes a more recent version of DirectX. If you install and then run an application or game that requires DirectX 9, you might receive an error message such as “The program can’t start because d3dx9_35.dll is missing from your computer. Try reinstalling the program to fix this problem.”

    To install it, go to: http://www.microsoft.com/en-us/download/details.aspx?id=35

  5. This one’s upto you, but I found this handy. In Windows 7, the Libraries were quickly accessible in the Navigation Pane. In Windows 8.1 however, Libraries appear beneath This PC in the pane. Ever since I started using Windows 7, I personally keep all my data in a separate hard drive and just add the location of my Documents, Music and Pictures to the appropriate Library. Hence Libraries are my most used links in the Navigation Pane. I do not like to scroll down each time to access them. Here’s a workaround to bring them above This PC in Windows 8.1.
    Open Registry Editor (Run > regedit) and navigate to the following key:

    HKEY_CLASSES_ROOT\CLSID\{031E4825-7B94-4dc3-B131-E946B44C8DD5}

    Change the value of SortOrderIndex to 38 (hexadecimal).

    thispc
    After you reboot, you will see the Libraries have moved above This PC and are quickly accessible.

    libraries

Don’ts

  1. Do not ditch the new Metro apps instantly. Give them some time. You will soon learn you will be using these new apps for the rest of your life. It wasn’t 5 minutes I started using the new Reader app that I realized I would finally stop using Adobe Reader which I had been using for the last decade.
  2. Do not install any ISO mounting software. Windows 8.1 includes this feature by default.
  3. Do not install any third party antivirus software. Windows Defender, prebundled into Windows 8.1 is just a rebranding of the Microsoft Security Essentials and works great.

Enjoy Windows 8.1!

Installing FreeBSD 9.1 in Virtual Box, and setting up a graphical desktop

Hello guys, it’s been a while since I last posted up a tutorial so here we go. I hope you have a downloaded FreeBSD 9.1 Release ISO and Virtual Box up and running. If you haven’t installed Virtual Box yet, do install it now, and install ALL components (networking, USB support, etc).

Create a new Virtual Machine in Virtual Box. I recommend 10 GB of a FIXED storage volume and 512 MB RAM.

1

Before we start, open the settings for this machine, and check Enable IO APIC option. Basically, what we need to enable is HPEC (high precision event timers). Without those, FreeBSD would not boot. Enabling this option will enable HPEC.

2

Start the machine. You will be asked to locate the drive to boot from

3

Locate the FreeBSD ISO.

4

Boot (make sure ACPI is enabled, other wise enable it using the ‘4’ or ‘A’ key.

5

When the kernel has booted, start the “Install”.

6

The steps are self explanatory. In the following, select ALL distributions. You will need src (the system source code) because in FreeBSD 9.1, there are no packages unfortunately. All has to be pulled off the online repository or compiled from source

7

In the partitioning, use GUIDED mode because it will create all three standard FreeBSD partitions on its own.

8

If you choose to do it manually though, remember the freebsd-boot partition should be no larger than 512 KB. freebsd-swap should be the size of the RAM, and devote the rest to the freebsd-ufs (with / as the mount point). The boot partition must be the first one.

9

After that, commit to the installation. You don’t have to worry about the warnings since this is a virtual machine.

10

After the install, do not configure the em0 interface at this point. Do not add users at this point either. A lot of work has to be done as root. You can add users later. Just Exit the installer and reboot.

11

If the machine reboots into the ISO image again, you will need to power off this machine after reboot. Use Machine > ACPI Shutdown. Then go to machine settings and in the storage tab, select the FreeBSD ISO. Remove it from the virtual drive as shown in the pic.

12

And then start the machine.

Log in as root and the password you set during install. The first thing you should do is to connect to the internet via NAT (Network Address Translator) of Virtual Box. NAT configures itself automatically. Make sure the host OS is online. Then issue this command:

# dhclient em0

Then since Google is always on,

# ping google.com

I deliberately used this syntax because most users don’t know how to exit from the ping command. Well, here you go, press CTRL + C to exit from ping when it has transmitted/received a few packets. CTRL + C will exit most commands.

Let’s move on and install X11.

# cd /usr/ports/x11/xorg
# make install clean

You are compiling from source. It may take a while. The dependencies will be downloaded from the internet also.

Alternatively you can run

# pkg_add -r xorg

To download precompiled packages directly and install them instead.

Once it is installed, I’d recommend you install nano text editor because we will need to edit a lot of files. The default editor, vi, is more fun to use but a bit complicated.

# pkg_add -r nano

Let’s move on to configure X11.

You need to edit /etc/rc.conf and place the following lines at the end:

hald_enable="YES"
dbus_enable="YES"

This is because Xorg uses HAL to autodetect mice and keyboards. That’s it, fire up X.

# startx

You will see TWM, the default X11 window manager. Then run this command to create a skeleton configuration file in /root

# Xorg -configure

Now test if Xorg is working on your hardware.

# Xorg -config xorg.conf.new -retro

If a black and grey grid and an X mouse cursor appear, the configuration was successful. To exit the test, switch to the virtual console used to start it by pressing Ctrl+Alt+Fn (F1 for the first virtual console) and press Ctrl+C.

Install the URW font collection (the default fonts shipped with X11 are less than ideal).

# cd /usr/ports/x11-fonts/urwfonts
# make install clean

Now make the X server detect these fonts. The following commands should be run in a shell in an X session:

% xset fp+ /usr/local/lib/X11/fonts/URW
% xset fp rehash

Last thing for today, install GNOME:

# pkg_add -r gnome2

or

# cd /usr/ports/x11/gnome2
# make install clean

Once that is done, add the following lines to /etc/rc.conf to make GDM start automatically at boot:

gdm_enable="YES"
gnome_enable="YES"

That’s it. Reboot and you will be greeted with a graphical login screen. Enjoy your FreeBSD experience!