My On-line Identity

Posted in General on January 30th, 2010 at 11:09 – 1 Comment

I am writing this article as a means to give some order to my thoughts on my on-line identity, specially on how I could take better care of it.

The Past

QR code for this blog Some ten years ago, when I started to have some activity on the Internet, I had some concerns about my privacy and rarely used my real name for anything I did on-line. In 2002, I started my own personal blog called Jovian Storm and I used to sign my posts as Jake. Since Jake is a very common name, it was very difficult to associate it to me in any way, except for those who knew me personally, which were the main consumers of my writings (aren’t they still?). Not long after that, I started to sign up for a number of web apps and on-line communities and used jovianjake as my new user name or nickname.

On the other hand, I had also used other user names that pointed directly to my name, e.g. jacobodevera, for some web apps that I considered more “serious”. The thought behind that was that most of those already had my name and I was trying to keep jovianjake and his on-line activity separated from my real self.

When I started to be aware of the concept of on-line identity, how it could affect my reputation and how I could benefit from it just by taking some care of it, I had already been producing content as jovianjake for a while. A quick Google search for my name showed nothing interesting. Most of the results came from official publications by the Spanish Government regarding scholarships, and from people I had traded bootlegs with.

I wanted to change that, so I could be associated to some of the contents I was producing (or consuming). A quick and easy first step was to provide my real name to some of those apps where I had signed up as jovianjake. I also mentioned my name in the About section of my blog. The change in the search results was quick; apparently the Spanish Government publications are not so popular after all (go figure!). This move had a drawback, though: by providing my real name in these sites, I was mapping it to my nickname jovianjake, and privacy was gone for good.

The Present

I have kept this scheme for a number of years now but the truth is it does not work very well for me. My on-line identity is now scattered across a variety of user names and nicknames and there is no clear separation between personal, professional, private and public. This is happening because I never had a strategy, not even when I realised I should take care of how the Internet sees me. So what user name to choose depended solely on a punctual decision taken at the moment of signing up.

Strategy is the key word here. I should have created one the moment I realised something was wrong. If I had done that in due time, it wouldn’t have been that hard to go back and get rid of all things jovianjake that were already public and start producing as jacobodevera or similar. But that is something I can’t do any more, since I am not willing to let go of all of jovianjake’s content and the time it would take to reproduce it as somebody else (when possible) makes the effort worthless.

So the plan is coming up with an on-line identity management strategy that has, to a reasonable extent, backwards compatibility with the poor decisions I made in the past. It certainly does not sound great, but it is better than having no strategy at all.

The Future

Here comes my shiny new strategy to manage my identity on-line:

Public stuff

This sentence is for you to recover from the fact that I used the word “stuff” in my strategy.

In those web apps where I don’t actually mind if the world knows who I am, I will continue using jovianjake as my user name or nickname. Then, if possible, I will include my name in whatever profile information there is available. This will create a clear mapping between this user name and my real name.

Private Stuff

In all new accounts that I create from now on in web apps where I don’t want to make obvious who I am, I will use a different user name or nickname that, of course, I will not mention here. I could even use a different user name for each app (I would love to read your thoughts on this).

There are some web apps or online communities where I had signed up as jovianjake as a privacy measure, to keep them separate from my real self. For those cases, if I want to continue using said app, I will create a new account with a different user name and then will try to move everything into this new account.

However, if by moving data over to a new account I am forced to create any kind of relation between jovianjake and my new user name, I will skip this step and simply start clean slated. It would be nice if I could back up and then delete all of jovianjake’s contents in that particular app too.

I often use Amazon to find the ISBN of a book, and it always annoys me (slightly) that I have to scroll down and scan the page looking for this number. So today I put in practice again my recently acquired basic knowledge of jQuery and wrote this snippet that places the ISBN, in square brackets, right beside the book title.

var isbn10 = $("div.content li:contains(ISBN-10)").text().split(" ")[1];
$("h1.parseasinTitle").append(" [" + isbn10 + "]");

And here is the corresponding bookmarklet:

Amazon ISBN beside title

See Only Private Bookmarks On Delicious

Posted in General on December 6th, 2009 at 17:46 – Be the first to comment

I have only started experimenting with jQuery and I already love it. It was this video/tutorial in John Resig’s blog that got me started. He has a bookmarklet that brings the jQuery library to any webpage and then uses Firebug to hack the page using the recently embedded jQuery functionality. Once he is happy with his hack, he can add the code to the bookmarklet itself and load it all together with a single click.

I followed this approach to solve a long-standing annoyance of Delicious: The lack of a option to show only the bookmarks that I have marked as private.

Tuns out that with only so much as this little piece of code:

$("ul.bookmarks li.post:not(.isPrivate)").toggle();

I can make all the public bookmarks disappear and appear again. Here is a bookmarklet to do that (to use it, simply drag it to your browser’s toolbar):

[Toggle Public Bookmarks]

I also noticed that Delicious only places the date on the first bookmark for a particular day, which means that if the bookmark that holds the date is a public one and we hide it, any private bookmark from the same day will be left dateless, thus appearing to have been saved on the latest shown date.

Dates on Delicious bookmarks

Fixing this made the code a little bit more complex and since I am not particularly fond of bookmarklets anyway, I decided to make it a GreaseMonkey Script.

I have uploaded the script to Userscripts.org although I am also keeping a local copy, so you can either

Once installed, you will see two new links on the header of your Delicious bookmarks page: “Show only private bookmarks” and “Show public & private bookmarks”

New links added by the script

GNOME Network Manager Applet With Multiple Users

Posted in General on July 30th, 2009 at 00:01 – 2 Comments

GNOME’s Network Manager Applet has a particularly annoying bug/feature: Only one instance can be running at a particular time. This is a problem when several users have sessions opened at a time, by using the fast user switch feature. It looks like this is annoying a lot of people out there, as you can see from the comments in the bug report.

Precisely in those comments you can see the two scenarios why this bug can annoy you and even upset you:

Scenario 1, as described in comment 11 (annoying):

  1. First user logs into PC, network manager starts up and connects to network
  2. Second user uses fast-user-switcher to logon, has no icon for network manager
  3. Some time later the first user switches back on, and logs out of their account
  4. Now, the second user has no network manager, and the network connection is lost. They’ve got no way of re-connecting to the network, save manually starting nm or logging out and logging back on.

Scenario 2, as described in comment 12 (upsetting):

  1. User A logs into the machine and connects to network
  2. User B logs into the machine
  3. User A or user B puts the machine to sleep
  4. User B wakes the machine but can no longer connect to the network, user A has to log in for this to work.

I would normally understand that, from a security point of view, a connection started by one user should not be allowed to be changed by another. However, there are some environments where this kind of security is not the main goal. I want all the users in my machine to be able to use the Internet even if I leave my session opened before going to work.

So I conveniently disregarded this security issue and created a workaround to temporarily alleviate the consequences of the bug. This doesn’t solve scenario 1 completely, but at least your users won’t get trapped in scenario 2.

The first solution I thought of, and the one I originally described in this entry, involved writing a small C program with a calle to one of the exec functions, compiling it and seting the user ID bit so that it would be executed as root. This seemed OK except for the fact that it required compiling a C program. Ruyk suggested a better alternative that involved no C at all. This is the one I will describe now.

This is what I did: Give all my users the power to kill the Gnome Network Manager Applet without having to allow them to run sudo (at least not without control) on my machine. After this, they can run the applet again and they will have access to the network.

I did this by editing the file /etc/sudoers by running:

sudo visudo

I added this to the end:

%users ALL=NOPASSWD:/usr/bin/killall nm-applet

This will allow all users who belong to the group called users to run /usr/bin/killall nm-applet with sudo without being asked for a password. This means that killall will be executed as root, so my other users could kill the nm-applet instance that I have started). Of course, I need to add those users to the users group, I did so by running this for each user name:

usermod -a -G users <username>

But I wanted to make life easier for my users, so I wrote this script that kills any running network manager applet and starts a new one in the current session:

#!/bin/bash

sudo /usr/bin/killall nm-applet  >/dev/null 2>&1
/usr/bin/nm-applet --sm-disable  >/dev/null 2>&1 &

I saved it in a file called nm-force, copied it to /usr/local/bin, made root the owner and allowed everyone to run it:

sudo cp nm-force /usr/local/bin/nm-force
sudo chown root.root /usr/local/bin/nm-force
sudo chmod 0755 /usr/local/bin/nm-force

After all this, you can reproduce scenario 2 and all user B has to do is to hit ALT+F2, type nm-force, and hit Enter. User A won’t have the applet when she logs back in later, but she can do the same as user B to get the applet back. You can also create a launcher for nm-force to make things simpler for your users.

Don’t forget to delete those two files when the bug gets fixed!

How to escape single quotes in Sed one-liners

Posted in General on April 10th, 2009 at 20:06 – 1 Comment

A few days ago, a co-worker came to me with a Sed question. He had a line like this in a file called myfile:

MYVAR='MYVALUE'

He needed to get MYVALUE (without the single quotes around it) into a shell variable and he wanted to use a Sed one-liner.

After a few failed attempts on escaping the single quotes, I decided to wrap the Sed expression with double quotes and it worked for me:

$ sed "s/^MYVAR='\(.*\)'\$/\1/" myfile
MYVALUE

Unfortunately, this did not work for him for some reason that perhaps was related to the fact that he was working in AIX. This alternative method, however, worked for both of us:

$ sed 's/^MYVAR='\''\(.*\)'\''$/\1/' myfile
MYVALUE

After this, assigning this value to a shell variable is as easy as capturing the output using back ticks:

$ SHELLVAR=`sed 's/^MYVAR='\''\(.*\)'\''$/\1/' myfile`
$ echo $SHELLVAR
MYVALUE

Split strings and join lists using Bash

Posted in General on March 10th, 2009 at 15:19 – 6 Comments

This weekend I wrote some more Bash functions for my .bashrc file that I thought were worth sharing. The idea came after trying to do a similar thing while writing my addtopath function.

The first one is mysplit, which is not much more than a Bash wrapper for a short Awk script. It takes the contents of a file or a string from standard input (so that another program’s output can be piped to it) and splits it in separate lines. It uses a user provided string as a delimiter. Actually, this delimiter is treated as an Awk-compatible regular expression, which only makes this even more powerful.

I am changing Awk’s field delimiter, and then in each line fed to the script, iterate through all the fields and print each on of them in a line of its own.

function mysplit
{
    DEFAULT_DELIMITER=" "

    delimiter=${1:-$DEFAULT_DELIMITER}
    inputfile=$2

    awk -F "$delimiter" \
    '{  for(i = 1; i <= NF; i++) {
            print $i
        }
    }'
$inputfile

    return $?
}

Of course, if there is a mysplit, there has to be a myjoin. And here it is indeed. This function does exactly the opposite of mysplit. It takes several lines from a file or from stdin and turns them into a string, using a user provided delimiter as “glue”.

Here I use an Awk/Sed combination (you have to love those two once you get to know them a bit). With Awk, I’ve changed its ORS (Output Record Separator) from the default new line character to whatever the user wants as delimiter and then simply print everything. There are two problems with this: Awk will print the delimiter also after the last record and, if this delimiter does not contain a new line feed, none will be printed at the end. We need a new line at the end in order to have an output that we can pipe to other programs, as we will see in the examples below. Enter Sed, which I’ve used to replace the last delimiter with a new line character. Problem solved:

function myjoin
{
    DEFAULT_DELIMITER=""

    delimiter=${1:-$DEFAULT_DELIMITER}
    inputfile=$2

    # Avoid treating this delimiter as a regex:
    delimiteresc=`echo "$delimiter"; | addslashesforsed`

    awk -v ORS="$delimiter"  '{print}' $inputfile | \
        sed "s/$delimiteresc\$/\n/" # Remove the last delimiter and
                                    # add a new line char at the end

    return $?
}

The delimiter, in this case, is a normal string but we need to prevent Sed from treating it like a regex, and for that I use addslashesforsed:

function addslashesforsed
{
    filename=$1

    sed $filename \
        -e 's#\\#\\\\#' \
        -e 's#/#\\/#' \
        -e 's#\.#\\.#' \
        -e 's#\*#\\*#' \
        -e 's#\[#\\[#'

    return $?
}

By combining those two functions (mysplit and myjoin) we can obtain a lot of extra functionality. I have coded a simple function that uses both of them in order to remove a specific element from a delimited list that is stored in a string. I have called this function myrmlistitems, which says a lot about my (lack of) function naming skills. I wrote this one with the my previous post’s addtopath function in mind, so that the step where the directory to be inserted in the PATH is first removed from it could be done in a more elegant (and correct, as I have found out later) way.

function myrmlistitems
{
    DEFAULT_DELIMITER=""

    element=$1
    delimiter=${2:-$DEFAULT_DELIMITER}
    inputfile=$3

    [ -z $element ] && return 1

    mysplit "$delimiter" $inputfile | grep -v "^$element\$" \
        | myjoin "$delimiter";
}

Finally, as trivial examples and just for fun, I am using myjoin in the process to calculate the factorial of a number, myrmlistitems to get rid of one of the directories in the PATH and mysplit to show the PATH contents in separate lines

jdevera@aurora:~$ seq 4
1
2
3
4

jdevera@aurora:~$ seq 4 | myjoin '*'
1*2*3*4

jdevera@aurora:~$ seq 4 | myjoin '*' | bc
24

jdevera@aurora:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games

jdevera@aurora:~$ echo $PATH | myrmlistitems /usr/local/bin :
/usr/bin:/bin:/usr/bin/X11:/usr/games

jdevera@aurora:~$ echo $PATH | mysplit ':'
/usr/local/bin
/usr/bin
/bin
/usr/bin/X11
/usr/games

Adding directories to the PATH in Bash

Posted in General on February 21st, 2009 at 18:09 – 3 Comments

When I am working on a Linux machine for which I don’t have administrator rights and want to use a program that is not available, or even a newer version of a program that’s already installed, I just install it somewhere in my home directory and add the directory where it is stored to the PATH environment variable. If I want to override an existing version of a program that is already in the system, I will have to prefix my program’s directory to the PATH, so that it is found before its system wide counterpart. If I just want to add some functionality that was not available, I can either prefix or append the directory to the PATH. The usual way to do is is to add lines like these to the shell configuration file (.bashrc for my beloved Bash).

export PATH=/home/jdevera/mybinaries:$PATH
export PATH=$PATH:/home/jdevera/mybinaries

I find this a bit unpleasant to read, so I use these functions instead:

function addtopath
{
    directory=`echo $1 | sed 's#/$##'`  # remove trailing slash
    where=$2

    # Add only existing directories
    if [ ! -d $directory ]; then
        return 1
    fi

    # If the directory is already in the path, remove it so that
    # it can be inserted in the desired position without
    # poluting $PATH with duplicates
    newpath=`echo $PATH | tr ':' '\n' | \
             grep -v "^$directory\$" | \
             xargs | tr ' ' ':'`

   
    if [ $where = "beg" ]; then    # Prefix to $PATH
        export PATH=$directory:$newpath
    elif [ $where = "end" ]; then  # Append to $PATH
        export PATH=$newpath:$directory
    else
        return 1
    fi

    return 0
}

# Convenience wrappers for addtopath
#
function pathappend  { addtopath $1 end; return $?; }
function pathprepend { addtopath $1 beg; return $?; }

The main function, addtopath, is smarter than the previous option (exporting the new value):

  • It checks that the directory exists before adding it to the PATH
  • It avoids duplicates in the PATH; if the directory is already in the $PATH, it is removed prior to reinsertion. This means that the directory will be moved within PATH to the desired position
  • It can prefix or append the directory to the PATH

I have also written two small wrappers, pathprepend and pathappend, that prefix and append, respectively, a directory to the PATH, thus making the calls even easier and more legible.

I can now write something like this:

pathappend /home/jdevera/mynewbinaries
pathprepend /home/jdevera/myoverrides

And will get them both in the PATH like this:

jdevera@aurora:~$ echo $PATH
/home/jdevera/myoverrides:/usr/local/bin:/usr/bin:/bin:/usr/games:/home/jdevera/mynewbinaries

Edit: I added semicolons after the return statements in the wrapper functions and this now works on the Korn shell as well.

In The Beginning

Posted in General on February 21st, 2009 at 14:46 – 2 Comments

Finally, a brand new weblog.

I’ve written a brief introduction to myself and this blog in the About page, please have a look.

I really don’t want to write a long and convoluted first post where I would tell you what I am going to write about, I’ll write about whatever I find interesting in the fields of computers, technology in general, the Internet, and all sorts of geeky stuff. I can’t promise, however, that I will always limit my articles to these topics.

I am using a self hosted WordPress installation to manage this weblog and I have decided to use a theme called simpleX. This will change over time. I wanted to create my own theme from scratch and add functionality to it little by little, but I’d rather start writing now and maybe share what I learn in the process with you, my readers (if any). For the time being, Simplex is good enough: I love tags, and it supports tags!.