Grabbing a whole site using wget

Recently, I needed an off-line copy of some documentation, available only as web pages. That's how I managed to clone entire parts of websites using wget.

First of all, the whole command I used:

wget -U "Mozilla/5.0 (X11; U; Linux; en-US; rv:1.9.1.16) Gecko/20110929 Firefox/3.5.16" \
--recursive --level=1 --no-clobber --page-requisites --html-extension \
--convert-links --no-parent \
--wait=3 --random-wait \
http://www.example.com/docs/interesting-part/ --domains=www.example.com

Basic arguments

Automatically build Sphinx documentation

sphinx-logo.png

This is a short bash script I wrote in order to automatically build the HTML version of some documentation using the Sphinx documentation system upon change of any file inside the documentation directory.

The script should be placed inside the documentation directory (the same containing the Sphinx Makefile, etc).
Its behavior is quite straight-forward; what it does is:

  1. Retrieve the directory containing the script, and use as $WORKDIR
  2. Wait for a modify|create|delete event on the $WORKDIR

99 Bottles of beer

Beer bottles on the wall

Do you know the popular programming challenge of generating the lyrics of the 99 Bottles of beer song using the shortest code possible?
There's even a websites that collects these scripts in many different languages: http://www.99-bottles-of-beer.net/.

I took the challenge..
..and here it is my solution, in just 237 bytes of Python code! :)

1
w=lambda c,d:'%s bottle%s of beer on the wall%s\n'%(c or'No','s'[:c!=1],d)

awstatic.sh - Generate static awstats reports

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
 
# samu 2010-02-23
 
STATIC_DEST="/var/www/awstats/static"
 
cat > "$STATIC_DEST/index.html" << EOF
<html><head><title>AWSTATS - Static</title></head><body>
<h1>AWSTATS - Static Statistics</h1>
<ul>
EOF
 
for conf in $( ls /etc/awstats/ | grep "^awstats\..*\.conf\$" | sed "s/^awstats\.\(.*\).conf\$/\1/" ); do
  echo "Generating static pages for $conf ..."
  if [ ! -e "${STATIC_DEST}/${conf}" ]; then
    mkdir -p "${STATIC_DEST}/${conf}"
  fi

Link sharer on Drupal

I just wanted something like the "share on facebook" button, but to post links on my (this) blog. I thought I would have to write a module to do that but.. no, Drupal itself allows us to do that directly :)

First, the CCK "Bookmark" Content

First of all, I created a CCK content named "bookmark". Here is the exported CCK code.
Download Bookmark CCK here

Second: the "bookmark" button

Yep, I copied this from the facebook "SHARE IT" button.. :)

Natouren New Theme

New theme for the under-development http://natouren.eu!

Convert FLV video to MP3 audio

mp3" title="" />

Many times we download a song we like from YouTube, or other sites, as a FLV video. But how to convert it to a regulare audio-only MP3 file? Here is a nice solution I found on the net, using FFMPEG.

The syntax of the command is:

ffmpeg [[infile options][-i infile]]... {[outfile options] outfile}

So, to convert a flv video to mp3, we could use something like:

PowerAdmin for drupal - now on Drupal.org

PowerDNS

I'm proud to announce that the Drupal administration module for PowerDNS I was writing is now available on Drupal.org at the address http://drupal.org/project/poweradmin.

Register APT repository key

Here is an useful script to register APT keys, to avoid the "There are no public key available for the following key IDs" warning message.

1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/bash
 
# samu 2010-01-01
# (c) 2010 Samuele ~redShadow~ Santi
# redshadow&hackzine.org - http://www.hackzine.org
# Under Gnu GPL v3
 
KEYID="$1"
 
echo "Registering APT key $1..."
gpg --keyserver wwwkeys.eu.pgp.net --recv-keys "$KEYID"
gpg –export –armor "$KEYID" | apt-key add -

Happy new year!

HAPPY 2010!
Syndicate content

Who Am I?

~redShadow~ A.K.A. Samuele Santi is an Italian Open Source developer, currently working as a freelance developer, mainly in the web applications sector. Favourite programming languages: PHP and, of course, Python!

racing cars (2) jamendo (2) music (2) powerdns (2) Python (9) projects (6) documentation (3) blogroll (7) social network (3) gentoo (2) MySQL (3) 3d (3) Web Apps (3) address book (2) Drupal (21) bash (12) electronics (2) twitter (4) security (4) awstats (3) svg (2) games (2) PHP (2) development (11) ldap (7) scripts (9) rfc (2) sysadmin (7) backup (3) subversion (2) PostgreSQL (3) C++ (2) graphics (5) hackzine (3) utilities (8) blender (3) code (3) Linux (18) database (3) e-mail (2)