↓ Twitter is updated more often, so read it! ↓

Archive for the ‘howto’ Category.

How to rapidly expunge Facebook’s Friend Suggestions

I really admire Facebook’s Friend Suggestions feature. It has on rare occasion shown someone to whom I’d really like to connect. Most of the time, though, it shows people who I don’t know at all and have maybe one mutual friend. So, it’s largely useless to me.

However, being the often mindless user, when I see a suggestion that may be relevant to my interests, I do visit the full friend suggestion page and see if there are any others. Rarely am I presented with anyone to whom I find a dreadful desire to connect. I still feel obligated to click that damned little [X] as if to say, “I don’t know this person.” Unfortunately, I have to repeat this approximately 25 times in order to full expunge this list of people.

So, I decided to write a little script which takes care of clicking that button for me. Navigate to the Find Friends page on Facebook and execute this script in your Firebug console. Or, prefix it with javascript: and execute it in the URL bar.

d = document.getElementsByClassName("fg_action_hide"); for (var i in d){ d[i].onclick() }

The first part gets an array (a list) of all of the clickable elements with that class, the class used to denote the [X]. The next part loops over them and executes each’s onclick() function just like as if you’d clicked it yourself.

Please note that I tested this ONLY on Firefox and Chromium, but it should work on any modern browser (read: anything but IE).

HOWTO: Add CACert Root Certificates to Chromium

CACert Logo + Chromium Logo

I’ve recently begun using Chromium for most of my day-to-day browsing tasks. It recently gained support for Adobe Flash and other plugins. I’ll be excited to when it picks up Java, as well—then I’ll have little reason to use Firefox except for development. I’ve enjoyed watching the daily builds go from a virtually a crash-on-click shell to the wonderfully quick tool I’m using right now to type this post.

However, I’m a CACert user (and assurer!) and have several sites and/or utilities which rely on CACert-issued free SSL certificates.

Chromium on Linux doesn’t have its own certificate management system, but instead uses Mozilla’s Network Security Services (NSS) Public Key Infrastructure (PKI). The LinuxCertManagement article on Chromium’s wiki gives some instructions on how to import certificates.

I’ve reproduced these instructions for Ubuntu with some of my own additions below.

sudo apt-get install libnss3-tools
wget http://www.cacert.org/certs/root.crt
wget http://www.cacert.org/certs/class3.crt
certutil -d sql:$HOME/.pki/nssdb -A -t "TCu,Cu,Tuw" -n "CACert Class 1 Root Certificate" -i root.crt
certutil -d sql:$HOME/.pki/nssdb -A -t "TCu,Cu,Tuw" -n "CACert Class 3 Root Certificate" -i class3.crt
rm root.crt class3.crt

You’ll now be able to log in to sites using CACert SSL certificates without needing to click through the red screen of hate.

Note that as of the daily build for August 11, 2009, it is not yet possible to accept and/or present a certificate for use with certificate login. Hopefully, this won’t be too far off. Fortunately, I don’t use this login style very often.

HOWTO buy music on-line, Android and Linux style

I have joined a new group of people: those who have paid for music downloads.

I’ve had a T-Mobile G1 since November. It came with the Amazon MP3 application for Android pre-installed. This little application allows G1 users to search Amazon’s fast music catalog, then purchase and download DRM-less music.

One of my New Year’s Resolutions was to go a year without DRM. This makes Amazon MP3 quite attractive to me as I try to stay legal in my music acquisitions now that I have a job. I’ve avoided iTunes primarily because of its DRM-encumbered formats, but Apple recently decided to go DRM-less. However, personally identifiable information is still embedded in the download, raising privacy concerns. There’s also not a Linux version of iTunes—there is a Linux version of the Amazon MP3 downloader, which was recently updated to work on Ubuntu 8.10. I’ve included a little tutorial at the end of this entry to get Amazon MP3 Downloader for Linux working on Ubuntu 8.10 64-bit.

An important thing to note is that when I first added Festival Thyme to my download list, it didn’t complete, and I didn’t notice it for more than three weeks! When I tried again, the application said that the downloads had expired. Unhappy with my first digital download experience, I called Amazon just a few minutes ago, and the CSR was happy to reimburse me so I could try again.

This is the new best way to enjoy music. If I’m on the go, I search Amazon’s catalog using my T-Mobile G1 via EDGE or 3G service, add tracks or an entire album to my downloads list, then watch the songs download when next I connect to the Internet via Wi-Fi. This is the way music downloading should be: inexpensive, available everywhere, and, most of all, free of restrictions of DRM.

And now, the tutorial on installing Amazon MP3 Download for Linux on Ubuntu 8.10 64-bit.

First, download the Amazon MP3 Downloader package to your Desktop.

Second, install some packages from the command line, or by clicking on this apt-url link: sudo apt-get install libgtkmm-2.4-1c2a libboost-thread1.34.1 libboost-iostreams1.34.1 libboost-signals1.34.1 libboost-date-time1.34.1 libcurl3 libssl0.9.8 xdg-utils.

Third, do sudo dpkg --force-architecture -i amazonmp3.deb to install the package.

Fourth, ensure that the 32-bit libraries are installed by first installing getlibs (click to download and install with GDebi), then going to a command line and doing sudo getlibs $(which amazonmp3). This will download the 32-bit libraries which Amazon MP3 Downloader needs.

Amazon MP3 Downloader will be available in the Applications > Internet menu.

Good luck, and happy downloading.

HOWTO: Install Gears on 64-bit Linux

I recently noticed that Wordpress added support for Gears, as have a few other sites, including ZohoOffice and MySpace.

Gears is essentially offline storage for rich Internet application data. GoogleOS has a list of Gears-enabled sites/applications. Read more on Gears at Wikipedia.

Much to my dismay, the only officially-available Firefox extension supports only 32-bit operating systems. I’m a 64-bit Linux user. Specifically, I use Ubuntu 8.10 Intrepid with my ASUS M3A32-MVP motherboard and 8 GB of DDR2 RAM (4GB of Geil and 4 GB of OCZ).

Fortunately, Gears is an open source project and one intrepid developer made a Gears Firefox extension package which supports 64-bit Linux.

I downloaded and installed the package by dragging and dropping it onto the Firefox Addons dialog, then restarting Firefox when prompted. I archived the Gears extension package on my own site in the event the package is suddenly no longer available. Be sure to check for new versions though, since this package may be out of date if you’re reading this post more than a few days after publication (though unlikely).

Huzzah for open source.

Adobe releases Flash 10 beta for Windows, Mac OS X, and Linux

Adobe released today beta packages for the upcoming version of its Flash player. The Flash 10 packages are available for download at Adobe Labs. Users have reported a serious speed increase and far less CPU usage, as much a 20% less. Check out the Flash 10 release notes for more information.

There is an RPM and a tar.gz for we Linux folks. Red Hat and Fedora users are fine with the RPM, but Ubuntu users will have a little more to do. Download the Flash 10 tar.gz, then continue.

Iinstalling it is easy. If you’re running 32-bit Ubuntu, simply make sure that flashplugin-nonfree is installed and copy the libflashplayer.so file in the tar.gz to .mozilla/plugins or to /usr/lib/flashplugin-nonfree. If you’re using 64-bit Ubuntu like I am, then you’ll have to do the latter and run nspluginwrapper -i /usr/lib/flashplugin-nonfree/libflashplayer.so to relink everything.

This release is on the heels of the recent announcement of the Open Screen Project, a project aims to put Flash on basically everything by opening up many of the workings of the proprietary format. To begin, Adobe will “[lift] restrictions on use of the SWF and FLV/F4V specifications, publish the device porting layer APIs for Adobe Flash Player, publish the Adobe Flash Cast protocol and the AMF protocol for robust data services, and [lift] licensing fees, making next major releases of Adobe Flash Player and Adobe AIR for devices free.”

Social engineering on The Daily WTF

The Daily WTF has a story about social engineering at its finest.

Read The Super Hacker at The Daily WTF.

HOWTO Add btnx repository to sources

Olli Salonen made a PPA on Launchpad yesterday, following my request for btnx in a PPA.

There are two ways to get the repository configured: the GUI way and the command line way. I think the command line way is a little quicker, but I’ll give you both. Remember, if you are not running Hardy, you will need to change all instances of hardy throughout these instructions to feisty or gutsy, whichever you are using. Olli did packages for all three versions. If you don’t know which you’re running, go to System > About Ubuntu and read the window that spawns. Your version will be in there somewhere.

First the command line way.

echo -e "deb http://ppa.launchpad.net/daou/ubuntu hardy main\ndeb-src http://ppa.launchpad.net/daou/ubuntu hardy main" | sudo tee /etc/apt/sources.list.d/btnx.list
sudo apt-get update && sudo apt-get install btnx btnx-config

Then, I’d recommend using btnx-config from Applications > System Tools > btnx to configure the tool. You could also do gksu btnx-config at the command line to bring it up.

Next, the GUI way.

If you already have btnx installed, go to System > Administration > Software Sources. Go to the Third Party Software tab. Click +Add and paste the line for each of the two APT lines: deb http://ppa.launchpad.net/daou/ubuntu hardy main and deb-src http://ppa.launchpad.net/daou/ubuntu hardy main. When you click Close, it will ask if you want to reload the sources. Confirm the reload.

If you do not already have btnx installed, go to System > Administration > Synaptic Package Manager. Go to Settings > Repositories and follow the above instructions. One the list finishes reloading, Search for “btnx” and the two packages will be shown in the main screen. Click each to mark it for installation, then click Apply. When it’s finished, you can access btnx-config through Applications > System Tools > btnx from the top panel.

Check out my prior updates on btnx for more information, including how to compile btnx and btnx-config from source.

Update on btnx HOWTO

Olli Salonen, author of btnx, has released new versions of btnx and btnx-config, along with debs for Ubuntu 64-bit. While they’ve been officially tested on Gutsy, I’m using them on Hardy without a problem. Now, Olli or someone just needs to get these into a PPA on Launchpad or get them added to the repos for 8.04.1.

Se vi parolas esperantan linvgon, bonvolu helpas traduki btnx-on ĉe Launchpad! Iru kaj traduku btnx-config! Mi komencis traduki, sed ĝi estas granda projekto por unu persono.

I originally posted instructions on how to compile from source in the article HOWTO Install btnx for better mouse control in Ubuntu Hardy. If you want to continue to compile it yourself, simply switch to the newest tag using subversion and recompile.

cd btnx-0.4.9
svn sw http://svn.ollisalonen.com/btnx/tags/btnx-0.4.10/
./configure && make && sudo make install
cd ../btnx-config-0.4.8
svn sw http://svn.ollisalonen.com/btnx-config/tags/btnx-config-0.4.9/
./configure && make && sudo make install

Now might be a good time to rename those directories, dropping the version numbers, or check out the source to a different directory.

HOWTO Install btnx for better mouse control in Ubuntu Hardy

When I installed Hardy, I forgot to copy my awesome xorg.conf which held the configuration to enable all 12 buttons of my Logitech MX1000.

Lo and behold, a new method of configuring it has come about, albeit it was around prior to Gutsy.

btnx is the work of Olli Salonen. The program runs as a daemon, catching mouse events and turning them into either key presses or proper mouse events which the system can interpret. This eases the configuration one must do in order to enjoy the full potential of the high-end Logitech mice—a potential which, in my opinion, Windows cannot reach.

The installation process for btnx is pretty easy.

First, I replaced the mouse section of my /etc/X11/xorg.conf with this section. This may not be necessary, but I did it before discovering btnx.

Section "InputDevice"
        Identifier      "Logitech MX1000"
        Driver          "evdev"
        Option          "Name"          "Logitech USB RECEIVER"
        Option          "HWHEELRelativeAxisButtons" "7 6"
EndSection

Next, open a terminal and cd to the location where you keep your sources. I keep mine in ~/Source. This next section prepares the libraries required to build btnx and its support program, btnx-config, as well as subversion if you don’t already have it installed. I prefer to use subversion and checkout tags if they are available. It makes switching to a new version just a svn sw away. Last, it checks out the source for the two programs.

sudo apt-get install subversion libgtk2.0-dev libglade2-dev libdaemon-dev
svn co http://svn.ollisalonen.com/btnx/tags/btnx-0.4.9/
svn co http://svn.ollisalonen.com/btnx-config/tags/btnx-config-0.4.8/

Next, do a simple cm&smi for each program.

cd btnx-0.4.9
./configure && make && sudo make install
cd ../btnx-config-0.4.8
./configure && make && sudo make install

Now that both programs are installed, you must first configure btnx using btnx-config. Start it as root using the command below or go to Applications > System Tools > btnx. Click “Detect Mouse and Buttons”. You’ll probably be able to figure it out from there.

gksu btnx-config

I have the middle thumb button on my MX1000 configured to activate the Rotate Cube plugin of Compiz. I have it configured as Button10 in Compiz and BUTTON_9 in btnx. Remeber: Compiz and many other programs start counting buttons at 1, but btnx starts at 0.

Update: There is a post on Ubuntu Forums about building btnx, too.

Update 2008-04-29 01:18: I’ve posted an update. New versions of btnx and btnx-config are available and so are debs for both 32-bit and 64-bit Ubuntu.

Update 2008-11-05 20:56: As Christopher pointed out, Btnx is useless in Intrepid. Olli, the author of btnx, remarks that the way btnx interacted with the kernel is no longer available, so all development on btnx has ceased. However, he says, evdev is able to recognize all of the buttons on the Logitech MX Revolution. Folks who might be willing to decode the cryptic xevents system and figure out how to assign mouse events to other keypresses and such should contact him.

HOWTO Update Twitter from the console or GUI

I’ve gone and added to the script, checking for errors and making it more slick.

Check it out at twitter-gx or read the code contained herein.


#!/bin/bash
#@Name: twitter-gx
#@Author: Colin Dean <cad@cad.cx>
#@URL: http://cad.cx/twitter
#CHANGE THESE
EMAIL=you@yours.com
PASSWORD=lolz
#PATHS
ZENITY=/usr/bin/zenity
CURL=/usr/bin/curl
ICON=/usr/share/pixmaps/gnome-irc.png
#can someone suggest a better icon?
#STRINGS--someone want to localize?
WHAT="What are you doing? "
SORRY="Sorry, that was too long."
UPDATED="Tweet submitted:"
FAILED="Tweet failed. Check output for why."

CURL_MISSING="curl was not found at ${CURL}. Please install curl."
ZENITY_MISSING="zenity was not found at ${ZENITY}. Please install zenity."
#-------Woe to those who make changes below unless they know what it does------#

#META
NAME="twitter-gx"
VERSION="1.0"
URL="http://cad.cx/twitter/twitter.xml"
#functions galore
function check_for_deps {

#I'm not going to bother checking for awk. Does any sane distro omit it?
  if [ ! -x ${CURL} ]; then

    CURL=`which curl`
    if [ "$?" = 1 ]; then

      warn_user "${CURL_MISSING}"
      exit 1
    fi
  fi

  if [ ! -x ${ZENITY} ]; then

    ZENITY=`which zenity`
    if [ "$?" = 1 ]; then

      warn_user "${ZENITY_MISSING}"
      exit 1
    fi
  fi

}

function getinput {
  if [ ${TERM} = "xterm" ]; then echo -n "${WHAT}"; read TWEET
    else TWEET=$(${ZENITY} --entry --text="${WHAT}" --entry-text="${1}")

  fi
}

function check_length {
  TWEETLENGTH=$(echo -n "${TWEET}" | wc -m)

  if [ ${TWEETLENGTH} -gt 140 ]; then

    warn_user "${SORRY} (${TWEETLENGTH} > 140)"
    getinput "${TWEET}"

    check_length
  fi
}

function warn_user {
  if [ ${TERM} = "xterm" ]; then echo "${1}"

    else ${ZENITY} --warning --text="${1}"
  fi

}

function urlencode () {
#one day, I will understand awk
#got this from somewhere
  echo "$@" | awk '

  BEGIN {
   # with inspiration from Heiner Steven and Rick Richardson
      split ("1 2 3 4 5 6 7 8 9 A B C D E F", hexit, " ")
      hexit [0] = 0 # setup the hex values we will use..
      for (i = 1 ; i <= 255 ; ++i) ord[ sprintf ("%c", i) "" ] = i + 0

    } {
      encoded = ""
      for (i = 1 ; i <= length ($0) ; ++i) {
        c = substr ($0, i, 1)
        if ( c ~ /[a-zA-Z0-9.-]/ ) { # allow only basic chrs
          encoded = encoded c

        } else { # encode everything else..
          lo = ord[c] % 16
          hi = int (ord[c] / 16);
          encoded = encoded "%" hexit [hi] hexit [lo]
        }

      }
#printf encoded
    }
  END {
    printf ("%s", encoded)
  }

'
}

function submit_tweet {
  OUTFILE="/tmp/twitter_response-`date +%Y%m%d%H%M%S`.txt"

  ${CURL} -s \
       -u ${EMAIL}:${PASSWORD} \
       -o ${OUTFILE} \
       -d status="$(urlencode "${TWEET}")" \
       -H "X-Twitter-Client: ${NAME}" \
       -H "X-Twitter-Client-Version: ${VERSION}" \
       -H "X-Twitter-Client-URL: ${URL}" \
       http://twitter.com/statuses/update.xml

}

function notify_user {
  if [ "${1}" = "success" ]; then

    TERM_MESSAGE="${UPDATED} ${TWEET}"
    GUI_MESSAGE="${UPDATED}\n\n${TWEET}"

    ICON_STR="--window-icon=${ICON}"
  fi
  if [ "${1}" = "failed" ]; then

    TERM_MESSAGE="${FAILED}"
    GUI_MESSAGE="${FAILED}"
    ICON_STR=""

  fi

  if [ ${TERM} = "xterm" ]; then echo "${TERM_MESSAGE}"

    else
      exec 3> >(${ZENITY} --notification --listen ${ICON_STR})

      echo "message: ${GUI_MESSAGE}" >&3
      sleep 10
      exec 3>&-
  fi

}

TWEET=$@ #see if it was supplied on the command line
if [ "${TWEET}" = "-v" ]; then echo "${NAME} ${VERSION}" && exit; fi

check_for_deps
if [ -z "${TWEET}" ]; then getinput; fi #if it wasn't, prompt for it

check_length #make sure it's less than 140 characters
submit_tweet #submit it since we got past the check

if [ "$?" == 0 ]; then notify_user success && exit 0;

else notify_user fail && exit 1; fi