Sunday, December 30, 2012

Qt 4.8.4 and MinGW Quick Start

The following are instructions for installing Qt and compiling a demo application using the MinGW toolchain:
  1. Download the Qt 4.8.4 libraries installer here.
  2. Run the installer. If a warning message about the version of the w32api.h file appears ignore it and continue the installation (my install is version 3.17 and appears to work fine).
  3. By default, the installer does not add the Qt toolchain to the PATH. Instead, it provides a custom command prompt environment called the "Qt 4.8.4 Command Prompt"; launch this command prompt from the Start menu.
  4. Now we can try compiling an example; from the Qt command prompt, navigate to C:\Qt\4.8.4\demos\textedit.
  5. Execute the command qmake; this should generate a makefile.
  6. Build the example using the command make.
  7. If everything goes correctly, textedit.exe should now exist in the debug directory; launch the demo application.
That’s it! Your machine is now ready to build Qt apps using MinGw.

Saturday, December 22, 2012

Vim Zoom Hack

When writing large documents with a text editor, it is sometimes useful to zoom out and get a high-level view of the file (I believe Sublime Text has a feature called minimap that does this). This functionality can be added to gVim with a simple vimrc addition (to my knowledge, this will not work with regular Vim).
Add the zoom out command with the following: noremap <Leader>zo :set guifont=courier_new:h4<CR>

Add the zoom in command with the following: noremap <Leader>zi :set guifont=courier_new:h10<CR>

Adjust the font type and normal size as desired. Not the most elegant method but it works. Please note that split window sizes may be affected during the zooming process.

Saturday, December 1, 2012

PopPage

Recently, I had a need for a very lightweight static website generator. The idea was to have Asciidoc and Pandoc handle the markup to HTML conversions while the generator would simply apply the HTML content to a Jinja2 template. The result was PopPage, a simple command-line driven website generator. It plays nicely with native Windows batch scripting and I plan on providing a few examples in the GitHub repo shortly.

Docopt

While browsing YouTube recently, I stumbled upon a video about a great third-party Python module called Docopt. It greatly simplifies writing command line utilities; instead of writing custom logic using the standard library optparse or argparse modules, you simply write the usage docs for the utility and Docopt handles the parsing. Check out the documentation; there are some great examples that really showcase the power of this module.

Sunday, August 19, 2012

Raspberry Pi First Impressions

Received my first Raspberry Pi the other day. I ordered two Model B devices from Newark and, despite the high demand, received them in about a week.

My intended use for the first R-Pi was to serve as a mini-HTPC for my basement TV. I tried both Omxplayer running on Raspbian and Raspbmc. I was very please with the performance of both; they were able to stream videos from my NAS with no issue. Unfortunately mplayer on Raspian currently does not support GPU acceleration on the R-Pi and lacks the horsepower to be of any use. For now, Raspbmc will likely remain the frontend of choice for the HTPC.

Overall, the value of the R-Pi is amazing! For $35, this device is an absolute bargain and a must have for any tech DIYer.

Wednesday, August 15, 2012

Vim Scratch Buffer

Opening a scratch buffer in Vim can come in handy. The following vimrc addition works well: nnoremap <Leader>sc :e scratch<CR>:setlocal readonly<CR>

It is especially useful in combination with the run shell command shortcut once Vim is configured to change to the directory of the current file with the following vimrc addition: autocmd BufEnter * execute "chdir ".escape(expand("%:p:h"), ' ')

The advantage this named buffer has over the [No Name] buffers created by :enew is that newly created scratch buffers will not affect the path of existing buffers. This can be useful if you later want to save the contents of your scratch buffer.

Sunday, August 5, 2012

Vim Run Shell Command

Here is a nice simple vimrc file addition that will execute a line as a shell command and read back the output into the buffer: nnoremap <Leader>rl yy:r!<C-r>"<CR>

Fossil Command Line Tips

For small projects, Fossil is a great choice for revision control. Fossil’s command line interface is very easy to use and plays nice with utilities like grep, gawk and xargs. The following are examples of common operations:
  • Check in only edited files: fossil changes | grep EDITED | gawk '{print $2}' | xargs fossil commit -m "Added feature X."
  • Add only files with name containing "pattern" to repo: fossil extras | grep pattern | xargs fossil add
  • Move files in repo to match move on filesystem: fossil changes | grep MISSING | gawk '{print "fossil mv " $2 " subdir/" $2}' | sh

Saturday, July 28, 2012

New GoogleCL Blog Process

First post using a new blog process! All new posts will be written using Asciidoc text files. Each file is then converted to HTML and uploaded to the blog via GoogleCL. The whole process is automated using Python.

I’m hoping this new workflow will make writing new posts more efficient in turn leading to more frequent updates.

Sunday, March 18, 2012

PyPy Intro

David Beazley gave an excellent introductory talk about PyPy at PyCon this year. I knew very little about PyPy going in and David really helped clarify the goals and approach of this ambitious project.

There are several other PyCon talks that discuss this project in more detail:
Also, check out the full list of videos from PyCon 2012 for other great talks.

Monday, February 27, 2012

Tweaking Gnome Panel

My HTPC is a Linux box running Ubuntu 10.04 and I love it. To give it a more couch-friendly interface, it's now running Avant Window Navigator. I wanted to keep the top Gnome Panel available but hidden with a 1 second unhide time. To tweak these settings, do the following:

  1. Open gconf-editor.

  2. Navigate to /apps/panel/toplevels/top_panel_screen0.

  3. Enable auto_hide.

  4. Set unhide_delay to 1000.