Dynamic On-Demand LaTeX Compilation

Most of the existing approaches to integrating LaTeX compilation into a LaTeX writing workflow centered around a text editor (as opposed to a fancy-schmancy IDE) are horrendously bloated creatures, aggressively and voraciously hijacking so many key-mappings and normal functionality that it makes your Vim feel like it is diseased and is experiencing a pathological personality disorder of some kind. Yes, LaTeX-Suite, I am looking at mainly at you. I did not want a platoon of obnoxiously cheery elves to insert two hundred environments into the document while a marching band parades around the room when I hit the \$ key.

Read more

Setting up the Text Editor in My Computing Ecosystem

Image from WikiMedia Commons Basic Setup of Shell to Support My Text Editor Preferences By “text editor”, I mean Vim, of course. There are pseudo-operating systems that include rudimentary text-editing capabilities (e.g. Emacs), and integrated development environments that allow for editing of text, but there really is only one text editor that deserves the title of “text editor“: Vim, that magical mind-reading mustang that carries out textual mogrifications with surgical precision and zen-like elegance.

Read more

Smart (`infercase`) Dictionary Completions in Vim While Preserving Your Preferred `ignorecase` Settings

Dictionary completions in Vim can use a ‘infer case’ mode, where, e.g., “Probab” will correctly autocomplete to, e.g., “Probability”, even though the entry in the dictionary might be in a different case. The problem is that this mode only works if ignorecase is on. And sometimes, we want one (infercase) but not the other (ignorecase). The following function, if added to your “\~/.vimrc”, sets it up so that ignorecase is forced on when dictionary completions are invoked via the `` keys, and then restored to its original state when exiting.

Read more

Building MacVim Natively on OS X 10.7 and Higher

You might want to do this if you want to install the latest snapshot and no pre-built release is available. OR you might want MacVim to use a custom Python installation instead of the default one on the system path. This latter was my motivation. Once you have downloaded and unpacked the code base that you want to build, step into the `src/` subdirectory: $ cd src Before proceeding, make sure that your Python installations have been built with the “``--enable-shared``”!

Read more

Using Python's 'timeit' Module to Benchmark Functions Directly (Instead of Passing in a String to be Executed)

All the basic examples for Python’s timeit module show strings being executed. This lead to, in my opinion, somewhat convoluted code such as: #! /usr/bin/env python import timeit def f(): pass if __name__ == "__main__": timer = timeit.Timer("__main__.f()", "import __main__") result = timer.repeat(repeat=100, number=100000) print("".format(min(result))) For some reason, the fact that you can call a function directly is only (again, in my opinion) obscurely documented. But this makes things so much cleaner:

Read more

'xargs' - Handling Filenames With Spaces or Other Special Characters

xargs is a great little utility to perform batch operations on a large set of files. Typically, the results of a find operation are piped to the xargs command: find . -iname "*.pdf" | xargs -I mv ~/collections/pdf/ The -I tells xargs to substitute “ in the statement to be executed with the entries being piped through. If these entries have spaces or other special characters, though, things will go awry.

Read more

YonderGit: Simplified Git Remote Repository Management

One of the great strengths of Git is the multiple and flexible ways of handling remote repositories. Just like Subversion, they can be “served” out of a location, but more generally, if you can reach it from your computer through any number of ways (ssh, etc.), you can git it. YonderGit wraps up a number of a common operations with remote repositories: creating, initializing, adding to (associating with) the local repository, removing, etc.

Read more

Simple Way to Build the GCC Suite from Scratch

Gist 5224956 #! /bin/bash GCC_VERSION="5.2.0" WORKDIR="$HOME/src/" INSTALLDIR="/platform" ## NOTE: XCode must be installed (through App Store) and the following run to install command-line tools. ## THIS IS IMPORTANT! Among other things, it creates '/usr/include' and installs the system header files. # xcode-select --install # get the source code cd $WORKDIR wget http://www.netgull.com/gcc/releases/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.bz2 tar -xf gcc-${GCC_VERSION}.tar.bz2 # download the prerequisites cd gcc-${GCC_VERSION} ./contrib/download_prerequisites # create the build directory cd .

Read more

Some Vim Movement Tips

Within-line character-based movement: h and l move you left and right one character, respectively. f[c] or F[c] will take you forward to the next or back to the previous, respectively, occurrence of character “[c] on the current line (e.g.,fpwill jump you forward to the next occurrence of "p" on the line, whileFp` will jump you back to the previous occurrence of “p” on the line). t[c] or T[c] will take you forward to just before the next or back to just after the previous, respectively, occurrence of character “[c]` on the current line.

Read more

Safe and const-correct std::map Access in C++ STL

The Standard Template Library std::map[] operator will create and return a new entry if passed a key that does not already exist in the map. This means that you cannot use this operator when you do not want to create a new entry (i.e., you expect the key-value pair to already exist in the map), or in a const context (i.e., in a const method or when using a const object).

Read more