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

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!

Wavefunctions, Space and Time

This post is meant to help you visualize the common wavefunction ψ(x)=A sin(kX-ωT).

Visualization is best done with graphs. Since the quantity ψ(x) here depends on two quantities, X and T, what we need here is a 3D graph. Y axis represents ψ(x). X axis represents Space and T axis represents Time.  The plane Y=0 is just placed for reference and does not hold any significance.

Rendered using Wolfram Mathematica
Rendered using Wolfram Mathematica

Do note that every function that depends on both space and time is actually a 3D graph. The Y quantity depends on both X and T. Y varies with both X AND T.

If you freeze your wavefunction in time, you are actually making the value of T constant at say T=0. The remaining wavefunction is simply ψ(x)=Asin(kX) since T=0. If you chose to enter a non zero value for t, the resulting expression will be ψ(x)=Asin(kx-C) where C represents ωT at a constant non zero value of T.

Freezing wavefunction in time also means looking at it from only the X-Y plane. (And freezing in space would mean looking at the Y-T plane.)

Mathematically, in ψ(x)=Asin(kX-ωT), if the value of ωT increases, you are subtracting a greater value from the argument of the sin function and the graph should shift towards the right.

Now observe the mesh lines on the 3D graph, as you move along the T axis, your graph in the X-Y plane is shifting forward. (Increasing T will also increase ωT).

The minus sign with ωT is conventional. If the sign of the quantity ω is reversed, this minus sign will disappear.

The argument of the sin function is always an angle in radians, hence the unit of both kX and ωT is rad (radian).

k is (2π rad)/(λ m) and X is in meters. Hence the unit m (meters) cancels out when k and X multiply together.
ω is (2π rad)/(t sec) and T is in sec. Hence sec (seconds) cancels out in ωT.

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!

How to update Iceweasel/Icedove on Debian

So after switching to Debian, I have realized that the only drawback this OS contains is the rebranding of Firefox and Thunderbird to Iceweasel and Iceape respectively. Because of this, they have been detached from the main release cycle of Firefox and Thunderbird and are not always up to date.

The latest release of Debian (Squeeze) still contains Iceweasel 3.x which is pretty old. Using the following procedure, I was able to update it to Iceweasel 10 which is way better. You may also be able to install 13 from source.

1. Add the following lines to the end of /etc/apt/sources.list

deb http://backports.debian.org/debian-backports squeeze-backports main
deb http://mozilla.debian.net/ squeeze-backports iceweasel-aurora iceweasel-beta iceweasel-release iceweasel-esr icedove-esr iceape-esr

2. Next, update apt:

sudo apt-get update

3. Next, issue this command to upgrade to the latest stable Iceweasel in the Debian Backports repo (which at time of writing this post was 10):

sudo aptitude install -t squeeze-backports iceweasel

Congrats, you have successfully upgraded your Iceweasel! Enjoy Debian. You can use the same process for Icedove, just replace iceweasel with icedove in step 3.

reduction to the absurd