Improving Your Workflow So I Don’t Feel Like Killing You for Typing like My Grandma

No IDE’s in this class (Integrated Development Environment)

  1. Eclipse
  2. IntelliJ
  3. Visual Studio
  4. XCode
  5. Others <When in doubt, ask me, and I’ll say no>

Why does Chander care that my workflow is bad?

Unfortunately for both of us, I’m your TA. This means you’re going to ask me questions. Which means I’ll stroll over to your laptop to explain things to you. And when you inevitably type / navigate / work like a slow old blind person, I will stab my eyes out with the nearest fork, and in my blind rage, flail violently until I kill you.

To prevent your death and my life sentence, let’s work together on this and not type like old, slow people.

Application Launcher

What in the heck is an application launcher? An application launcher is a tool to quickly launch applications (duh). Rather than going through the Mac “Dock”, or going through Applications folder, (or whatever horrific thing you windows users do now that the Start menu is gone,) this application’s sole purpose is helping you to quickly and speedily launch things.

Examples:

If you’re on a Mac, I recommend Quicksilver.

By the way, I assume you all know that CMD-<Tab> and CMD-Shift-<Tab> are ways to quickly cycle through your programs, yes? And CMD-~ is to cycle through windows belonging to the same program. Please tell me you knew that already. (CTRL for linux users, and Windows key for Windows users.)

Purpose: So you don’t take 3 minutes just to open an application.

Terminal Navigation

This is something more directly related to the “not type like an old person” theme. Whenever I see someone press backspace / delete more than 9 times in a row, it makes me want to claw my eyes out.

Here are some short-cuts you should all commit to memory:

Name Description
C-W Delete 1 word back. A word is defined as the last whitespace
C-A Go to the beginning of the line
C-E Go to the end of the line
C-R Search through history in reverse
Esc-b Go one word backwards
Esc-f Go one word forwards

Those of you who are familiar with Emacs will realize that these are the same navigation commands! That’s true. Remember, most terminals will use Emacs-style navigation. So your python interpreter? Same thing. Your MySQL interpreter? Same thing.

If you use your up and down arrow keys, you will start cycling through your history of past commands. So if you want to repeat a command you just did, just hit the up arrow and press Enter.

There are, of course, many many more. The more you learn the more you know. And the less of a n00b (that’s a technical term) you seem.

If you decide you’re a hard-core vi kind of gal, you can switch your shell to use vi navigation instead! set -o vi. If you have regrets after doing so, just go back with set -o emacs.

Tab completion is another important feature. Most shells by default tab complete on filenames, which means if there’s a file called sample.txt, you can just type cat s-<TAB>and it will auto-complete to cat sample.txt.

It disambiguates by using the least characters to get uniqueness. So if there’s another file called sniffles, s alone isn’t enough to know what file you mean. So if you hit cat s-<TAB>-<TAB>, it will output sniffles and sample.txt because those are the two files that begin with s.

If you then hit cat sn-<TAB>, it will correctly fill in sniffles because there are no other files that begin with sn, and so the disambiguation is complete.

Vim-Style Navigation

Although many things use Emacs-style navigation, there are also many programs and commands that use Vi-style navigation. For example, man and less both display the results using a buffer that navigates like Vim. So it’s useful to learn.

Name Description
gg Go to beginning of file
G Go to end of file
C-f Forward by a page
C-b Backward by a page
j Up by 1 line
k Down by 1 line
q Quit

Get a Good Terminal Application

A good terminal application can be the world of a difference. You will spend most of your time as a developer here, just like you spend 1/3 of your day sleeping. Investing in a good bed, like a good terminal, will lead to a much happier life. I promise.

If you’re on a Mac, get iTerm2 . But not all of you use Macs. Here are awesome features your terminal should have:

If you’re on a Mac, I strongly recommend iTerm2.

There are so many damn themes out there. Find one you like. Get a terminal with 256 colors, and it will make your world beautiful. Or, if you’re like me and believe the world is a horrible place with no happiness, the ever-popular IR_Black is the one for you (and here is IR_Black for the iTerm2 crowd).

Text Editors Are the New Religion

You will not be allowed to use IDE’s in this class. We are here to learn how to hack (no, not crackers). As such, you will now live in the terminal. Welcome home!

There are many, many text editors out there. Without a doubt, though, the three most popular ones are the following:

  1. Vim
  2. Emacs
  3. Sublime

Honorable mentions go to Text Wrangler and Notepad++, both of which were extremely popular once upon a time and are still widely used. Sublime is a relatively new player in this - both Vim and Emacs have been around for decades. (To be fair, not quite accurate. Vim stands for V i Im proved. Vi is the really old school one.)

Which you pick doesn’t really matter, so long as you become really proficient. Watching someone who doesn’t know how to navigate their way around a text editor is even more painful than not knowing how to navigate around a terminal. Seriously.

There is a huge debate between Emacs and Vim for first place; there has been for decades, and there will continue to be.

The war is silly, and those of us affected by it personally have found it especially hard. I used to have many good friends. There was a time when we didn’t know… Perhaps it’s better to not know. How I wish for the days of innocent not knowing. Imagine my surprise when my best friend turned out to be an Emacs user. That was the last I heard from him.

Jokes aside, I have a very strong bent towards Vim. Here is my fair attempt at being neutral:

If you wish to be productive immediately and cannot invest time in learning, use Sublime. If you have just a little bit of time, learn to use Emacs. If you have lots of time to invest, but seek the best rewards, learn to use Vim. The learning curve is not for the faint of heart, but its rewards are boutiful and shall lead ye to the promised land.

There are several important differences though.

But why would I ever have to learn these?

I’m going to leave it at this for now. I could honestly give a whole separate recitation lecture just on Vim. I won’t - but if anyone is curious, let me know. If there’s enough interest, I will give an optional lecture on the best parts of vim, the best plugins, etc.

Configuring Your .bashrc / .bash_profile

If you’re on a Mac, it’s your .bash_profile. Otherwise, it’s .bashrc. Learning to configure this to your liking is essential. You’ll be spending a lot of time here.

Common examples:

All this and more will one day be yours, if only you spend the time to configure your .bashrc. For those of you interested, a new religious war is starting between BASH (the Bourne Again Shell) and zsh. zsh is incredibly useful, and I don’t mind if you use it provided that all your scripts be compatible with bash as well.

bash, regardless of what you say, is ubiquitous on all corporate servers. It is absolutely essential that you be familiar with it. zsh is more or less a superset of BASH, which is fine. But it does mean all your scripts cannot use features present in zsh but not in bash.

Configuring your bash prompt so it displays useful things is also super nice. There are lots of things to do here, so explore lots!

Windows people: Install Cygwin. Or get a linux box. Or whatever. Get your shit together is what I’m saying basically.

Screen / TMux

Unfortunately, SSH isn’t going away anytime soon. You’ll use it everywhere. When we can, we should, of course, edit locally on our laptops. But sometimes it’s unavoidable that we simply must edit on a remote server. So we use SSH and decide we’re going to do stuff there. Fine.

But imagine for a moment that you’re working on a fairly large project (as you will be in a month’s time). You have to edit 6 different files, you’re running 3 different programs simultaneously, and all of a sudden, you have an ungodly 9 terminal windows (or tabs or whatever) opened up!

Navigating through 9 tabs is miserably painful! And you curse SSH and its creaters (incidentally S, S, and H… lol jk not this acronym…) and proclaim unto the heavens “Isn’t there a better way!?”

Why yes, there is. You have 2 options in fact, so you have 2 better ways.

  1. Screen
  2. tmux

The Hacking Spirit

I just wanted to say a few words about this course before I leave you today.

This is not an intro level course. It’s no longer CS1, where after trying to debug for 10 seconds you could run to a TA. The purpose of this course is to make you really, fully ready for an internship or serious job. On the job, when handed a task, you don’t run to your manager with every little tiny question.

You figure it out.

Of course there are times when you ask a co-worker, and of course there are times when you can receive help. But the point is that you should value other people’s time. So if you don’t spend the due diligence of searching through every possiblity and wracking your brain for answers, not only will you never get better at debugging (which, o-m-g, as it, like so totally turns out, is a skill and not some gift granted by the gods), you will waste the instructors’ time and your classmates’ time as well.

Think about debugging strategies. Use process of elimination. Try the same thing but on a much simpler, smaller problem to isolate the bug. Use google. Search stackoverflow. Use whatever means you can (honor code obviously applies) of solving the problem, and if you still can’t figure it out, then come to us, but as a last resort.

The final thing I wanted to say is get some of what I call “The Hacking Spirit”. Get an eagerness to try things out because it will serve you well. You have at your figertips the most powerful computers ever made. So many people would have killed to get these kinds of tools at their disposal.

Reading about it is boring - that’s what my cousins in India are doing because they don’t have the money to get computers like these. They watch videos of people doing the things they wish they could be doing.

So do it! Have fun with it. Try it out, see what happens. You learn by doing.

Oh Yeah - the Lab

Things to keep in mind