Found 5 entries, viewing 1 through 5.

Rambling on Git

So during my UTOSC presentation I add some spare time, and ended up doing a "Git in Five Minutes" demo. I've done a written version for everyone to enjoy. So yes, I've written a Git tutorial.

Oh, and this Git Magic tutorial is pretty good too.

Permalink | Posted: Sep 10, 2008 | Tags: programming tips git

Full Code Navigation: Cscope

Not long ago we discussed ctags here, and how it can quickly let you navigate your code, helping you find definitions of variables and functions. You'll have taken notice that sometimes you want to navigate in the reverse: where is this function called, who includes this file, etc. Cscope builds a database of such information (and more). We can include it with ctags and have very impressive code searching.

If you want a detailed introduction, there is a great cscope and vim tutorial available. I'll just give you a quick run down of using it.

  1. At the base of your C or C++ source tree run cscope -R -b -q

  2. Add this to your .vimrc:

    if has("cscope")
      set cst
      set csto=1
      if filereadable("cscope.out")
        cs add cscope out
      endif
    endif
    
  3. Start Vim in the same directory as the generated cscope.out file. (If not, just ...

Continue Reading

Permalink | Posted: Apr 18, 2008 | Tags: programming tips vim

Host Aliases in SSH

So you've probably got one or two hosts that you frequently ssh to that have long hostnames. You'd prefer to just alias this to something really short. There's a couple ways to do this:

  1. Hosts file alias. Problem: may overwrite something useful for other network connections.
  2. Shell alias. Problem: too many aliases.
  3. Good shell tab-completion. Problem: I can never get zsh to do intelligent ssh host completion.
  4. SSH configured alias.

So to create an alias for a system add to ~/.ssh/config the following:

Host <alias>
    HostName <real system fqdn>

Some examples:

Host s
    HostName scottr.org
Host b
    HostName 192.168.1.1

After a Host entry can be host specific configuration, and Host can be a pattern (Host *.slashdot.org). So for a host you could disable host key checking, or use a specific key file. Comes in pretty handy.

Permalink | 2 comments | Posted: Apr 18, 2008 | Tags: tips shell

Navigating Man Pages in Vim

If you program in C you probably look to the man pages as a prime reference. There are a lot of different functions in the standard library. For example, what does this all mean?

sscanf(str, "%*d: %12[^a-zA-Z] 0x%4x %n", ...)

Luckily in Vim I can just press K over sscanf and in a window split I'll have the man page. Now this isn't a new feature, except that the man page opens in a Vim window not in a pager. This is a feature enabled by enabling a plugin that ships with Vim.

As an additional bonus the man page has syntax highlighting and is tagged so you can travel between man pages with CTRL-] and CTRL-T. Now when you see the references (like getc(3)) you can just scroll over and hit CTRL-] to view it.

To enable this plugin, and map K to use ...

Continue Reading

Permalink | Posted: Mar 21, 2008 | Tags: programming tips

ctags and Vim

At work I deal with a large code base. Taking into consideration that I'm often still familiarizing myself with the code, you can imagine that it isn't easy finding things. An average day working in the code used to involve me trying to determine what a bit-field flag means, which involves tracking down a #define somewhere in the code. Worse yet are the various functions I've seen around and now need to understand what they're doing, leaving me to find where they're doing it.

Now at first I was running commands like egrep -R '^some_function_name' * or egrep -R '^#define \+FLAG' *. This usually worked, but it meant I would then have to then open the file up in my vim session. This took away a lot of time, and I knew that there was a better way.

ctags is a program that will go through code ...

Continue Reading

Permalink | 2 comments | Posted: Feb 24, 2008 | Tags: programming tips

Tags

42 | django | python | oggify | OSCON | OSCON07 | osx | utosc | mythtv | security | reading | music | gaming | programming | tips | shell | vim | pyobjc | cocoa | iphone | blog | git

Calendar

<< Jan >>
Mo Tu We Th Fr Sa Su
31 1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31 1 2 3

Search

This space reserved for a search box

A Django site. Hosted on a Slicehost Slice