Posted in : Plugins & Widgets
I decided to have another play with tags as I tend to use them quite a bit on my posts and I'm always forgetting which ones I've used before and which ones I haven't. So I threw together a plugin that will auto-suggest tags based on ones that you've used in the past. It'll also show you a list of all other similar tags in case you have more than one tag with the same starting letter(s) although they're not clickable at the moment because I haven't got that far.
Installation is pretty simple, just download the zip ( AM AutoTags ), upload it, install it, then meander into the plugin settings and set the tag separator for whatever your version uses. That's it. Now when you enter tags you it should try and auto complete them for you and show you a list of other tags.
NOTE : I've only tested this in FireFox as my IE is having a crisis of confidence when it comes to running javascript, so if you use IE and it doesn't work then tough shit. Also, this is a pre-release version so it's bound to have a few quirks, if you find any then just let me know and I'll see what I can do to eradicate them.
¥
*edit* 24th April
I think I've finally managed to convince IE that it can actually understand javascript so this should now work in IE as well, zip file updated
Posted in : Hacks
<bitchchecker> tell me your network number man then you're dead
I advise you don't piss off this hacker ...... unless you're bored ... or sadisitic ... source : Shut Up I Hack You ![]()
¥
Posted in : Techno Babble
I decided to have a play with Bash this weekend as I'd been asked if I could come up with a backup process that was simple enough for the average joe blogs to configure to suit their needs. The script needed to be able to do daily/weekly/monthly backups of selected databases and files/folders and store them on a different server, as a nice touch it also emails the user to let them know that the backup had been done and which databases/files/folders had been included. As well as doing the backups it also keeps the latest 3 in a grandfather/father/son rotation which gives the user 9 potential backups which they can recover from.
As I haven't had a shedload of experience in using bash I spent a fair amount of time hunting round the web looking for clues as to how to do some bits and bats so I thought I'd share some snippets as some of them took a fair amount of searching for/solving and you never know, it may just help someone else in the future ..... probably me ![]()
Code:
#!/usr/bin/env bash | |
# | |
# Read a named file into a variable | |
# | |
| |
# read "file_you_want" into $variable_name | |
contents=$(<foo.txt) | |
| |
echo "${contents}" | |
| |
# | |
# Read a variable file into a variable | |
# | |
| |
# set $variable_name = "file_you_want" | |
my_file='/path/foo.txt' | |
| |
# read file $variable_name into $variable_name | |
contents=$(<"${my_file}") | |
| |
echo "${contents}" |
Code:
#!/usr/bin/env bash | |
# | |
# Convert windows line endings to linux line endings | |
# | |
| |
# set $variable_name = "file_you_want_to_convert" | |
filename='/path/foo.txt' | |
| |
# remove all \r and save the output to $variable_name.linux | |
tr -d '\r' < ${filename} > ${filename}.linux | |
| |
# remove original file | |
rm ${filename} -f | |
| |
# rename $variable_name.linux to $variable_name | |
mv ${filename}.linux ${filename} |
Code:
#!/usr/bin/env bash | |
# | |
# check if a process is already running | |
# | |
| |
# name of the process to check for | |
# add [] around the first letter to stop the "grep process" from showing | |
check_process='[f]oo' | |
| |
if ps aux | grep -q "${check_process}" | |
then | |
echo 'running' | |
else | |
echo 'not running' | |
fi |
Code:
#!/usr/bin/env bash | |
# | |
# switch between 2 directories | |
# | |
| |
# switch to directory 1 | |
cd /path/foo/ | |
| |
# show current directory | |
pwd | |
| |
# switch to directory 2 and "remember" previous directory | |
pushd /path/bar/ | |
| |
# show current directory | |
pwd | |
| |
# switch back to directory 1 | |
popd | |
| |
# show current directory | |
pwd | |
| |
# alternative method | |
| |
# switch to directory 1 | |
cd /path/foo/ | |
| |
# show current directory | |
pwd | |
| |
# switch to directory 2 and "remember" previous directory | |
pushd /path/bar/ | |
| |
# show current directory | |
pwd | |
| |
# switch back to directory 1 | |
pushd | |
| |
# show current directory | |
pwd | |
| |
# switch back to directory 2 | |
pushd | |
| |
# show current directory | |
pwd |
Code:
#!/usr/bin/env bash | |
# | |
# send an email using echo | |
# | |
| |
echo 'your email content' | mail -s 'your email subject' email_1@domain.com email_2@domain.com | |
| |
# | |
# send an email using a file as content | |
# | |
| |
mail -s 'your email subject' email_1@domain.com email_2@domain.com < email_content.txt | |
| |
# | |
# send an email using a variable file for content | |
# | |
| |
# set $variable_name = "file_you_want_to_use_as_content" | |
email_body='/path/foo.txt' | |
| |
mail -s 'your email subject' email_1@domain.com email_2@domain.com < ${email_body} | |
| |
# | |
# send an email using a file and replace "%placeholders%" with variables | |
# | |
| |
# set $variable_name = "file_you_want_to_use_as_content" | |
email_body='/path/foo.txt' | |
| |
# set $variable_name = "replacement_value" | |
foo='bar' | |
| |
# replace the placeholders and email the results | |
# replaces %placeholder% with $foo | |
sed -e "s!%placeholder%!${foo}!;" ${email_body}" | mail -s 'your email subject' email_1@domain.com email_2@domain.com |
Code:
#!/usr/bin/env bash | |
# | |
# find the directory your script lives in | |
# | |
| |
foo= `dirname $0` | |
echo $foo |
¥