Stata syntax highlighting for gedit

December 1, 2010 11 comments

For quite a while, I have been looking for a way to enable Stata syntax highlighting in gedit. Today, I stumbled across this thread:

The second poster (jcress410) wrote a .do file that generates the stata.lang file with the gtksourceview/gedit language specs.

Here’s how to make it work under Ubuntu 10.10:

1. Download the stata file & unzip it
2. Change to the unzipped folder and rename file styles to styles.csv
3. Change the value of the working_dir macro in line 9 in the file to the name of the unzipped directory
4. Run in Stata
5. Copy the generated stata.lang file to
/usr/share/gtksourceview-2.0/language-specs (for use by all users on the system, requires superuser privileges)
or to
~/.local/share/gtksourceview-2.0/language-specs (for use with your account only)
For the latter option, you may have to create the directory first:

mkdir -p ~/.local/share/gtksourceview-2.0/language-specs

6. Restart gedit.

.do files are now recognized automatically. For manual selection of the Stata Highlight Mode, go to View > Highlight Mode > Scientific > stata

Many thanks to Justin Cress for writing the syntax to generate the file!! You made my day!

Categories: Science

Using MPlayer as a music/guitar trainer

Say you are interested in figuring out how to play a blues lick in a video that somebody posted on YouTube. Here’s what you do:

Download the video to your computer using one of Firefox’ many video download extensions (e.g. Video DownloadHelper). Then fire up a terminal window and type

mplayer -af scaletempo -speed 0.5 '~/Desktop/myvideo.mp4'

This will open MPlayer playing the video at half speed (‘-speed 0.5’) while preserving the pitch. Of course, you can use values other than 0.5.

Categories: Sound, Video

Installing SAS 9.2 under Ubuntu 9.10 (Karmic)

March 29, 2010 Leave a comment

Insert the SAS installation disk and start the installation script with

sudo /media/cdrom0/

(The path to you CD-ROM drive may differ slightly.)

You need to provide the location of your SAS license file and of the Java Runtime Environment. For the latter, you can have SAS install version 1.5 for you. If you want to use your existing version, you can find it by typing

locate 'bin/java'

into a new terminal window.

If the system throws an error after starting the installation, click on the ‘Retry’ button and read the error message in the console window popping up. Most likely, it will be ‘/bin/sh: Illegal option -p’

This error message comes up if bash is not your default shell (it’s usually dash on a fresh Ubuntu install). You can easily change that by typing

sudo rm /bin/sh
sudo ln -s /bin/bash /bin/sh

into a terminal window. After that, the installation should run smoothly and you can accept all the default selections.
To create a Desktop or panel shortcut at the end of the installation, use

/usr/local/SAS/SASFoundation/9.2/sas -work /tmp

To restore dash as your default shell (dash has a lower overhead than bash), you can do

sudo rm /bin/sh
sudo ln -s /bin/dash /bin/sh

Categories: Hacks, Science

Installing StatTransfer 10 on Ubuntu 9.10 (Karmic)

March 18, 2010 Leave a comment

OK, here we go again… just as with Stata it’s great to have a Linux version of StatTransfer available but there’s some quirks to overcome before it will run smoothly.

Please note: Circle Systems (the makers of S/T) recommends that you install their software as a non-root user in your home directory. I personally prefer to separate my applications and my data, therefore I install it with sudo. If you are not sure what you are doing and you rather to be on the safe side, install S/T as a non-root user. In that case, you will only have to install that older C++ library version (see below) to make S/T run on your machine.

After downloading the installer file to your Desktop, open a terminal and do

chmod +x ~/Desktop/stlinux32_install # make file executable

sudo ~/Desktop/stlinux32_install # install it

The program will install in /usr/local/stattransfer10. A user configuration directory will be created in your /home folder. Because you installed with sudo, the file is owned by root. Doing

sudo chown -R yourusername:yourusername ~/.stattransfer10

will make the file readable and writable for you.
Now try to start S/T using the Desktop shortcut. If the GUI comes up, you can proceed with the licensing procedure. If not, try to start it from the Terminal


Chances are you get an ‘ error while loading shared libraries: cannot open shared object file: No such file or directory’.

I tried the symbolic link trick that worked so well with Stata but it didn’t cut no ice with StatTransfer. However, installing an older version of libstdc++ worked. Download the package and install by doing

cd ~/Desktop
sudo dpkg --install libstdc++5_3.3.6-17ubuntu1_i386.deb

To activate your copy, you have to run S/T as root:

sudo /usr/local/stattransfer10/stattransfer

Go to About, press Activate Online, and follow the instructions. Once activated, run S/T only as a non-root user.

Categories: Hacks, Science

Tune the OpenOffice Startup

February 5, 2010 Leave a comment

Remove the ugly brown splash screen
sudo sed 's/Logo=1/Logo=0/' -i /etc/openoffice/sofficerc

Disable the automatic loading of the Java Runtime Environment on startup
Go to Tools > Options > > Java and remove the checkmark for ‘Use a Java runtime environment’

You are in business.

Categories: Hacks, Office

Run Stata 10/11 with GUI under Ubuntu

January 24, 2010 19 comments

Stata 10/11 are available for Linux, which is great but… after installing Stata (dynamically linked) under Ubuntu, starting the GUI version (xstata) usually results in an error message because one or more libraries apparently cannot be found.

By adding the corresponding symbolic links

sudo ln -s /usr/lib/libgtk2.0-0 /usr/lib/libgtk-1.2.0

sudo ln -s /usr/lib/ /usr/lib/

sudo ln -s /usr/lib/ /usr/lib/

Stata can be tricked into using the newer version instead of the old version it is expecting.

As Julian pointed out below, Stata 11 may close unexpectedly when starting the .do file editor. If that happens (I reproduced that bug on a fresh Karmic install), installing libgtksourceview 1.0 may fix the problem:

sudo apt-get install libgtksourceview1.0-0

Natty Narwhal update: After upgrading to 11.04, I got an error message (“error while loading shared libraries: cannot open shared object file: No such file or directory.”) when trying to run Stata. I fixed it by creating another symbolic link:

sudo ln -s /usr/lib/i386-linux-gnu/ /usr/lib/

Oneiric Ocelot update: Thanks to Charles Opondo for pointing out that libgtksourceview1.0 is not in the Oneiric repos.
You can either 1) download and install libgtksourceview from the Natty repos or 2) re-install the statically linked version of Stata.

– Option 1 –
cd ~/Desktop
sudo dpkg --install libgtksourceview-common_1.8.5-2build1_all.deb
sudo dpkg --install libgtksourceview1.0-0_1.8.5-2build1_i386.deb
rm libgtksourceview*.deb

– Option 2 –
Delete your Stata installation in the /usr/local/stata folder and re-install it from the disk. During the installation, Stata asks whether you want to install the 32-/64-bit dynamically/statically linked version. Choose statically linked.

Whichever way you choose, please update Stata 11 after installing it before doing any analyses. There is a serious bug in the original CD version that can completely muck up your results. You have to run Stata as a superuser to do that

sudo /usr/local/stata/xstata

Replace xstata with xstata-se if you are using Stata/SE.
Then, in Stata, type update all and when prompted update swap. When you are done, restart Stata as a normal user. It should now say “Stata 11.2” in the title bar.

Categories: Hacks, Science

File sharing with Python from the command line

January 24, 2010 Leave a comment

Can’t remember where I found this nifty little trick. Running

python -m SimpleHTTPServer 1234

at the command line starts an HTTP server in the current working directory. Other people on the same network can then access the files in this directory by pointing their browser to

1234 is just an arbitrary port number. You may choose (almost) any other port number you like.

Categories: Networking