Category Archives: Tricks

Automated way to check for PGF version

This is one way to check for the version of PGF that is installed in an automated way. First create a tex file with the following contents:


Say you named it test-pgf-version.tex. Then:

pdflatex test-pgf-version.tex
cat test-pgf-verson.log | grep PGFVersion | sed ‘s/PGFVersion=//’

should display the version number. I happen to need to do this from R so using similar logic:

logFile <- ‘testpgfversion.log‘    
logContents <- readLines( logFile )
match <- logContents[ grep(‘PGFVersion=‘, logContents) ]
version <- gsub([=AZaz]‘,”,match)

which accomplishes the same task as the second line above.

Using Git with R-Forge OR Adding an local Git branch to track an Subversion Repo

These instructions were originally from instructions from my friend Charlie.

I really like to use Github but R-Forge has alot of nice features for package development, so why not get the best of both worlds.

Say you have a git repo (with an R package or something else) but want to create a local brach which tracks an svn repo (from R-Forge) such that you can merge changes from your git repo in and then commit them to svn. First use the following command to grab the current svn:

cd my-r-package
git svn clone svn+ssh:// .

This will create a new git repository that is a mirror of whatever svn repo you pointed at. This may take a while if you have a big existing svn repo.

If you want to add a svn bound branch to an existing git repo:

Edit .git/config and add the following:

[svn-remote "r-forge"]
  url = path/or/url/to/svn/repository
  fetch = :refs/remotes/r-forge-svn

Once you’ve done this, you have created an entry for a new git remote server- fetch the status and history of it’s branches using the following:

git svn fetch r-forge

If this command is successful, git branch -a should show:


In the list of available branches. This branch is a remote branch- to make a local copy, do the following:

git checkout r-forge-svn
git checkout -b r-forge-svn-local

Now you have a local branch which is bound to the svn server- once again straight up adding/removing/moving files in this branch should work fine. It’s merging that gets you into trouble.

How to merge between a git branch and a git-svn branch

The point is that you don’t want git infecting your subversion repository with any of its awesomeness. Exposure to the kind of concentrated badass possessed by git causes poor SVN’s head to pop. So, the merge must be done as follows:

git checkout r-forge-svn-local
git merge –squash branch-to-merge-in

The --squash option tells git to leave out any info about what happened during the merge and act like it just mashed a bunch of files into your svn branch using copy commands.

Once you’ve added/copied/moved/squashmerged new files into your local svn branch- do the following to push the changes to the svn repo:

git commit -a               (Commit changes to your git repo as normal.)
git svn dcommit           (This will form each git commit into a svn commit and send it to the svn repo)

To pull changes from the svn repo run the following:

git svn rebase

Trick Gmail into checking POP3 more often

I finally got sick of gmail only checking my POP3 account every hour or so, so I resolved to fix it. If you google this, there are numerous solutions, I thought I would share my experience. I have access to a web/mail server so I used that.

(1) Log on to the server. (2) Create the script ~/.mailthis

echo "x123456789x" | mail

(3) Then edit your crontab with crontab -e and put the following in there

* * * * * /path/to/.mailthis

You must put the absolute path here. This will send a mail to your pop3 account every minute.

(4) Finally create a filter in Gmail that says any message with the word x123456789x in it, delete it. That way you don’t spam yourself.

Thats it, now gmail will check your mail every minute since you are getting messages every minute.