I’ve just discovered an incredibly annoying bug downgrade “feature” in the new firefox (3) – the new add-search-plugins site is broken. I noticed it in later versions of firefox 2.x as well: I was kind of hoping it was something temporary but it looks like its here to stay.
(Quick solution: ignore the site the “Add engines” link takes you to and go to mycroft.mozilla.org instead – its all there).
I’m a big fan of the firefox search bar: I have it setup for google, google images, dictionary.com, urban dictionary, wikipedia, wikiquote, youtube, imdb and ebay. I’ve even written two search plugins in use at the computer science dept at my university which is used to search the staff directory + and general website. I use them all the time, and they will be included in the firefox 3.x deployed to the workstations our 17+ computer labs this semester.
So I’m a fan, I consider search plugins a highly desirable if not essential time-saving feature in my browser, and as soon as I install a new copy of firefox, I take time out to customise my search menu pretty much straightaway. I quietly evangelise the feature to others, show them how easy their common searches can be. Click here, click there, bam, done, easier, isnt firefox great?
Problem is, Â what used to be a simple and smooth process is no longer. By default anyway – and only if you’ve upgraded your browser relatively recently.
Now I haven’t actually gone back and installed an older version to check or anything, but I’m pretty sure that getting more search plugins used to be a case of dropping the search menu, selecting “Manage Search engines”, then “Get more search engines” (or the equivalent text) in the settings dialog.
This would take me to a site I never bothered to remember the URL of, since the link was always right there in settings.
Used to be, I could go *wherever the aforementioned link went*, type in the name of *major searchable site* I wanted to add (ebay/youtube/wikipedia/etc) and would be presented with a list of links – click on them, approve the security popup, and wham, the plugin is added. It was quick and easy, and I found that if I was searching somewhere (ebay for example), rather than go straight to the site and use their search, it was worth the 60 or so extra seconds to go via the search plugins site and add them to my search bar.
Now, this simplicity is broken, due to a simple change: the “Get more engines” link now takes me to addons.mozilla.org. Different site, ok, cool – as long as it gives me the functionality, right? I have faith. Its landed me automatically in the ‘Search plugins’ category. Cool. I seach for ‘ebay’. It turns up… zilch. Searching for ‘google’ gives me… ‘AOL search’ (wtf?).
Oh no.
A couple of minutes later navigating around and trying different searches with no fruit, I realise that regardless of whether this site actually does conspire to harbour the search bar plugins I pursue, perhaps concealed behind some menu or search option I have overlooked, however n00b-like I may be in overlooking said option, this new way of adding plugins has failed, catastrophically. It has failed the end user test. Namely, its chief advertised function – adding searchbar plugins – is nowhere in sight. Not to the casual user, and not to me. It is, it seems, akin to getting in a taxi, asking to be taken to a restaurant and being dumped at the local gymnasium. I wanted a hamburger and I didn’t even get something edible. The place I’ve been taken is not even related.
So I dumped the broken site and hit google looking for firefox search plugins. A couple of links in, I found what looks like the old site – mycroft.mozdev.org - which has the goodness, the instant search, the 60 second convenience I wanted. I bookmarked it, problem solved – for me, anyway. Now I remember that URL in case I need to add more plugins on another machine, or demonstrate the add plugins feature on someone elses browser.
I just hope this difficulty doesn’t put people off using firefox, especially those migrating from other browsers.
I recently wrote this bash script for the purpose of a simple selective backup on one of our linux servers. It tars up a bunch of files and copies them to a windows / SMB server elsewhere on the network (where it is then backed up to tape as per everything else on that server). I know there are many different examples of this type of script on the interweb already, but someone might find this version helpful as well.
There seems to be a few different ways to get the SMB bit done but I ended up using smbfs: you’ll need this on your system for this script to work. If you don’t have it and you’re using a package manager it should be pretty simple to get, a bit of apt-get install smbfs should do the trick.
Note: I am aware of various security issues with running scripts as root, storing passwords in scripts, and this sort of thing. Since this is a super simple backup script, I’m doing it anyway : Complaints department is /dev/null ;)
Script 1: this is a super simple version. It tars and copies some folders to the remote share and thats it.
#!/bin/bash
#simple backup script
#by Glen Scott, glenscott.net
# set smb server and auth vars
sharename="//ourserver/ourshare"
username="ourdomain\ourbackupuser"
password="passwordgoeshere"
backuplocation="/backups/*"
savepath="/root/"
filename=$(hostname).backup.$(date +%a).tar
mountpoint="/mnt/smb"
#tar up the backup folder
tar -cf $savepath$filename $backuplocation
#connect to the share
mount.smbfs $sharename $mountpoint -o username=$username,password=$password
# move the tar
mv -f $savepath$filename $mountpoint
# disconnect the share
umount $mountpoint
#all done!
Script 2: this is the second version I made for another box. It needed a mysql database backed up as well so I added a few lines in for that. I also took the chance to add a quick working folders checker / creator, tidy it up a bit and comment everything.
#!/bin/bash
# simple backup script
# by Glen Scott, glenscott.net
# this is a simple script to tar.gz certain folder locations and copy them to a SMB share
# this script should be run periodically from crontab
# you will need smbfs installed on your system or modify the samba mount method
# set smb server and auth vars
sharename="//ourserver/ourshare"
username="ourdomain\ourbackupuser"
password="passwordgoeshere"
#set mysql details
mysqlhost="localhost"
mysqlusername="root"
mysqlpasswd="mysqlpasswordhere"
#set which folder locations we want to backup, inc trailing slashes
#add more here and append to the appropriate tar line further down the script if needed
location1="/var/"
location2="/backup/"
#set temp files and folders
backuptemp="/backuptmp/"
savepath="/root/backup/"
filename=$(hostname).backup.$(date +%a).tar.gz
mountpoint="/mnt/smb"
# make sure our working folders are present and accounted for
if [ ! -d "${backuptemp}" ]
then
mkdir $backuptemp
fi
if [ ! -d "${savepath}" ]
then
mkdir $savepath
fi
if [ ! -d "${mountpoint}" ]
then
mkdir $mountpoint
fi
# tar up the files we want into the backup temp
tar -cf ${backuptemp}files.tar $location1 $location2
#dump the local mysql db into the backup temp
mysqldump "-h${mysqlhost}" "-u${mysqluser}" "-p${mysqlpasswd}" --all-databases --lock-tables > ${backuptemp}mysqldump.sql
#tar up the backup temp folder
tar -czf $savepath$filename $backuptemp
#connect the smb share to our mount point
mount.smbfs $sharename $mountpoint -o username=$username,password=$password
# copy the tar (could also move it but whatever you like)
cp -f $savepath$filename $mountpoint
# disconnect the share
umount $mountpoint
#all done
As long as you have smbfs installed, the above should work fine.
A word on smbfs: without it the above script will fail. You can probably install smbfs quite easily on your system with the command apt-get install smbfs (or yum if you’re using redhat/fedora, or whatever your flavor of package manager happens to be). I use debian, so apt-get works just fine for me.
A word on Crontab: You’ll need to add the script to your local cron to get regular backups.
I won’t go into hideous details about how crontab works, theres plenty of that on the net already. To keep it simple, if your distro supports it (most should) you can put a symlink to the script in /etc/cron.daily or /etc/cron.weekly which will give you a simple schedule.
If you want something a bit more complicated, you’ll have to mess with the crontab. I’m aware there are commands to get this done but I’ve always just edited the system crontab directly. Mine runs twice a week, on wednesdays and fridays, so my crontab line looks like this:
# m h dom mon dow user command
0 2 * * 3,5 root /root/backupscript
Righto, thats it.
UPDATE: I notice a mutated version of this script has been posted in this forum thread over at linuxquestions.org – cool! Check it out over there if you want to see what someone else has done with it.
Yeah I know theres seventy thousand or so articles out there already talking about modifying wp_list_pages(); to include and exclude various pages from your wordpress site menus, but I’m going to talk about they way I did it anyway =)
The deal is, I’m wanting to publish stories and other standalone type pieces of writing on this site, and I want to create them as nice friendly text wordpress pages, but I don’t want each and every story to appear as a default pages link. The titles are long, there’ll be a few of them, and they’ll screw up my page layout if included in the pages menu(s), especially in the top nav bar where theres limited space.
To change this behavior, you just need to go into your theme template files and add some parameters to wp_list_pages(). The definitive list of parameters is over here and is worth a read:
http://codex.wordpress.org/Template_Tags/wp_list_pages
The most useful ones for this task are ‘include’, ‘exclude’, and ‘depth’. You can string multiple parameters together using the ampersand & character like so: wp_list_pages(foobar=1&moobar=2);
Include and exclude will do as they suggest, given a comma delimited list of page numbers. If you use include it will only include the specified pages, if you use exclude it will include all except the specified pages.
I decided a better way to get it done, actually ideal for my purposes, is to create all my ‘hidden’ pages in a subcategory, and set the depth parameter to ’1′. This means any page created as a subcategory will not appear in the navigation menus, though it can be explicitly linked to, or appear in a list of links for that subcategory (exactly what I want).
The Widgets file
I managed to sort out the top nav bar page listing on my template pretty easily by making the change to the header.php file, but I couldn’t find anything immediately obvious generating the page listing in sidebar.php, or any of the other theme includes. After some bumbling around trying to figure this out, I discovered the sidebar listing was being handled by wordpress widgets . This was pretty easy to fix once I found out where the widgets file is (/wp-includes/widgets.php), although since it uses an array for the parameters its slightly different than the edit above.
You have a few options for changing how the pages display through the wordpress widgets control panel, but sadly no way to exclude sub-pages by default. This would be a cool thing to have available, and I’d write it into the widget file and make my version available, but my php is far too rusty at the moment for this even though its pretty simple.
Ok, how to do it manually. Open up the widgets file for editing and find the section which defines function wp_widget_pages and add to the line which starts as follows:
$out = wp_list_pages (array ('title_li' => '', etc etc and add to it the parameter ‘depth’ => 1, so it ends up looking something like this:
$out = wp_list_pages( array('title_li' => '', 'depth' => 1,'echo' => 0, 'sort_column' => $sortby, 'exclude' => $exclude) );
Thats it. save the file and your side menu should hide all pages in sub-categories.
Also, there is this plugin I found over here which interferes somehow with wp_list_pages(); to cause the change everywhere the function is called. Might save having to mess with multiple places in the template / widgets file depending how your theme is set up. (Mine has pages listed in a top nav bar as well as a side menu, for example).