Quick Reference

by Konrad Lorincz

 

Emacs  |  CVS  |  Latex  |  gcc | MySQL | Perl

 

Quick Reference Cards

 

 

Emacs
 
Add Figures (with sub-figures) side-by-side 

\usepackage{epsfig}
\usepackage{subfigure}

\begin{figure*}[tb]
  \begin{center}
    \subfigure[Caption of sub-fig a] % caption for subfigure a
    {
      \label{fig:sub:a}
      \includegraphics[width=7cm]{figures/cold-cache_join-indexed-2-rows_log-log.eps}
    }\qquad
    \subfigure[Caption of sub-fig b] % caption for subfigure b
    {
      \label{fig:sub:b}
      \includegraphics[width=7cm]{figures/cold-cache_join-indexed-3-rows_log-log.eps}
    }
    \caption{Caption for whole fig} % caption for the whole figure
    \label{fig:sub} 
  \end{center}
\end{figure*}

 

 

CVS

Importing a New Project

konrad@drdoom
~/cs265/project ; cvs import -m "Importing CS265 project" cs265/project cs265-corporation release-1_0

Add Directory and Everything Under it

cvs add myDirecotry
cvs add myDirectory/*
cvs ci -m "Added a directory myDirectory and everything under it"

Remove Directory and Everything Under it

rm -r myDirectory
cvs rm myDirecotry
cvs ci -m "Removed directory myDirectory and everything under it"
 

 

 

Latex
 

 

 

 

gcc (compiling in unix)

 

 

 

MySQL
  • MySQL Manual [HTML]
  • MySQL Reference Manual ver 4.0.6 [HTML]
Start MySQL
mysql -h host_name -u user_name -p
  (ex: mysql -u cs265 -p)
Load a database
USE asst2;  # MySQL keywords are not case sensitive
Show all databases SHOW DATABASES;
Load a database USE db_name;
Show the loaded DB SELECT DATABASE();
Show all tables in the loaded DB SHOW TABLES;
Show attributes of a table DESCRIBE attribute_name;
   
Querie Examples CREATE TEMPORARY TABLE username.FirstTen
SELECT name
FROM   Person
WHERE  id <= 10;
Execute a SQL script file from within mysql
source queries.sql
Create a file containing the outputs of your queries.
mysql -t -h mysql -p < queries.sql > output.txt
   
Export and Import a database
Make a backup copy of a whole database
    mysqldump --opt db_name > backup-db_name.sql
You can read this back into MySQL with: 
    mysql db_name < backup-db_name.sql
Use -u, -h, -p flags if necessary
Remove a table
DROP TABLE table_name;

 

 

Perl
  • Very good reference - regular expressions and examples [HTML]
  • More regular expressions and examples [HTML]
Quick-Replace
Replace certain characters in a file with another set of characters.
#!/usr/bin/perl
#

while (<STDIN>) {
    ($_ =~ s/( )+/\t/g); # replace 1 or more consecutive whitespances with tab
    print STDOUT $_;
}
Matching characters in Perl
if ( $line =~ m/(\d+):(\d+):(\d+.\d+)(.*)S\s+(\d+)\:\d+/ ) {
    $startTimeSec = $1*360 + $2*60 + $3;
    $startKBytes = $5/1000;
}
if ( $line =~ m/attach\s+120\(0\)\s+attach\s+121\(1\)\s+delay\s+(\d+\.\d+)/ ) {
    print STDOUT "---> Caught one \n";
}