How to Use Sublime Text 2 From Terminal on Mac OS

Sublime Text 2? The editor that developers, developers, developers like to use. At the very least, Sublime is a common text editor for the everyday programmer. How can you use Sublime on your terminal? If you’re any programmer, you’re maneuvering through the terminal left and right, all day everyday, so you need to have an easy way to use sublime from the terminal!

By default, for Mac OS X, you don’t have Sublime binded to a command on the terminal! Let’s do show you how to do that.

Installing Sublime

You can install the stable version of Sublime on their website.

http://www.sublimetext.com/2

 

How to Set-up

We want to be able to type in:

subl

and open files.

Open a new terminal. First, we will bind the newly installed Sublime 2 (you can also do this for Sublime 3) as the subl command. We’re using a symbolic link from the binary within the Application to what we will make as globally accessible.

sudo ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

OR you can bind sublime to a sublime command for clarity instead of the abbreviation.

sudo ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime

The symbolic link will create an accessible subl command to open sublime and use it to open files or folders.

We will open ~/.bash_profile with a text editor and make sure that this new sublime command will be ready whenever we open the terminal.

open -a TextEdit ~/.bash_profile

With .bash_profile, we will set the PATH variable to look inside the /usr/local/bin folder where we created the sublime link. Type the following if it is not in your ~/.bash_profile.

By exporting the path, ~/.bash_profile will refresh and export the folder for accessible binary commands whenever we open a new terminal.

Now save and exit. The first time we do this, we will not have access to the sublime command immediately. We first need to source, which means to reload the ~/.bash_profile in order to have access to our sublime command!

source ~/.bash_profile

How to Use

Open a terminal and use any of the variations of the command:

Open sublime
subl
Open a file
subl file
Open a folder
subl folder/
Open the current directory
subl .

Enjoy your new sublime command! Makes things much more convenient if you enjoy using sublime!

How to Install Cassandra 2.1.6 on Mac OS

Cassandra is a useful NoSQL database management system with praise for its high availability. Let’s demonstrate how to install Cassandra 2.1 on Mac OS X.

Step 1) Install the Oracle Java Development Kit (JDK)

On Macs, you can easily download the corresponding dmg file and install.

After installing, check that you have installed the JDK.

Step 2) Install Cassandra

Make a directory for your Cassandra package and change directory into it.

Download the latest Cassandra tar file into the directory you just made.

http://cassandra.apache.org/download/

At the time of writing, 2.1.6 is the most stable release.

Extract the file.

Set a symbolic link from the newly extracted folder to a conveniently named cassandra folder in your packages directory.

Step 3) Cassandra directory configurations

We’ll use some convenient Cassandra configurations to store logs, data, and cached files.

We will edit the ~/opt/cassandra/conf/cassandra.yaml file to accommodate the folders that we just created. Configure the following settings. Erase the # on each.

4) Add Cassandra to PATH

Open the bash profile.

Add Cassandra to PATH, so you can call cassandra from anywhere.

Load the bash profile.

5) Run Cassandra

Start Cassandra. Cassandra should run with a long log record.

CTRL-C to close Cassandra, but let’s not do that right now. Instead, open a new terminal. You can log into the Cassandra shell in the new terminal as long as Cassandra is running.

You can run commands within the Cassandra shell, which looks like:

Cassandra is successfully installed and usable!

How to Install Django on Mac

Section 1: Install Django on your local machine and run a simple page

If you have already installed Django, please jump to the next section.

If you are not sure if you have Django on your computer, please open terminal and enter:

python -c "import django; print(django.get_version())"

If you already have Django installed, it should show something like this:

Screen Shot 2014-11-12 at 5.56.59 PM

If you don’t have Django, please follow the rest of these steps.

Step 1: Verify that you have Python on your computer

Django requires Python to work.  Django can work with different versions of Python.

Make sure that your Python version is one of 2.7 or 3.2, 3.3, 3.4, 3.5 versions. Depending on the version of Django, you’ll need to make sure that you have a verified working Python version. As of May 20, 2015, version 1.8.2 is the stable release of Django.

Since Django comes along with a light SQLite database, you don’t need to worry about the database at this point.

Open your terminal and type:

python --version

If you already installed Python, something line this should show up:

Screen Shot 2014-11-12 at 6.00.01 PM

 

If your computer doesn’t have Python, you should download it from:

https://www.python.org/downloads/

You should either download the 2.7 version or 3.4 version. Since I am using 3.4 in this tutorial, 3.4 is recommended.

 

Step 2: Install pip

After you have made sure that you have Python, it is time to install pip.

pip is a tool that enable us to easily install Django.

If you are not sure if you have pip on you computer, you can open your terminal and enter:

pip --version

Screen Shot 2014-11-12 at 6.02.47 PM

If you don’t have pip on your computer, you have to get the get-pip.py installation file. Download the following:

https://bootstrap.pypa.io/get-pip.py

curl -O https://bootstrap.pypa.io/get-pip.py

Afterwards, change directory to the location get-pip.py, go to your terminal, and enter:

python get-pip.py

 

Step 3: Using pip to install Django

After you make sure you have pip installed on your computer, go to the terminal and enter:

sudo pip install Django

You will need to enter the password of your computer. You can also specify a specific version of Django to install. Since the stable release at the time of writing is 1.8.2, I’ll show the command to install that version:

sudo pip install Django==1.8.2

 

Section 2 : Start a project

Step 1: Create a project

Open your terminal, cd to your Desktop or the place where you want to put your project and enter the following command:

django-admin.py startproject blog

Screen Shot 2014-11-12 at 6.13.19 PM

You will see a directory called blog appear on the Desktop. It contains all the framework file to help you generate your website.

Screen Shot 2014-11-12 at 7.07.10 PM

 

Step 2:

In your terminal, cd to into the blog folder and enter:

python manage.py runserver

You will probably see:

Screen Shot 2014-11-12 at 7.10.05 PM

Now, open a web browser. In the address file, enter the address that is showing in your terminal.

On the terminal and yours, by default, it will say http: //127.0.0.1: 8000

127.0.0.1 means localhost on every computer.

So I enter: http://localhost:8000 or http: //127.0.0.1: 8000 inside the web address of my browser, and it takes me to the default view of a Django site! You did it!

8 Steps to Install Cygwin on Windows

Cygwin provides the Linux feeling on Windows. With Cygwin, you can get a sizable Linux collection of GNU and Open Source tools including a terminal that supports POSIX interface on Windows.

Step 1)

Check whether your System type is 32 bit or 64 bit. If you have Windows 8 or 8.1, right click on This PC on your Desktop, then click on Properties. If you don’t have This PC on your Desktop, you can also use Windows’ search to look for “This PC“, then right click the icon, and click on Properties.

On the Properties of This PC, you can see the System Type underneath System category. For me, System type: 64-bit Operating System, x64-based processor. I have a 64 bit operating system.

Right Click on This PC, Click on Properties, and Look at your System type.

 

Step 2)

Go to https://cygwin.com/install.html

Select the blue linked executable setup based on your system type of Step 1. Download will start automatically after clicking on one of the blue executable setup links.

Click on the executable setup based on your System type. Download starts automatically.

 

Step 3)

Open the executable Cygwin setup file. Run the set-up as normal. Click on Next on the Cygwin Setup screen.

When choosing Installation Type, select Install from Internet (default). Click Next.

When choosing the Installation Directory, you can leave the root directory by default, which will be C:\cygwin64 (64 bit). Install for all users. Click Next.

The Local Package Directory contains the setup installation files for packages that you wish Cygwin to have. Underneath Select Local Package Directory, the default is the directory where you have the setup executable.

You can leave this by default.

For Setup your Internet Connection, use Direct Connection for your Internet Connection if you’re using wi-fi or ethernet. Click next.

Choose a Download Site. Select any of the download sites. Click Next.

Cygwin Setup

 

Step 4)

You’ll now be at Cygwin Setup – Select Packages. From here, you can search for packages that you wish Cygwin to have. The ones that I recommend are:

For each of these packages, they belong to categories. Search for a package. Click on the + next to a category to expand the contents of the search. Click on the circle twirl with the arrows to select the most up-to-date version of that package. Package names are on the right with a short description of that package.

Example of selecting the latest version of nano to install.

 

Step 5)

After selecting a version to install for all your packages, you can click the next button at the bottom right of the setup screen. At the Resolving Dependencies screen, make sure that the checkbox that says Select required packages (RECOMMENDED) is checked. Click Next. The download and installation of your desired packages will commence.

Resolving Dependencies.

 

Step 6)

After you finish the download and installation, you can check Create an icon on Desktop. Click Finish. You’ll find a program called Cygwin64 Terminal on your desktop. Open the program. Cygwin is installed.

Installation of packages has finished. Finish.

When you open Cygwin for the first time, Cygwin initializes.

 

Step 7)

You can also add the Cygwin packages and POSIX interface for the Windows command prompt. In other words, you can make the command prompt act like the terminal in Linux.

Right click on “This PC” and click Properties if it’s on the Desktop. Also, you can use Windows’ search for “This PC” and right click, then click on Properties.

Click on Advanced System Settings in this Properties window.

In the System Properties that pops up, click on Environment Variables, which will be within the Advanced tab. Inside Environment Variables, look underneath the System variables section. Scroll through and look for the Variable with the name Path. Click on that line. Click on the Edit button underneath. For 64 bit, add a “;C:\cygwin64\bin;” to the end of the Variable value line. This allows the command prompt to work with Cygwin’s directory path to the Cygwin’s bin folder and utilize Cygwin’s packages and POSIX interface. Click OK for each of the three windows to save this setting.

Cygwin’s path variable to work with the command prompt.

 

Step 8)

Open a command prompt. You can use Windows’ search and search for command prompt or cmd. Click on command prompt, and a command prompt black box will open. You will have all the functionality of Cygwin within the command prompt. You can choose to use either Cygwin or a command prompt to use the linux tools or POSIX interface.

Displaying SSH on a Windows command prompt.