April 2010 Archives
Wed Apr 21 15:55:50 EDT 2010
Web interface for NanoBlogger: Add entries.
Please bare in mind that this is a proof of concept (that works) but here it is a web interface that allows you to submit entries to NanoBlogger through a BASH CGI. The script is rather simple, it just takes the fields title, description and body then writes it to a text file, you can latter process it through a cronjob or just leave it there for then you get a chance parse it by nb.
For this we will be using 3 code segments, the first would be the HTML form that will allow us to enter the content and pass those values to the CGI besides those two we have a javascript segment that allow us to preview the actual article that we are submitting.
The Form.
In other to have a bit of eye-candy i decided to use the heather and cascade style sheet from the actual style i am using for NanoBlogger. I found that the easiest way was to create a file by running `nb -b /path/of/the/blog/ make-file nb_send_entry.txt`. This will create a template that we can use to add the form HTML inside the 'BODY' section.
The product of this code is a web page with the same look and feel that the blog has. Here is a sample from our Spanish site:

The JavaScript.
If you take a look at above source code we have a 'preview' button; this button calls the function openPreview. The idea of this function is to show how would the HTML that we are codding look using the current style. You can get a good idea on how would this entry look before you submit it. Here is the code:
As you can see we are defining a new window and opening it with the content we entered on the form, it uses the nb_default.css. Most of the customizations can be done on in popWin.document.writeln in case you want to adapt it to your blog. Remember that this is a proof of concept and that it can still be improved, perhaps we can latter make it to read the blog.conf file. Here is a screenshot of how it looks.

All you need is BASH.
A CGI codded in bash to create the new entry for the blog. Here is the source code of send_nb_entry.cgi
We can latter import the file defined by $DRAFT_ENTRY_DIRECTORY/$name_entrada_tmp issuing the command:
This will add the entry to our blog. I though about automating this in the CGI but at this point i prefer to create a central control panel and keep things separated.
Spanish version: Interfaz web para agregar entradas a NanoBlogger.
Wed Apr 21 12:52:16 EDT 2010
ZNC IRC Bouncer start up script.
A few weeks a go I published an article about how to have push notifications to your iPhone from an IRC channel events. After installing and configuring ZNC I was a bit disappointed that it didn't had a start up script so I decided to write one.
This script allows you to start, stop, reload the configuration and restart the service. lets take a look at /etc/init.d/zncd
If your NSLU2 is running gentoo you could add it to the default run level like this:
The output should be something like this:
Spanish version: script de arranque para ZNC bouncer.
Sun Apr 11 19:11:00 EDT 2010
Bluetooh Audio Through the NSLU2.
@POTUSCamacho has an interesting article about how to use the NSLU2 in combination with a USB bluetooth adapter as an audio server. POTUSCamacho explains how to do it with a mono audio adapter but clarifies that it should be possible to do it using a stereo adapter.
Lets take a look at this interesting howto:
Once you have installed Ubuntu, log in and update your packages:
Then install the following packages:
Note: I do alot of other development stuff on my unit. I may have left off something, and if so let me know if you try it and it doesn't work.
Now that the needed packages are installed, an .asoundrc needs to be created in your user home directory. An example:Edit the device section with the MAC address of your bluetooth headset. To find this, issue a reset of the bluetooth adapter by issuing the command:
Then place your headset in pairing mode and issue the following command:
Now copy the following python script into a file named pair.py:
Now place your headset into pairing mode again and issue the follow command:
Once again replacing the address above with your headsets MAC. The last step involves editing the vlcrc. To do this, issue the command:
Scroll down and replace:
To:
If it does not exist then create it.
Now you should be ready to listen to audio. To listen to the audio from NASA TV's online video stream, issue the command:
If everything is working you should hear audio. Keep in mind that the sample rate needs to be 8000Hz since that is the sample rate the headset can handle.
To pair another headset, or to re-pair the current, the /var/lib/bluetooth/(your MAC)/linkkeys file must be deleted. It will regenerate once you have paired the devices. Also remember that the .asoundrc file must be edited to match a different headset as the MAC will be different.
To find out more info about this article, please visit POTUSCamacho Industries blog.
Spanish version: Audio vía bluetooh desde el NSLU2.