Wednesday, September 2, 2009

Using the command line for looking up wikipedia entriesLi

Lifehacker had a tip of how to look up an entry in Wikipedia using the command line. It uses the dig command line, and the syntax is as follows:

     dig +short txt .wp.dg.cx

Just replace with what you want to look up. That will give you the Wikipedia summary back. Quite cool.

Sunday, August 23, 2009

Which XCode files should be under SCM?

I am using XCode for some of my programming projects, and I would like to minimize the number of files in my SCM repository. The question is, which files are necessary for XCode to compile the project and which can be ignored?

You will of course need to add all your .h and .m files. The .xib (.nib) files should also be included. From what I have been able to figure out, you could put the following into your ignore-file (.gitignore if you are using git, as I am at the moment).

    # XCode files that can be ignored
    build/*
    *.pbxuser
    *.mode1v3

Also, it could be a good idea to add the following into your .gitattributes-file, in order to treat the project file as a binary file. This will make things easier if you get conflicts.

    *.pbxproj -crlf -diff -merge

Sunday, July 19, 2009

OS X Terminal Software Update

As I manage a couple of computers running Mac OS X (not all mine), keeping them up to date with the latest security and software updates can be a bit tiresome. This is especially true for machines I have to use remote control on in order to update. With slow Internet connections, the VNC-protocol can be a bit slow, in particular when the machine is also downloading huge security updates. 

To help with this, I just found out that is possible to update the machine remotely (or locally) using the terminal. All you have to do is fire up the terminal, optionally ssh to the remote machine, and type in the command 

   sudo softwareupdate -i -a

This will download and install all available Apple updates. If you just want to see what updates are available, try

   softwareupdate -l

Tuesday, April 28, 2009

Using the command line to get the external IP

Lifehacker hints on how to get your external IP-address from the command line. You can use either curl or wget, using either of the following commands:

curl -s myip.dk |grep '"Box"' | egrep -o '[0-9.]+'

or

wget -O - -q myip.dk |grep '"Box"' | egrep -o '[0-9.]+'

OS X do not come with wget preinstalled (it can be installed through e.g. Fink or MacPort), the curl version might be the most useful for OS X users.

Wednesday, April 8, 2009

Use 'ls' to only show directories

Lifehaker has a great tip on how to use 'ls' to only show the subdirectories at the command prompt. When you know about it, it is kind of obvious (if you know some simple regexp), but a it is still very handy. 

So, what you do is to type

    ls -l | grep ^d

at the command prompt. This will only list your subdirectories. 

Saturday, April 4, 2009

Line numbers in LaTeX

As I am doing a bit of writing, I suddenly had the need to have line numbers in my LaTeX document. There is a really nice package called lineno that takes care of this very nicely. All you have to do is include the package, and put the command \linenumbers somewhere in your document. I placed the following two lines in my preamble:

  \usepackage{lineno}
  \linenumbers

You will find the documentation for lineno at ctan. 

Saturday, February 28, 2009

Printing with Quicksilver

I find that I use Quicksilver for many things. I came over a post explaining how to print a file that is selected in the finder without opening preview or other programs. Quite handy.