Archive for the ‘utilities’ Category

Record screencasts, convert to Flash, and embed on your site

Saturday, May 3rd, 2008

Here’s a step-by-step tutorial of creating a screencast, converting it into an .flv file, and uploading it to your site with an embedded Flash player. (more…)

Use Sphinx for documentation

Friday, April 25th, 2008

I’ve been doing quite a bit of code documentation lately, and I decided to try and figure out the best tool to use. I found it. It’s called Sphinx, and you can see what the documentation looks like by checking out the documentation for Python itself (v. 2.6 and 3.0).
Here’s how to get started using Sphinx. (more…)

Persistent SSH sessions

Thursday, March 13th, 2008

The screen program, among other useful things, lets you keep an SSH session running even after you disconnect from SSH. Here’s how to use it.

SSH in.

ssh user@hostname.com

Once on the remote machine, set up a named screen:

screen -S myscreen

In another terminal, open another SSH connnection and start another screen:

screen -S mysecondscreen

You can see they are there by using, in either of the terminals,

screen -ls

This does NOT start screen, just lists the different screens.

You can now disconnect the SSH connections. When you reconnect, you can use

screen -r myscreen

or

screen -r mysecondscreen

to reconnect to the one you want.

Setting up and using an SVN repository

Thursday, March 13th, 2008

Install subversion (Ubuntu)

sudo apt-get install subversion

Make a directory to store the repositories

mkdir /path/to/repository

Create the repository

svnadmin create /path/to/repository

Import existing files into repository

svn import /path/name/to/foo file:///path/to/repository

when you checkout this repository, it will create the directory foo. So to get the svn repository in my ~/work directory as ~/work/foo I would go to ~/work, then

svn co file:///path/to/repository

that is, don’t make a new dir dir called foo and import into there . . . it will make its own dir.

Check out locally

svn checkout file:///path/to/repository /local/workdir

Check out remotely through an ssh connection

svn checkout svn+ssh://user@hostname/path/to/repository/on/remotehost /local/workdir

Update local copy from SVN

svn update

Check what’s been changed

svn status

Resolve a conflict

svn resolved filename

Send these changes to SVN (editor will prompt for revision notes, must be non-empty)

svn commit

Send these changes to SVN, and specify logfile to send as comments

svn commit -F logfile

A more secure SSH configuration

Thursday, March 13th, 2008

Some easy ways to configure SSH to be a little more secure:

Edit /etc/ssh/sshd_config as root.

  • Change the port (default is 22)
  • Change “PermitRootLogin yes” to “PermitRootLogin no”
  • AddUser username
  • save and quit
  • restart the ssh server: sudo /etc/init.d/ssh restart

More info here:
http://ubuntu-tutorials.com/2007/02/14/what-you-ought-to-know-about-securing-ssh/

SSH: Add public key to remote server

Thursday, March 13th, 2008

Easy way to add public key of this machine to a remote machine:

ssh-copy-id -i ~/.ssh/id_dsa.pub root@fileserver01

More good info here:
http://ubuntu-tutorials.com/2007/02/05/unattended-ssh-login-public-key-ssh-authorization-ssh-automatic-login/

Remote MySQL using SSH

Thursday, March 13th, 2008

Step 1: SSH forwarding

First, forward the local port 3307 to 3306. That is, when you access the local port 3307, it will redirect it to port 3306 on the remote host.

ssh -fNg4 -L 3307:127.0.0.1:3306 user@hostname

-f sends SSH to the background
-g allows remote hosts to connect to local forwarded ports
-N don’t execute a remote command
-4 this was key! Forces IPv4. Kept getting “bind: Address already in use” errors because I didn’t have this.
-L the forwarding magic happens here . . . syntax is localport:localhost:remoteport

Step 2: Connect to mysql on port 3307

. . . which will redirect to port 3306 on remote host.

mysql -u root -h 127.0.0.1 -P 3307 -p

and you’re in!

Converting between SVG, EPS, and PDF

Tuesday, February 12th, 2008

Sometimes you want to be able to tweak a plot in R that was saved as a PDF or an EPS.

Use this to convert an eps into svg for editing in Inkscape:

pstoedit -f plot-svg input.eps output.svg

Then save the SVG in Inkscape as a “Plain SVG”, and use

convert input.svg output.pdf

Split the pages out of a PDF, or merge PDFs into one

Sunday, January 27th, 2008

Using the free open source program PDF Toolkit, you can operate on PDFs quite easily. (more…)

Convert images into a movie with mencoder

Saturday, January 26th, 2008

Here’s how to create a movie out of a collection of images, along with a more detailed example on creating multiple images with nested folders of images. (more…)