Quick Refs
This page containts a simple list of links and references that can come in handy on the go. These include some of my most used dotfiles (pulled from GitHub).

Useful Links

List of CSS web-safe fonts: http://www.w3schools.com/cssref/css_websafe_fonts.asp
Google C++ style guide: http://google.github.io/styleguide/cppguide.html
LaTeX equation generator: http://www.codecogs.com/latex/eqneditor.php
Burnt orange color info: https://www.utexas.edu/brand-guidelines/visual-style-guide/color


vim Tips

Automatically format a comment block: (v) highlight, (e) gw
Insert TAB character with expandtab enabled: (i) ctrl+v, TAB
Do a case-insensitive search: (/) preface search string with \c


.bashrc

# set dotfiles directory (where setup was run)
dotfiles_dir=$HOME/Dotfiles  # TODO: automate w/ setup script?


# detect platform
OS=`uname`


# customize the terminal prompt message:
# [h, n] user@computer:directory $
# where h = command history number, and n = number of running processes
export PS1='\u@\[\e[1m\]\h\[\e[0m\]: \W $ '


# add ~/Scripts and ~/bin to PATH (list of executables for this account)
export PATH=$HOME/Scripts:$PATH
export PATH=$HOME/bin:$PATH

# Also add specific UT Austin scripts.
export PATH=$HOME/Scripts/UTA:$PATH

# if a local bashrc is also defined (for this machine only), source
# that to add the required local setups.
local_bashrc_file=$dotfiles_dir/.bashrc_local
if [ -a $local_bashrc_file ]; then
  source $local_bashrc_file
fi

# add ~/lib to library path
# TODO: this is a local export and shouldn't be in the repo
export LD_LIBRARY_PATH=~/lib/:/lusr/opt/gcc-4.8.2/lib64/:$LD_LIBRARY_PATH


# make "ls" show results in color
# TODO: have different setup scripts for each OS and source them as needed
# OS X:
if [[ $OS == 'Darwin' ]]; then
    export CLICOLOR=1;
    export LSCOLORS=GxFxCxDxBxegedabagaced;
# Linux:
else
    alias ls='ls --color=auto';
fi


# source all other bashrc files

# aliased commands
source $dotfiles_dir/.bashrc_alias_commands

# custom function definitions
source $dotfiles_dir/.bashrc_functions


.vimrc

set smartindent
set tabstop=2
set shiftwidth=2
set expandtab
set ruler
syntax on
let g:loaded_logipat = 1



Example CMakeLists.txt

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
set(proj_name IVFeatures)
set(proj_bin ivfeatures)
project(${proj_name} C CXX)


# Set the compiler to C++11:
# http://stackoverflow.com/questions/10851247/how-to-activate-c-11-in-cmake
set(CMAKE_CXX_FLAGS "-std=c++11")


# Add PCL to the package:
find_package(PCL 1.3 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})


# Build for the main executable:
file(GLOB proj_src "src/*.h" "src/*.cpp")
add_executable(${proj_bin} ${proj_src})
target_link_libraries(${proj_bin} ${PCL_LIBRARIES})


# Add gtest (the Google test library) to the package:
find_package(GTest REQUIRED)
find_package(Threads REQUIRED)
set(proj_include "src/")
include_directories(${GTEST_INCLUDE_DIRS} ${proj_include})


# Set up tests.
enable_testing()
set(proj_test_bin ${proj_bin}_test)
file(GLOB proj_test_src "test/*.cpp")
add_executable(${proj_test_bin} ${proj_test_src})
add_dependencies(${proj_test_bin} googletest)
# Find the GTest library files.
find_library(gtest_lib gtest libgtest.a libgtest)
find_library(gtest_main_lib gtest_main libgtest_main.a libgtest_main)
# Find the GMock library files.
find_library(gmock_lib gmock libgmock.a libgmock)
find_library(gmock_main_lib gmock_main libgmock_main.a libgmock_main)
# Link the located gtest and gmock libraries to the test binary.
target_link_libraries(${proj_test_bin} ${gtest_lib} ${gtest_main_lib})
target_link_libraries(${proj_test_bin} ${gmock_lib} ${gmock_main_lib})
# Link threads library to the test binary.
target_link_libraries(${proj_test_bin} ${CMAKE_THREAD_LIBS_INIT})
# Adds test to Makefile (run "make test"):
add_test(test1 ${proj_test_bin})



Example Makefile

# Makefile for Spherical K-Means code


# Galois path (needs to be installed and specified here)
GALOIS_PATH_RAW = ./../../../Galois-2.2.1

# For 64-bit systems, try to use the 64-bit installation.
BITS = $(shell getconf LONG_BIT)
ifeq ($(BITS), 64)
GALOIS_PATH = $(GALOIS_PATH_RAW)_64
else
GALOIS_PATH = $(GALOIS_PATH_RAW)
endif


# specify flags and compiler variables
EXE = spkmeans
COMPILER = /usr/bin/g++
FLAGS = -DNDEBUG -g -O3 -ffast-math -fopenmp -std=c++0x
SRC_DIR = src
OBJ_DIR = obj


# specify source files
SRC_FILES = main.cpp reader.cpp vectors.cpp timer.cpp cluster_data.cpp spkmeans.cpp spkmeans_openmp.cpp
GALOIS_SRC_FILES = spkmeans_galois.cpp
OBJ = $(addprefix obj/, $(SRC_FILES:.cpp=.o))
GALOIS_OBJ = $(addprefix obj/, $(GALOIS_SRC_FILES:.cpp=.o))
SRC = $(addprefix $(SRC_DIR)/, $(SRC_FILES))
GALOIS_SRC = $(addprefix $(SRC_DIR)/, $(GALOIS_SRC_FILES))


# specify libraries and include sources
GALOIS_INCLUDES = -I$(GALOIS_PATH)/build/release/include -I$(GALOIS_PATH)/include
GALOIS_LINKS = -L$(GALOIS_PATH)/build/release/src -lgalois
LINKS = -pthread -ldl


# set a flag if the Galois library path exists and if galois was installed
GALOIS_EXISTS  = $(shell if [ -d $(GALOIS_PATH) ]; then echo y; fi)
GALOIS_EXISTS += $(shell if [ -d $(GALOIS_PATH)/build/release/lib ]; then echo y; fi)


################################################################################
################################################################################


all: prep compile

prep:
	@mkdir -p $(OBJ_DIR)

# if Galois is installed, compile everything:
ifeq ($(GALOIS_EXISTS), y y)
$(OBJ): $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
	@echo "Compiling $@..."
	@$(COMPILER) $(FLAGS) $(GALOIS_INCLUDES) -c -o $@ $<
$(GALOIS_OBJ): $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
	@echo "Compiling $@..."
	@$(COMPILER) $(FLAGS) $(GALOIS_INCLUDES) -c -o $@ $<

compile: $(OBJ) $(GALOIS_OBJ)
	@echo "\nBuilding executable:"
	$(COMPILER) $(FLAGS) $(GALOIS_INCLUDES) $? -o $(EXE) $(GALOIS_LINKS) $(LINKS)
	@echo "\nCompilation complete: success!\n"

# otherwise, if Galois is not installed, compile without it:
# TODO - else ifeq($(GALIS_EXISTS), y) ... only works in new version of make
else
	@echo "\nGalois library not found... compiling without it.\n"
$(OBJ): $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
	@echo "Compiling $@..."
	@$(COMPILER) $(FLAGS) -c -o $@ $< -D NO_GALOIS

compile: $(OBJ)
	@echo "\nBuilding executable:"
	$(COMPILER) $(FLAGS) $? -o $(EXE) $(LINKS) -D NO_GALOIS
	@echo "\nCompilation complete: success!\n"
endif

################################################################################

# Remove the executable and object files
clean:
	@echo "Deleting object files and executable:"
	rm -f spkmeans
	rm -rf $(OBJ_DIR)


################################################################################
################################################################################


# Run test with a small test file, with different versions:
TESTCMD = ./spkmeans -d ../TestData/documents --autok --noresults
test:
	$(TESTCMD)
# OpenMP version:
testo:
	$(TESTCMD) --openmp
# Galois version:
testg:
	$(TESTCMD) --galois


# Run with the larger test data set:
run:
	./spkmeans -d ../TestData/documents --auto --noresults --galois


# Compare two versions with small dataset
COMMAND = -d ../TestData/documents --auto --noresults
comp:
	./spkmeans $(COMMAND); ./spkmeans2 $(COMMAND)


# Compare two versions w/ big dataset
COMMAND2 = -d ../TestData/classic3 --auto --noresults --noscheme
comp2:
	./spkmeans $(COMMAND2); ./spkmeans2 $(COMMAND2)


# Compare two versions w/ bigger dataset
COMMAND3 = -d ../TestData/mat -k 50 --noresults --noscheme
comp3:
	./spkmeans $(COMMAND3); ./spkmeans2 $(COMMAND3)


# Compare two versions w/ biggest dataset
COMMAND4 = -d ../TestData/news20 -k 200 --noresults
comp4:
	./spkmeans $(COMMAND4); ./spkmeans2 $(COMMAND4)


# Debug with GDB (running on larger test data set):
#debug:
#	gdb ./spkmeans ../TestData/documents