Tutorial

Freenode IRC – Connect And Auth Securely

January 30th, 2010  |  Published in FYI, Tutorial

OK, so today freenode migrated to their new server. It was a bit rough around the edges at first, however they have finally added support for connecting via SSL and using a script in Irssi you can authenticate via SASL. So, I will quickly show you how to get SSL and SASL setup for Irssi and Irssi only, and I am assuming you already have a connection to Freenode already setup.

WARNING: It has been brought to my attention that the Irssi folks get mad when people tell you to edit the config file instead of using the commands, so with that, backup your config file first, and if anything goes wrong, not my fault :)

  1. Let’s install the necessary packages (I think this is all, I already had openssl installed but had to install the libcrypt- packages for the SASL script below):
    sudo apt-get install openssl libcrypt-openssl-bignum-perl libcrypt-dh-perl libcrypt-blowfish-perl
  2. Grab and save the cap_sasl.pl script to ~/.irssi/scripts and setup a link for it to autorun:
    cd ~/.irssi/scripts
    wget http://www.freenode.net/sasl/cap_sasl.pl
    mkdir autorun  ## only if you do not have this directory already
    cd autorun
    ln -s ../cap_sasl.pl .
  3. Fire up Irssi without connecting to anything:
    irssi -!
  4. Once in Irssi, setup your username and password for SASL:
    /sasl set freenode your_nick your_password DH-BLOWFISH
    /sasl save
    /save
  5. Quit Irssi
  6. Using a text editor, edit ~/.irssi/config and in the section that says servers = ( you want to remove the stuff between the { and } for freenode, and then add the following in its place:
    address = "chat.us.freenode.net";
    chatnet = "freenode";
    port = "7000";
    use_ssl = "yes";
    ssl_verify = "yes";
    ssl_capath = "/etc/ssl/certs";
    autoconnect = "yes";
  7. Now under the chatnets = ( section, you want the freenode = part to be changed to:
    freenode = { type = "IRC"; };

If you get a message about your nick being “Juped” or “temporarily unavailable” and get switched to Guestxxxx nick, read the following, otherwise enjoy your new secure connection.

Now you can go ahead and connect to IRC like you are used to. If you have the ENFORCE flag set for your nickname, you may come across some issues with identifying, and the one message I kept getting was:

Nick nixternal is Juped

If you get this, you need to disable the ENFORCE flag on your nick (make sure you are identified with your correct nick first):

/msg nickserv set enforce off

After that, disconnect from IRC, then reconnect to IRC. You shouldn’t be getting that error message now. If you do, go to #freenode and complain accordingly :) If all is well, you can go ahead and set the ENFORCE flag back to on:

/msg nickserv set enforce on

Now all should be well. Enjoy your new secure, SSL and SASL authentication, connection.

Mark E-mails in Mutt as Tasks in Taskwarrior

January 25th, 2010  |  Published in GTD, Tutorial

OK, so I think most people know that I have grown quite fond of Taskwarrior for managing my Getting Things Done stuff. Many of you might also know that Mutt is my e-mail client of choice, for the past 15 years. Recently you saw a post on Planet Ubuntu by the rockstar Bryce Harrington concerning Mark emails in mutt as tasks in gtg. Well, I have had something similar, actually pretty much the same damn thing, just with a different GTD application. So without further ado, here is what you need to do in order to mark an email in mutt as a task in taskwarrior.

Setup Mutt Macro

macro index t "<pipe-message>mutt2task<enter> <save-message>+TODO<enter>"

What this does is set the t key, while in the index of mutt, as a macro. The macro pipes the email message to a script I wrote that strips the header from the message and adds that as a task. The save-message part saves the email to my TODO folder.

Setup Mutt2Task Script

#!/bin/sh
/usr/bin/task add +email E-mail: $(grep 'Subject' $* | awk -F: '{print $2}')

What this does is call the command task add which adds a new task. The +email tags the task, and the E-mail: $(grep ‘Subject’ $* | awk -F: ‘{print $2}’) greps the Subject line and then prints the part after Subject: from the email, therefor just giving me the subject text. Make sure you place this script somewhere in $PATH and make it executable.

Make sure you add a TODO message folder in your mutt configuration so you can see the TODO messages.

Byobu shows me next meeting

December 30th, 2009  |  Published in Tutorial

Have I ever told you all how much I love byobu? I have always used screen, though I really never tweaked it all crazy like many did. Recently I typed screen at the command line and I was presented with this thing called byobu. I went ahead and gave it a shot, and at first I will say I was rather annoyed with the bar at the bottom of my screen, and my scrollwheel didn’t work with byobu the way it did with screen. I went ahead and changed my workflow in order to get used to byobu. A couple of weeks ago, I got nosey, and wanted to know how byobu was doing its thing. After a while of messing around, and seeing everything it could display, I wanted more! And since quite a few of you on IRC wanted it, well here it is.

See, I use the cli more than I do the desktop, which is weird seeing as I am an avid KDE lover and hacker. Here is my current workflow via the command line:

With byobu, I have it set up to automatically create 5 windows (the 4 above, plus a regular zsh shell). Since I use the command line so much, I tend to forget about meetings from time-to-time as I don’t get any warning of them, until it is either to late or I have totally missed it. So I thought, since I use the command line so much, how can I have something simple to show me the next meeting. Then I thought: I could use gcalcli to read the Fridge meeting calendar, and then have the next meeting output to the bar in byobu, so I will always see the next meeting. Currently with byobu, it isn’t the easiest thing in the world to add custom items such as this, but I have been told they are coming soon! Awesome!

So, here is what my new addition looks like:

To get this, I had to do the following:
Step 1: Create crontab task
Create a crontab task to create a file in my home directory that contains a list of meetings:

*/5  * * * * gcalcli --nc --ignore-started agenda "`date`" > $HOME/.gcal_agenda.txt

Step 2: Create a script for byobu
Create the following script (/usr/lib/byobu/gcal_agenda) and then make it executable:

#!/bin/sh
if [ "$1" = "--detail" ]; then
        head -2 /home/nixternal/.gcal_agenda.txt | tail -1
        exit 0
fi
GCAL=$(head -2 /home/nixternal/.gcal_agenda.txt | tail -1)
printf "\005{+b }%s\005{-} " "$GCAL"

Step 3: Add a tick to the common profile
In /usr/share/byobu/profiles/common, you need to add the following:

backtick 200    67      67              byobu-status gcal_agenda

Add this line right after the last backtick line you see.

Step 4: Add output to the hardstatus string
We need to add the number 200 that represents our backtick in the previous step to the hardstatus string line in $HOME/.byobu/profile. profile is a symbolic link to the current color profile you are using in bybobu, so if you ever change your theme, you will lose this setting until you add it to the next theme. Here is what my hardstatus string line looks like in $HOME/.byobu/profile:

hardstatus string '%99`%{= kw} %100`%112`%= %102`%101`%200`%127`%114`%115`%108`%128`%125`%126`%113`%119`%117`%116`%106`%104`%103`%105`%107`%123`%120`%121`'

That is all on one line. See the %200 in that line, that is our gcalcli output. That is the one we need to add in there.

Step 5: Make byobu use it
For some reason, byobu didn’t automatically pick up my new script in /usr/lib/byobu, even after reloading (F5), so I added gcal_agenda=1 to $HOME/byobu/status, did a reload (F5), and it was there.

I think this is everything, hopefully I didn’t forget anything. If you try it, and it doesn’t work, let me know.

EDIT: I am a moron, not /var/lib, but /usr/lib. I have made the changes to the post already. Also make sure you have gcalcli up and running with your calendars first. To add the fridge calendar, you subscribe to it from your Google calendar.

EDIT: I redid the last 3 steps because I totally forgot them originally. Thanks to Chris Johnston to pointing this one out!

RE: SSH Tab Complete

December 5th, 2009  |  Published in Tutorial

This is a response to SSH Tab Complete by Michael Lustfield.

Create a ~/.ssh/config file and populate it with configurations. Doing this is the only step you need to do, and you don’t need to add anything to your ~/.bashrc. Example ~/.ssh/config:

# foobar.com
Host foobar
    Hostname foobar.com
    User xxxxxxxxxxxxx
 
# Home server (internal)
Host iserver
    Hostname 10.0.0.2
    User xxxxxxxxxxxx
    Port ####

Host is a simple word that will be used with ssh like ssh foobar. Hostname is the actual IP address of domain name of the server. User is your username for that machine. Port is the ssh port number, if it isn’t the default port of 22.

So, when I want to ssh into my home server, I just do ssh is, press tab, then enter. There are many more options to add to the config file as well, and a simple Google search will provide more. Also man ssh_config will give you pretty much everything you need as well.

Kubuntu DocBook/XML 101

November 23rd, 2009  |  Published in Documentation, Kubuntu, Tutorial, Ubuntu

So, you keep hearing me talk about contributing to Kubuntu documentation, and you see that I say it would be nice for you to have some DocBook/XML experience. Many people want to help, but they don’t have that experience. In most cases, the people interested at least understand HTML or some other markup language a little bit. If you can understand that, then you can easily understand DocBook/XML the way we use it for Kubuntu documentation. DocBook/XML has a lot of tags that one can use, however we only use a very small subset of those tags with our documentation. Just an idea of the main tags we use from DocBook/XML are:

  • <sect1>
  • <sect2> – sometimes
  • <title>
  • <para>
  • <ulink>
  • <example> – sometimes
  • <mediaobject> – only for screenshots
  • <imageobject> – only for screenshots
  • <imagedata> – only for screenshots
  • <acronym> – sometimes
  • <guibutton> – sometimes

There might be a few more, but these are the ones that pop into my head. For instance, when you are trying to let the reader know to open up an application via the menu, there is a tag called <menuchoice>. We have an entities file that contains all of the menu stuff, so you wouldn’t even need to use that tag, as you would call it in the document you are working in. Example: Say you are trying to tell the user how to open Amarok, you would enter &menuamarok;. Easy!

Here is an HTML example, lets say, Hello World :)

<html>
<head>
<title>Hello, World!</title>
</head>
<body>
<p>Hello, World!</p>
</body>
</html>

The html, head, and title, are already taken care for you with the template, so you just need to do the part in between the <p> and </p>. So in DocBook/XML, that would look:

<para>Hello, World!</para>

Easy. Typically with HTML, when you are trying to show a section or make a section stand out, you might use <h1> to make the title stand out. Well in DocBook/XML there are a few more lines, but still easy to do:

HTML:

<h1>This is the title of the section</h1>
<p>This is a paragraph in the section.</p>
<p>This is another paragraph in the section.</p>

DocBook/XML:

<sect1 id="intro">
<title>This is the title of the section</title>
<para>This is a paragraph in the section.</para>
<para>This is another paragraph in the section.</para>
</sect1>

If you are looking for a little bit more information concerning documentation in the Ubuntu world, take a look at the Documentation Team Wiki Page. There is also a bit of information on how we use Bazaar when working with documentation as well. To get an idea of how we use DocBook/XML with Kubuntu documentation, take a look at the old Jaunty Documentation for Kubuntu. Under the docs/ directory you will find the topics covered. And then under the topic, in the C/ folder is the XML markup for that topic. There is obviously a bit more DocBook/XML markup in our documentation, but the header portion and the layout is already completed in a template, so all one would need to do is fill in the space and create new sections.

If you have any questions, please do not hesitate to stop by the Ubuntu Documentation IRC channel on Freenode in #ubuntu-doc and ask away. We also have a mailing list where you can ask questions and communicate via email to other documentation people.

CSS Border Radius

June 19th, 2009  |  Published in Coding, Development, FYI, KDE, Personal, Tutorial

I am really just adding this so I have it documented in case I forget it in the future or need to reference it. One thing I like to do when messing around with web development is when I use a table to hold something, instead of a silly div (really on wiki pages and such to create cheap button-like objects), is use a round border. So here are the example on how to use round borders for tables, utilizing border-radius and CSS.

Firefox

/* 5px radius on all 4 corners of the table */
-moz-border-radius: 5px;
/* 5px radius on top left and bottom right corners only */
-moz-border-radius: 5px 0 5px 0;
/* 5px radius on bottom left and top right corners only */
-moz-border-radius: 0 5px 0 5px;
/* 5px radius on the top left corner only */
-moz-border-radius-topleft: 5px;
/* 5px radius on the bottom left corner only */
-moz-border-radius-bottomleft: 5px;
/* 5px radius on the top right corner only */
-moz-border-radius-topright: 5px;
/* 5px radius on the bottom right corner only */
-moz-border-radius-bottomright: 5px;

CSS 3

/* 5px radius on all 4 corners of the table */
border-radius: 5px;
/* 5px radius on top left and bottom right corners only */
border-radius: 5px 0 5px 0;
/* 5px radius on bottom left and top right corners only */
border-radius: 0 5px 0 5px;
/* 5px radius on the top left corner only */
border-top-left-radius: 5px;
/* 5px radius on the bottom left corner only */
border-bottom-left-radius: 5px;
/* 5px radius on the top right corner only */
border-top-right-radius: 5px;
/* 5px radius on the bottom right corner only */
border-bottom-right-radius: 5px;

Webkit

/* Just add -webkit- in front of the CSS 3 styles */
-webkit-border-top-right-radius: 5px;

KHTML (Konqueror)

/* Just add -khtml- in front of the CSS 3 styles */
-khtml-border-radius: 5px;

And with that said, Why is there 4, count them 4, different ways to skin the same exact cat? Come on browser devs, lets come together and accept 1 solution and implement it. I have been noticing Ajax-like functions out there to do rounded corners, and now I see why. With like 10 lines of JavaScript, you get this same functionality. Now do this in your style sheet, and 1 table could have as less as 4 lines if it is a simple table, or as many as 16 lines for a bit more complex layout. Anyways, just wanted to keep this documented instead of Googling for it all of the time when I need it, and pass it on to all of you fine folks who are unfortunate enough to read my blog. Plus, I also wanted to pass on how web developers, when utilizing border-radius, can now make a KHTML friendly site :)