Sun Sep 4 11:43:22 EDT 2011
Video: How to add a menu option to permanently delete a file in Gnome 3
There might be times when you want to bypass the trash can while deleting some files in Gnome 3, luckily there is a way to add this bypass option to the context menu of Nautilus (Gnome's 3 file manager) in Fedora 15 and I have a video to guide you through it.
The process basically consist in editing the preferences of Nautilus, to do so you can just click on 'Edit' and then on Preferences in Nautilus like so:

Next we navigate to the 'Behaviour' tab which is the second to the right.
Among the last options, you enable the option that says 'Include a Delete Bypass...'
At this point you are done, just remember that you wont be able to recover those files unless you use some forensic tools. Please note that this guide was done based on Fedora 15, it might change in other Linux distributions
Here is a Spanish version of this post: Eliminar archivos permanentemente
Mon Jul 26 11:31:54 EDT 2010
Limit the space of a samba share without using disk quotas
Recently a friend of mine asked me if it was possible to limit the amount of space taken up by a user on a samba share without using disk quotas. I assumed it could be done through the smb.conf but since I have never worked with samba I wasn't sure. A bit of research here and there came to nothing so I decided to write a script and solve this problem the dirty way. My friend manages a small network where users run workstations with MS Windows.
First things first, let's create a file containing the usernames and the amount of space we want to give them. Something like this:
# cat /tmp/smbusers.txt maria.perez,5 arnaldo.hernandez,5 gustavo.flores,10 jesus.boss,5 marta.hernandez,5 wilkneman.pascoski,5 tatiana.siu,5 alexandra.delarosa,5
Using this information I need to create the configuration to be appended to the smb.conf; it needs to have the following format:
[alexandra.delarosa] comment = alexandra.delarosa with 5MB path = /mnt/smb_discs/alexandra.delarosa read only = no browseable = yes guest ok = yes [arnaldo.hernandez] comment = arnaldo.hernandez with 5MB path = /mnt/smb_discs/arnaldo.hernandez read only = no browseable = yes guest ok = yes [gustavo.flores] comment = gustavo.flores with 10MB path = /mnt/smb_discs/gustavo.flores read only = no browseable = yes guest ok = yes
Here is the script which basically reads the list of users and how much space they are allowed to use and creates disk images using the command dd, then it mounts each of these images as loop back devices and creates a file with the information that has to be appended to the smb.conf file.
LISTASMBUSERSS=`cat /tmp/smbusers.txt|sort`
PATH_TO_DISKS="/smb_disks/smb_drives"
MOUNT_SMB="/mnt/smb_discs"
TMPSAMBACONF="/tmp/samba.virt.conf"
echo > $TMPSAMBACONF
mkdir -p `echo $PATH_TO_DISKS`
for X in $LISTASMBUSERSS
do echo $X | awk -F , '{print "assigning " $2 "MB to smb_user "$1}'
SMBUSERS=`echo $X | awk -F , '{print $1}'`
PRE_SMBQUOTA=`echo $X | awk -F , '{print $2}'`
let SMBQUOTA=`echo $PRE_SMBQUOTA`*1024
dd if=/dev/zero of=$PATH_TO_DISKS/$SMBUSERS.img bs=1024 count=$SMBQUOTA
/sbin/mke2fs -L $SMBUSERS -j $PATH_TO_DISKS/$SMBUSERS.img
mkdir -p $MOUNT_SMB/$SMBUSERS
mount -t ext3 $PATH_TO_DISKS/$SMBUSERS.img -o loop $MOUNT_SMB/$SMBUSERS
echo "[$SMBUSERS]
comment = `echo $SMBUSERS" with "$PRE_SMBQUOTA"MB"`
path = /mnt/smb_discs/$SMBUSERS
read only = no
browseable = yes
guest ok = yes
" >> $TMPSAMBACONF
done
echo "Used space in $PATH_TO_DISKS: "
du -smh $PATH_TO_DISKS/*.img
du -smh $PATH_TO_DISKS/
mount -l | grep $MOUNT_SMB
echo "CHECK $TMPSAMBACONF AND ADD IT TO YOUR /etc/samba/smb.conf"
My friend would just have to add the output of the script located in /tmp/samba.virt.conf to his /etc/samba/smb.conf and restart the service.
Please note that I have never worked with Samba before so if you know a better way to do this without using disk quotas please let me know.
Original Article (spanish version): Limitar el espacio de una carpeta sin usar cuotas en Samba.
Wed Jun 9 16:23:49 EDT 2010
Shell script to backup NanoBlogger to a remote server
This is a simple script that creates full backups of our NanoBlogger blog by compressing our DocumentRoot directory and upload it to a remote server via SCP.
Lets take a look at it:
#!/bin/bash BLOG_PATH="/path/to/the/directory/that/contains/your/blog.conf/" BLOG_NAME="orvtech.com" DATE=`date +%d%b%Y-h%Hm%M` NO_BAKUP="cache/*" SCP_SERVER="" SCP_USER=" " SCP_PORT="22" cd $BLOG_PATH tar -czpsf ~/$BLOG_NAME-nanoblogger.$DATE.tar.gz --exclude "$NO_BAKUP" * ls -lah ~/$BLOG_NAME-nanoblogger.$DATE.tar.gz scp -P$SCP_PORT ~/$BLOG_NAME-nanoblogger.$DATE.tar.gz $SCP_USER@$SCP_SERVER:~/
Spanish version: Respaldar NanoBlogger.
Tue May 18 10:57:05 EDT 2010
Find the biggest file or folder inside a directory.
By using the `du` command we can find the biggest file or directory inside a folder. The next example shows how to list the 10 most biggest files and floders inside 'HOME'
du -a ~/ | sort -n -r | head -n 10
If we use the `find` command we can list the 10 biggest files inside a directory, even if they are inside sub-folders.
find ~/ -type f -exec ls -ls {} \; | awk '{print $6"\t"$9}' | sort -k1 -n -r | head -n 10
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.
Fri Mar 26 12:49:32 EDT 2010
A BASH CGI as a workaround to .htaccess files on lighttpd
As you might remember, in a previous post I explained how to maintain a permanent link which always points to the latest submission on your nanoblogger website. Since I decided to migrate from apache to lighttp I lost the ability to use .htacees files thus .htacees file based redirects do not work anymore.
The workaround.
We will keep using the /latest url for the redirects the only thing is that we will use a CGI written in
BASH to accomplish the redirect. The script will parse our RSS feed (rss.xml) to check which is the latest
post and redirect to that url. The redirect is accomplished by sending the HTTP headers 'Location' and
'Status'. Let's take a look at the script:
latest.cgi
Here we are sending the Status header to prevent search engines from associating more than one url to the same content (this will give us a lower score in some search engines' systems) and then we send the Location header to do the actual redirect.
Lighttp and CGIs.
In other to execute this CGI we need to make some minor modifications to our VirtualHostost configuration.
Lets add these two lines to it:
In the first line we are telling lighttpd to use /bin/bash to execute any *.cgi file (you can change this
to anything like *.sh, *.bash). In the second line we redirect all requests to /latest/ to the url
/latest.cgi. You can either use /latest.cgi or /latest/ for these urls in your signature at the forums;
personally I like to use /latest/
Spanish version: Un CGI en BASH para mantener tu firma al dia en todos los foros en que participas.
Posted by orvtech | Permanent link | Comments | File under: Scripts, NSLU2, Linux, nanoblogger, lighttp
Fri Mar 19 11:03:40 EDT 2010
From Picasaweb Albums to BBCode
This script has the same function as the Flickr script, it takes a Picasaweb album and gets the BBCode to allow you to share it on a forum, the urls that we are going to work with have the picasaweb.google.com/
http://picasaweb.google.com/orvtech/Hdd
Lets take a look at the code:
Lets name this script Picasa2BBCode.sh, we can execute it like this:
We can modify the constant SIZE in this script, it can take the values 72px, 144px, 288px, 320px, 400px, 512px, 576px, 640px, 800px or 1024px but if the image is smaller than 800px we might have some problems. Running the script will produce an output like this:
Spanish version: De Picasa a BBCode.
Tue Mar 16 10:27:06 EDT 2010
From flickr to bbcode script
As you know I participate a lot in internet forums and most of these use BBCode to let us pulish photos, youtube videos, links, etc. Since I like to share photos and dont want to copy the url of each image on a set of 60 or more images on flickr I decided to automate this and wrote a simple script that will generate the BBCode from a flickr set url.
Lets take a look at this script, lets call it flickr2bbcode.sh
If you want to run this script you will need to pass the url of the set of photos that you want to publish, for example http://www.flickr.com/photos/tatadbb/sets/72157606893687387/ so your command line will look like this:
The out put of this command would be something like this:
Spanish version: De Flickr a BBCode.