The authors of Advanced Linux Programming “take a tutorial approach and teach the most important concepts and power features of the GNU/Linux system”. This book contains exactly what I need to fill the gaps in my understanding of the inner workings of Linux. The breadth of information is amazing. Even more amazing is the fact that the entire book is freely available for download in PDF format.
Posts Tagged: Programming
How to be a Programmer
How to be a Programmer: A Short, Comprehensive, and Personal Summary is an excellent essay. I dare not call myself a real programmer, but I’m definitely an aspiring programmer. Essays like this one are miniature goldmines — decades of real human experience compacted and organized, ready for ingestion.
Reflections on Trusting Trust by Ken Thompson
Reflections on Trusting Trust by Ken Thompson (the co-creator of the C programming language) is an excellent paper. My favorite line was, “You can’t trust code that you did not totally create yourself. (Especially code from companies that employ people like me.)”
Gustavo Duarte on the Anatomy of a Program in Memory
In his latest post, Anatomy of a Program in Memory, Gustavo Duarte explains beautifully the way in which programs are laid out in memory. He explains things in a very clear and concise manner and the diagrams are amazingly helpful in illustrating what he’s talking about. I feel that memory management is where my C programming class left off, so this post is extremely helpful in deepening my understanding.
Blogging from the Command-Line
I’m a command-line person. If you can show me a command-line version of something I already do in a windowed environment, I’ll get stuff done faster. I often look for command-line solutions to tasks that become repetitive and feel as though time could be saved by doing them on the console.
A recent example of this is the posting of asides on my blog. Asides are often very short (one or two sentences at most — they appear on my blog without a title) and navigating the WordPress Administration interface in a web browser simply to post one or two sentences became very time consuming and distracting. Since I’m constantly editing files and code on the console using my favorite editor (vi), being able to quickly create and post an aside from the same environment would be awesome.
Before writing a tool that allowed me to post to my WordPress blog, I searched Google to see if someone else had already written something. Sure enough, I found blogpost, a script written in Python by Stuart Rackham:
blogpost is a WordPress command-line weblog client. It creates and updates weblog entries directly from AsciiDoc (or HTML) source documents. You can also delete and list weblog entries from the command-line.
It uses XML-RPC to post to WordPress blogs and also supports automatically uploading media files (images, videos, audio, documents) that are referenced within the AsciiDoc (or HTML) post file. Check the blogpost man page for full details.
Remember, my main goal here is to make posting short asides easier. I’m perfectly happy using the WordPress web interface to write longer posts. In fact, I prefer the web interface for longer posts because I get things like automatic spell checking (through OS X) and automatic draft saving (through WordPress).
After installing blogpost and modifying the configuration file to include my WordPress login details, I created a file called post.txt using the vi editor and, after saving the file and closing vi, I published the aside using blogpost:
$ blogpost.py --title="My Test Aside Post" -U --doctype='html' create post.txt
creating published post 'My Test Aside Post'...
id: 2758
url: http://blog.raamdev.com/2009/01/24/my-test-aside-post
$ blogpost.py cat --categories="Asides, Blog Entries, General" post.txt
assigning categories: Asides,Blog Entries,General
Note that I only need really basic formatting (i.e., HTML for links), so I use the --doctype='html' option. This allows me to type raw HTML in vi when I’m editing the post file, just as I do now in WordPress (I don’t use the Visual Editor).
While the options and flexibility provided by blogpost are great, the process of publishing an aside needed to be more automated to solve my problem. Creating a new file in vi, typing all those options, running two separate commands, and then deleting the file every time I wanted to post a few sentences on my blog didn’t make a whole lot of sense. So I whipped together this little shell script to help automate the steps above:
#!/bin/sh ## ## aside.sh - automates publishing asides using blogpost.py ## # Open a temporary file in the vi editor vi aside.$$ # Display new aside before publishing echo "New Aside:" cat aside.$$ echo # Prompt for an aside title echo "Enter a title for this Aside:" read TITLE echo "OK!" echo # Using the temp file saved above, post the Aside blogpost.py --title="$TITLE" -U --doctype='html' create aside.$$ blogpost.py cat --categories="Blog Entries, Asides" aside.$$ # Remove the temporary file rm aside.$$
Now posting an aside to my blog is as simple as running ./aside.sh, typing the aside in vi, saving and quitting (:wq), and then typing a title. The rest of the work, including cleanup, is taken care of by the script!
Stuart did an excellent job with blogpost and if you have a blog and use the console (and why shouldn’t you?!) I recommend you check it out. The blogpost README is a great place to start, as it includes prerequisites and installation information.
