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
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:
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) |
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 |
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 of all, I created a CCK content named "bookmark". Here is the exported CCK code.
Download Bookmark CCK here
Yep, I copied this from the facebook "SHARE IT" button.. :)
New theme for the under-development http://natouren.eu!
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:
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.
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 - |