A Django site.
November 5, 2008

Clint Savage
herlo
Sexy Sexy Penguins » Tech
» Meme: First thing I do after installing (insert your distro here)

Obviously, my distro is Fedora, but for those of you who might choose something else, let’s play along.

This meme comes from Valent Turkovic’s blog post a few days ago, so I thought I’d share mine.

$ su -c 'yum install nautilus-open-terminal'

This enables me to right click on the desktop and click ‘Open in Terminal’. This is much better than choosing ‘Applications -> System Tools -> Terminal’, which in my opinion is a big pain in the ass!

While it used to open in the user’s home directory, now it opens in their Desktop.  Not sure of the benefit for that, but I’m glad it’s still around.

Cheers,

Herlo

September 11, 2008

Scott Paul Robertson
spr
Spr: The Ramblings
» 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.

April 19, 2008

Scott Paul Robertson
spr
Spr: The Ramblings
» 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 do :cs add <cscope.out file>).

  4. To find where a function is called do :cs find c <function>. To find where a symbol is defined do :cs find s <symbol. You'll notice that if there are multiple matches a menu pops up to let you pick. This is the case for using CTRL-] on symbols as well.

  5. Make some handy mappings:

    nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
    nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
    

Cscope can do many other searches. See the tutorial or just type :he cscope in 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.

March 22, 2008

Scott Paul Robertson
spr
Spr: The Ramblings
» 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 it, add to your .vimrc:

runtime ftplugin/man.vim
nmap K :Man <C-R>=expand("<cword>")<CR><CR>

Now you'll always have man pages at your finger tips without ever leaving Vim!

February 24, 2008

Scott Paul Robertson
spr
Spr: The Ramblings
» 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 and determine where things are defined and write a tag file. ctags can generate tag files for a host of programming languages, and the best part? Vim knows how to deal with them.

  1. Generate a ctags file. find src/directory -name '*.c' -o -name '*.h' | ctags -f - tags
  2. Run vim from the directory with the generated tags file.
  3. See something you don't recognize? Move the cursor over it and CTRL-] will jump you to the definition. CTRL-O will jump you back.
  4. If vim says something about this being tag 1 of 3, you can jump to other definitions by adding a count to you tag command. 1 CTRL-] jumps to the first definition (or the current definition if you're over one). 2 CTRL-] jumps to the second, and so on.
  5. Tried of typing in long paths, but know the function you want to work on? Start vim in the directory without a file name, the just run :tag function_name and you're there.

I'm currently using this for C and Perl, and I'm not sure how I've lived without it for so long. Even though I know the code a lot better than when I started, navigating by tags is so much faster than opening a file and leaves me more time to remember more important things like which argument is the source and destination of a strcpy, it will always be worth using.

May 11, 2007

Richard K. Miller
no nic
Richard K Miller
» Choose a good password

You’ve heard over and over the importance of choosing a good password, but we all seem to keep the same bad habits. Roger Grimes analyzed 34,000 real passwords and discovered some interesting trends:

  • As expected, English vowels are by far the most frequent occurring password symbols.
  • [In passwords with numbers,] the number 1 appeared 45 percent of the time, followed by the number 2 (22 percent.)
  • The exclamation point was the most commonly used non-alphanumeric character.
  • Words, colors, years, names, sports, hobbies, and music groups were very popular.
  • Other popular words include: angel, baby, boy, girl, big, monkey, me, and the.
  • Names of sports — golf, football, soccer, and so on — were as popular as professional sports teams and college team nicknames

Drawing on this study and other wisdom, here are some tips for choosing a good, secure password. Read #8 if you don’t read them all:

  1. Don’t write your password on a sticky note attached to your monitor (or “hidden” under your keyboard.)
  2. Don’t choose anything obvious like your birthday, spouse name, etc.
  3. Don’t choose any single word you can find in a dictionary.
  4. Don’t use the same password on a secure site (like your bank) as on an insecure site (like a mailing list.) If someone discovers your password because it was emailed to you from an insecure site, you don’t want your bank account to be vulnerable. Ideally you’d keep a different password for each site.
  5. If a digit is required in your password, don’t simply append a “1″ or a “2″. If a symbol is required, don’t simply append an exclamation point.
  6. Learn which channels are secure and which are not. Generally HTTP, FTP, and VNC are not secure, while HTTPS, and SSH are secure. Don’t use secure passwords on insecure channels. (Look for the padlock in your browser.)
  7. Pick a password you can remember, so you won’t have to write it down.
  8. Pick a LONGER password. Think of a phrase or sentence or haiku, not a word. Password length is more important than symbols or numbers. For a security expert like Mr. Grimes, a 6-9 character password with “complexity” (symbols, numbers) is fairly easy to break, while a password with 15+ characters is almost impossible to break.

Eventually, we may be using our fingerprints or some other biometric procedure, but until then, choose a good password.

March 17, 2007

Byron Clark
byronc
byronc bits
» Editing ViM Macros

At the BYU UUG meeting this week, Peter mentioned a great ViM trick that I’ve never seen before. Here’s my feeble attempt to document it.

Because ViM macros are stored in registers they can be edited. This means that if you create a long macro and then realize that you forgot to send the cursor to the beginning of the line before finishing the recording, you don’t have to create the entire macro again, you can just add the motion command. You use it like this:

  1. Start recording your macro by typing q and then the single character ([0-9a-zA-Z"] are allowed). The single character is the register your macro will be stored in.
  2. Enter the commands you want included in the macro.
  3. Type q to finish recording the macro.
  4. At this point you could run the macro by using @ and the register name.
  5. To modify the macro, move to a blank line and type "Rp replacing R with the register name of your macro. This will paste all the commands in your macro to the current line.
  6. After making the changes you need, save the macro by typing 0"Ry$ replacing R with the register name you want to use for the macro. The register name does not have to be the same as the original.

December 18, 2006

Byron Clark
byronc
byronc bits
» aspell and LaTeX

I write a lot of things in LaTeX and always get annoyed when aspell complains about my LaTeX tags being mispelled. Imagine my surprise when I discovered that aspell has a TeX mode so that it will ignore the tags. 'aspell -c -t <myfile.tex>' invokes the proper magic.

December 16, 2006

Byron Clark
byronc
byronc bits
» orpie

Chances are that if you ever used an HP-48 series calculator you’ve never wanted to use anything else. Well now you can save space in your laptop bag by replacing the calculator with orpie. orpie is a terminal based RPN calculator that will make you curse all the time you wasted trying to use bc, dc, and calc.exe.

ps - The cygwin version works just fine if you’re stuck on Windows.