Some of you probably already know about this, but I just discovered it and wanted to share.
Tired of typing in the same terminal commands all the time? Try this:
alias cy='ssh -Y email@example.com'
Now when you type “cy” in the terminal, it automatically replaces it with the command you specify in quotes.
You can do this for each session, but even more helpful is to put these alias commands in your .bashrc file so that they are run whenever you start bash (the “rc” in “bashrc” stands for “run commands” … at least I think it does). If you’re using cygwin, this file will be located at C:\cygwin\home\(your username)\.bashrc. Open it in a text editor and put your alias commands somewhere in the middle. (On the cluster, your .bashrc file is located in your home directory, ~.)
Some useful possibilities:
- On your computer, create aliases to log into different clusters (“cy” for cyberstar, “lx” for Lion-XO, etc.)
- On the cluster, create aliases for common queue operations (“qme” for “qstat -u jdh33”, for example, which is a good idea I got from Ryan. Or “killall” for “qdel $(qselect -u jdh33)”. Pretty handy!)
- Any long commands you find yourself repeating can be aliased! Just be careful not to overwrite any existing Linux commands when you do it.
You can check your current aliases at any time by running alias without any arguments.
That’s all, thanks for reading.
This post details the programming languages commonly used in our group. For each language, we have included installation instructions, suggested reading materials, and other notes.
The ternary operator (the question mark and colon in the expression a ? b: c) is a tricky one. It’s use is relatively uncommon, but it’s present in many programming languages, and sometimes it drastically simplifies a conditional assignment. I bring it up because it was in the first version I saw of the GAA objective function, and it was doing something it shouldn’t have been. Before I took up the GAA problem, some of the work involved allowing a 3 percent constraint violation. This was still present in the objective function when I got my hands on it, although we no longer wanted to allow a 3 percent constraint violation.
Here’s what it looked like:
constr = CV_TOTAL > 0.03 ? CV_TOTAL : 0.0;
What it does is assign CV_TOTAL to constr only if CV_TOTAL is greater than 0.03, and otherwise it assigns 0 to constr. It works this way because in general, the expression a ? b : c evaluates to b if a is true, and to c if a is false. So writing d = a ? b : c is a shorthand way of saying, “assign b to d if a is true, and assign c to d if a is false.” And what it does in this case is allow 3% constraint violation.
My advice: there’s nothing wrong with using the ternary operator, but don’t be stingy with your comments. Writing it like this could save you a lot of time:
constr = CV_TOTAL > 0.03 ? CV_TOTAL : 0.0; // allow 3% constraint violation!
Of the languages that I’ve used, the ternary operator shows up in this form in C, C++, Java, and Ruby.