From 6f116ca59eef1fac8e16535cce3fad6c3b63ff69 Mon Sep 17 00:00:00 2001 From: Nick White Date: Sat, 7 Aug 2010 12:45:13 +0100 Subject: Reorganise software section --- index.txt | 2 +- scripts/encrypt-if-possible.sh | 26 --------- scripts/fetchdnow.sh | 93 --------------------------------- scripts/filenonpersonalmail.rc | 21 -------- scripts/gatherflaggedmail.sh | 32 ------------ scripts/getlwn.py | 63 ---------------------- scripts/index.txt | 82 ----------------------------- scripts/remove-links.js | 31 ----------- software.txt | 48 ----------------- software/index.txt | 50 ++++++++++++++++++ software/scripts/encrypt-if-possible.sh | 26 +++++++++ software/scripts/fetchdnow.sh | 93 +++++++++++++++++++++++++++++++++ software/scripts/filenonpersonalmail.rc | 21 ++++++++ software/scripts/gatherflaggedmail.sh | 32 ++++++++++++ software/scripts/getlwn.py | 63 ++++++++++++++++++++++ software/scripts/index.txt | 82 +++++++++++++++++++++++++++++ software/scripts/remove-links.js | 31 +++++++++++ 17 files changed, 399 insertions(+), 397 deletions(-) delete mode 100644 scripts/encrypt-if-possible.sh delete mode 100644 scripts/fetchdnow.sh delete mode 100644 scripts/filenonpersonalmail.rc delete mode 100644 scripts/gatherflaggedmail.sh delete mode 100644 scripts/getlwn.py delete mode 100644 scripts/index.txt delete mode 100644 scripts/remove-links.js delete mode 100644 software.txt create mode 100644 software/index.txt create mode 100644 software/scripts/encrypt-if-possible.sh create mode 100644 software/scripts/fetchdnow.sh create mode 100644 software/scripts/filenonpersonalmail.rc create mode 100644 software/scripts/gatherflaggedmail.sh create mode 100644 software/scripts/getlwn.py create mode 100644 software/scripts/index.txt create mode 100644 software/scripts/remove-links.js diff --git a/index.txt b/index.txt index 0525c0b..e728e8b 100644 --- a/index.txt +++ b/index.txt @@ -1,7 +1,7 @@ Nick J. White (njw) ======================================================================= -[Software](software) +[Software](software/) ----------------------------------------------------------------------- More information about the free software projects I have been and am involved with. diff --git a/scripts/encrypt-if-possible.sh b/scripts/encrypt-if-possible.sh deleted file mode 100644 index 36e15cb..0000000 --- a/scripts/encrypt-if-possible.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -# Copyright 2009 Nick White -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# See for a copy of the GNU General -# Public License. -# -# This script creates a list of commands for mutt, to autoencrypt -# every email for which we have a key -# -# To use this in mutt, add the following to your ~/.muttrc: -# source encrypt-if-possible.sh| - -gpg --list-keys | sed \ - -e '/@/!d' \ - -e 's/\(.*\)<\(.*\)>/\2/g' \ - -e 's/\(.*\)/send-hook \1 "set crypt_autoencrypt = yes"/g' diff --git a/scripts/fetchdnow.sh b/scripts/fetchdnow.sh deleted file mode 100644 index 990a2dc..0000000 --- a/scripts/fetchdnow.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash -# Copyright 2008 Nick White -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# See for a copy of the GNU General -# Public License. - -function usage -{ - echo "Usage: dnow [-c codec] [-f outfile]" - echo " codec may be ogg, flac or mp3" -} - -# Get Dates # -year=$(date +%Y) -month=$(date +%m) -monthname=$(date +%B) -day=$(date +%d) -dayunpadded=$(date +%-e) - -# Set Defaults # -title="Democracy Now!" -titleshort="Democracy_Now" -codec="ogg" -podcastdir=~/feeds - -while [ "$1" != "" ]; do - case $1 in - -c | --codec ) shift - codec=$1 - ;; - -f | --file ) shift - outfile=$1 - ;; - -h | --help ) usage - exit - ;; - * ) usage - exit - ;; - esac - shift -done - -downfile=dn$year-$month$day-1.$codec - -url=http://www.archive.org/download/dn$year-$month$day/$downfile - -downdir=$podcastdir/$year-$month-$dayunpadded - -# if the file already exists, exit -if [ -f "$downdir/$downfile" ]; then - echo "download file already exists" - exit 1 -fi - -echo "url is $url" - -mkdir -p "$downdir" -wget --quiet --directory-prefix="$downdir" $url - -# check that it's audio data, not a 404, & if necessary delete -if [ -f "$downdir/404.php" ]; then - find "$downdir" -iname "404.php*" -type f -exec rm -f {} \; - echo "404, sorry" - exit 1 -elif [ -z "$(file $downdir/$downfile|grep audio)" ]; then - rm "$downdir/$downfile" - echo "download wasn't audio" - exit 1 -fi - -# tag the newly downloaded file -vorbiscomment -w "$downdir/$downfile" -t "ARTIST=$title" -t "TITLE=$day $monthname $year" -t "GENRE=News" -t "DATE=$year" - -# create directories and links to integrate with GoldenPod's directory structure -catdir=$podcastdir/catalogue/$titleshort - -mkdir -p "$catdir" - -ln -s "$downdir/$downfile" "$podcastdir/catalogue/All/" -ln -s $downdir/$downfile "$catdir/" -ln -sf $downdir/$downfile "$catdir/latest.$codec" -ln -sfn $downdir "$podcastdir/latest" diff --git a/scripts/filenonpersonalmail.rc b/scripts/filenonpersonalmail.rc deleted file mode 100644 index a446177..0000000 --- a/scripts/filenonpersonalmail.rc +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2009 Nick White -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -ALIASFILE=$HOME/.mutt/aliases/personal - -:0 -* ^FROM* -* ? test -s $ALIASFILE -* ! ? grep -qi $(formail -x "From:"| cut -d '<' -f 2- | cut -d '>' -f 1) $ALIASFILE -impersonal/ diff --git a/scripts/gatherflaggedmail.sh b/scripts/gatherflaggedmail.sh deleted file mode 100644 index 4333ee5..0000000 --- a/scripts/gatherflaggedmail.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# Copyright 2009 Nick White -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# See for a copy of the GNU General -# Public License. -# -# To use this in mutt, add something like the following to your ~/.muttrc: -# macro index \eF "gatherflaggedmail.sh\n -# =flagged" "Gather flagged mail" - -MAILDIR=$HOME/.mail -FLAGGEDDIR=$MAILDIR/flagged - -# exclude transitory directories -searchpaths=$(ls $MAILDIR|sed -e '/search/d'|sed -e '/flagged/d') - -# clear old directory -rm -f $FLAGGEDDIR/cur/* - -for path in $searchpaths; do - find "$MAILDIR/$path" -regex '.*,*F[^\,]+*$' -exec ln -sf {} "$FLAGGEDDIR/cur" \; -done diff --git a/scripts/getlwn.py b/scripts/getlwn.py deleted file mode 100644 index 0cfde2e..0000000 --- a/scripts/getlwn.py +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/python2 -# Copyright 2009 Nick White -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# See for a copy of the GNU General -# Public License. - -import urllib2 -from cookielib import CookieJar -from urllib import urlencode -from optparse import OptionParser -from os import getenv - -# defaults -username = '' -password = '' -filename = 'lwn.html' -login_url = 'https://lwn.net/login' -bigpage_url = 'https://lwn.net/current/bigpage?format=printable' - -# parse arguments -parser = OptionParser() -parser.add_option("-u", "--user", dest="username", default=username, - help="lwn username") -parser.add_option("-p", "--pass", dest="password", default=password, - help="lwn password") -parser.add_option("-f", "--file", dest="filename", default=filename, - help="name of file to save to", metavar="FILE") -parser.add_option("-d", "--direct", dest="direct", default=False, - help="connect directly, bypassing any proxies", - action="store_true") -(options, args) = parser.parse_args() - -# set up cookiejar to use -credentials=urlencode({'Username': options.username, 'Password': options.password}) -cookiejar = CookieJar() -cookie_handler = urllib2.HTTPCookieProcessor(cookiejar) - -# set up proxy -proxyaddr = getenv('HTTP_PROXY') -if options.direct == True or not proxyaddr: - opener = urllib2.build_opener(cookie_handler) -else: - proxy_handler = urllib2.ProxyHandler({'http': proxyaddr, 'https': proxyaddr}) - opener = urllib2.build_opener(proxy_handler, cookie_handler) - -# login, then retrieve page -opener.open(login_url, credentials) -f = opener.open(bigpage_url) - -# save to a file -savefile = open(options.filename, 'w') -savefile.write(f.read()) -savefile.close diff --git a/scripts/index.txt b/scripts/index.txt deleted file mode 100644 index 93a53cf..0000000 --- a/scripts/index.txt +++ /dev/null @@ -1,82 +0,0 @@ -Scripts -======================================================================= - -"Spending 2 hours to accomplish in 2 seconds what could otherwise be -done in 2 minutes." - - -## [Readability simple](http://git.njw.me.uk/cgit/cgit.cgi/readability-simple/) and [remove links](remove-links.js) - -"The ever-present awareness of possibility to either make or refuse -choice, was to preempt my creating any meditative space for myself" - - *Sean Birketts, The Gutenberg Elegies*. - -[Readability](http://code.google.com/p/arc90labs-readability/) is a -program which decides which parts of a web page make up the core text, -and rewrites the page to remove anything else. Unfortunately it was -designed as a 'bookmarklet,' meaning that one must rely on external -servers for its operation, with the speed, connectivity and privacy -implications which that entails. I lightly reworked the code to remove -some unnecessary functionality and ensure it can be easily used -locally. - -I also created a simple companion script which removes all links from a -page. I currently use these in [uzbl](http://www.uzbl.org), with the -command: `chain 'script @scripts_dir/readability/js/readability.js' -'script @scripts_dir/remove-links.js'` - -[Democracy Now! fetcher](fetchdnow.sh) ------------------------------------------------------------------------ - -The wonderful news programme -[Democracy Now!](http://www.democracynow.org) provide FLAC, Ogg Vorbis -and MP3 files of all of their episodes, but only a RSS feed for the -MP3s. This script downloads the latest episode, in FLAC, Ogg Vorbis -or MP3 format. I use this from a cron job to automatically fetch new -episodes in my prefered format. - -[LWN fetcher](getlwn.py) ------------------------------------------------------------------------ - -The online publication [LWN](http://lwn.net/) provides excellent news -on free software each week. However to access the latest issue one -needs to log in to a subscriber account. This script just automates -the login and download of the latest issue. - -[Encrypt email if possible](encrypt-if-possible.sh) ------------------------------------------------------------------------ - -One feature I really wanted with the [mutt](http://www.mutt.org/) mail -reader was to automatically encrypt email to anyone I have an OpenPGP -public key for. This simple script accomplishes just that, and can be -easily included in any mutt configuration. - -[Gather flagged email](gatherflaggedmail.sh) ------------------------------------------------------------------------ - -I store my email in Maildir format, in a variety of folders, and read -it using the mutt mail reader. This setup worked well for me, except -that there was no way for me to easily see all flagged messages in any -folder. This script enables this, by creating a dynamic folder with -links to all flagged email. - -[File non-personal email](filenonpersonalmail.rc) ------------------------------------------------------------------------ - -I find it useful to keep personal email separate from everything else I -receive. This is a simple procmail rule which moves email from anyone -not in my personal -[alias](http://www.mutt.org/doc/manual/manual-3.html#ss3.2) -file into a different folder. This could be done more neatly with awk, -but it has always worked perfectly so I'm leaving it be. - -[osCommerce Easy SEO URLs](http://addons.oscommerce.com/info/5901) ------------------------------------------------------------------------ - -osCommerce doesn't have a robust plugin system, so it's particularly -important to me that any modifications I make to osCommerce -installations are as simple and maintainable as possible. I found this -contribution to rewrite urls, which nearly did what I needed. I fixed -some serious bugs, added a few little features, and generally made it -a little more robust. I am currently maintaining the releases, and -(time-permitting) handling bug and feature requests. diff --git a/scripts/remove-links.js b/scripts/remove-links.js deleted file mode 100644 index 1defd2b..0000000 --- a/scripts/remove-links.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2009 Nick White - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Use something like the following to use this in uzbl: - * script @scripts_dir/remove-links.js */ - -function removeNode(n){ - if(n.hasChildNodes()){ - for (var i=0; i 0) { - removeNode(a[a.length-1]); -} diff --git a/software.txt b/software.txt deleted file mode 100644 index 24cd556..0000000 --- a/software.txt +++ /dev/null @@ -1,48 +0,0 @@ -Software -======================================================================= - -I am very supportive of -[software freedom](http://www.gnu.org/philosophy/free-sw.html) - -ensuring everyone has freedom and control of their own computing. -One of the ways I support this goal is by working on free software, -some of which may be found in my -[public git repositories](http://git.njw.me.uk). - -[Gentoo](http://www.gentoo.org) ------------------------------------------------------------------------ - -An operating system based on either Linux or FreeBSD that can be -automatically optimized and customized for just about any application -or need. - -My distribution of choice, within which -[I am active](http://bugs.gentoo.org/buglist.cgi?email1=gentoo-bugs%40njw.me.uk&emailassigned_to1=1&emailreporter1=1&emailcc1=1&emailtype1=substring) -in reporting and fixing bugs. I wrote the ebuild for the -[icecat](http://www.gnu.org/software/gnuzilla/) package and modified -the kernel eclass to enable automatic deblobbing with -[linux libre](http://www.fsfla.org/svnwiki/selibre/linux-libre/). -I also maintain a -[personal overlay](http://git.njw.me.uk/cgit/cgit.cgi/njw-gentoo-local/) -of some ebuilds I've built for it. - -[GemRB](http://www.sourceforge.net/projects/gemrb) ------------------------------------------------------------------------ - -A reimplementation of the Infinity Engine, as used in games such as -Baldurs Gate and Planescape: Torment. - -I contribute the odd patch to this, as well as maintaining the -[gemrb game installers](http://git.njw.me.uk/cgit/cgit.cgi/gemrb-gameinstallers/) -and writing the official Gentoo ebuild. - -[GetHT](http://www.nongnu.org/getht) ------------------------------------------------------------------------ - -An application for GNU/Linux to download the PDF editions of -[Hinduism Today](http://www.hinduismtoday.com). - -[Scripts](scripts/) ------------------------------------------------------------------------ - -A collection of small scripts and related miscellany which others may -find useful. diff --git a/software/index.txt b/software/index.txt new file mode 100644 index 0000000..f4e6b92 --- /dev/null +++ b/software/index.txt @@ -0,0 +1,50 @@ +Software +======================================================================= + +I am very supportive of +[software freedom](http://www.gnu.org/philosophy/free-sw.html); +ensuring everyone has freedom and control of their own computing, by +protecting the right to freely use, study, modify and share programs. +One of the ways I support this goal is by working on free software, +some of which may be found in my +[public git repositories](http://git.njw.me.uk). + +I strongly reject 'open source,' a term which was created to +undermine the importance of freedom and collective welfare, and +recast free software as nothing more than an efficient mode of +production and profit. + +[Gentoo](http://www.gentoo.org) +----------------------------------------------------------------------- + +A unix-like operating system that can be automatically optimized and +customized for a variety of different applications or needs. + +My distribution of choice, within which +[I am active](http://bugs.gentoo.org/buglist.cgi?email1=gentoo-bugs%40njw.me.uk&emailassigned_to1=1&emailreporter1=1&emailcc1=1&emailtype1=substring) +in reporting and fixing bugs. I wrote the ebuild for the +[icecat](http://www.gnu.org/software/gnuzilla/) package and modified +the kernel eclass to enable automatic deblobbing with +[linux libre](http://www.fsfla.org/svnwiki/selibre/linux-libre/). +I also maintain a +[personal overlay](http://git.njw.me.uk/cgit/cgit.cgi/njw-gentoo-local/) +of some ebuilds I've built for it. + +[GetHT](http://www.nongnu.org/getht) +----------------------------------------------------------------------- + +An application for GNU/Linux to download the PDF editions of +[Hinduism Today](http://www.hinduismtoday.com). + +[GemRB game installers](http://git.njw.me.uk/cgit/cgit.cgi/gemrb-gameinstallers/) +--------------------------------------------------------------------------------- + +A set of scripts to install the games supported by +[GemRB](http://www.sourceforge.net/projects/gemrb), a reimplementation +of the Infinity engine. + +[Scripts](scripts/) +----------------------------------------------------------------------- + +A collection of small scripts and related miscellany which others may +find useful. diff --git a/software/scripts/encrypt-if-possible.sh b/software/scripts/encrypt-if-possible.sh new file mode 100644 index 0000000..36e15cb --- /dev/null +++ b/software/scripts/encrypt-if-possible.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# Copyright 2009 Nick White +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# See for a copy of the GNU General +# Public License. +# +# This script creates a list of commands for mutt, to autoencrypt +# every email for which we have a key +# +# To use this in mutt, add the following to your ~/.muttrc: +# source encrypt-if-possible.sh| + +gpg --list-keys | sed \ + -e '/@/!d' \ + -e 's/\(.*\)<\(.*\)>/\2/g' \ + -e 's/\(.*\)/send-hook \1 "set crypt_autoencrypt = yes"/g' diff --git a/software/scripts/fetchdnow.sh b/software/scripts/fetchdnow.sh new file mode 100644 index 0000000..990a2dc --- /dev/null +++ b/software/scripts/fetchdnow.sh @@ -0,0 +1,93 @@ +#!/bin/bash +# Copyright 2008 Nick White +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# See for a copy of the GNU General +# Public License. + +function usage +{ + echo "Usage: dnow [-c codec] [-f outfile]" + echo " codec may be ogg, flac or mp3" +} + +# Get Dates # +year=$(date +%Y) +month=$(date +%m) +monthname=$(date +%B) +day=$(date +%d) +dayunpadded=$(date +%-e) + +# Set Defaults # +title="Democracy Now!" +titleshort="Democracy_Now" +codec="ogg" +podcastdir=~/feeds + +while [ "$1" != "" ]; do + case $1 in + -c | --codec ) shift + codec=$1 + ;; + -f | --file ) shift + outfile=$1 + ;; + -h | --help ) usage + exit + ;; + * ) usage + exit + ;; + esac + shift +done + +downfile=dn$year-$month$day-1.$codec + +url=http://www.archive.org/download/dn$year-$month$day/$downfile + +downdir=$podcastdir/$year-$month-$dayunpadded + +# if the file already exists, exit +if [ -f "$downdir/$downfile" ]; then + echo "download file already exists" + exit 1 +fi + +echo "url is $url" + +mkdir -p "$downdir" +wget --quiet --directory-prefix="$downdir" $url + +# check that it's audio data, not a 404, & if necessary delete +if [ -f "$downdir/404.php" ]; then + find "$downdir" -iname "404.php*" -type f -exec rm -f {} \; + echo "404, sorry" + exit 1 +elif [ -z "$(file $downdir/$downfile|grep audio)" ]; then + rm "$downdir/$downfile" + echo "download wasn't audio" + exit 1 +fi + +# tag the newly downloaded file +vorbiscomment -w "$downdir/$downfile" -t "ARTIST=$title" -t "TITLE=$day $monthname $year" -t "GENRE=News" -t "DATE=$year" + +# create directories and links to integrate with GoldenPod's directory structure +catdir=$podcastdir/catalogue/$titleshort + +mkdir -p "$catdir" + +ln -s "$downdir/$downfile" "$podcastdir/catalogue/All/" +ln -s $downdir/$downfile "$catdir/" +ln -sf $downdir/$downfile "$catdir/latest.$codec" +ln -sfn $downdir "$podcastdir/latest" diff --git a/software/scripts/filenonpersonalmail.rc b/software/scripts/filenonpersonalmail.rc new file mode 100644 index 0000000..a446177 --- /dev/null +++ b/software/scripts/filenonpersonalmail.rc @@ -0,0 +1,21 @@ +# Copyright 2009 Nick White +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ALIASFILE=$HOME/.mutt/aliases/personal + +:0 +* ^FROM* +* ? test -s $ALIASFILE +* ! ? grep -qi $(formail -x "From:"| cut -d '<' -f 2- | cut -d '>' -f 1) $ALIASFILE +impersonal/ diff --git a/software/scripts/gatherflaggedmail.sh b/software/scripts/gatherflaggedmail.sh new file mode 100644 index 0000000..4333ee5 --- /dev/null +++ b/software/scripts/gatherflaggedmail.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Copyright 2009 Nick White +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# See for a copy of the GNU General +# Public License. +# +# To use this in mutt, add something like the following to your ~/.muttrc: +# macro index \eF "gatherflaggedmail.sh\n +# =flagged" "Gather flagged mail" + +MAILDIR=$HOME/.mail +FLAGGEDDIR=$MAILDIR/flagged + +# exclude transitory directories +searchpaths=$(ls $MAILDIR|sed -e '/search/d'|sed -e '/flagged/d') + +# clear old directory +rm -f $FLAGGEDDIR/cur/* + +for path in $searchpaths; do + find "$MAILDIR/$path" -regex '.*,*F[^\,]+*$' -exec ln -sf {} "$FLAGGEDDIR/cur" \; +done diff --git a/software/scripts/getlwn.py b/software/scripts/getlwn.py new file mode 100644 index 0000000..0cfde2e --- /dev/null +++ b/software/scripts/getlwn.py @@ -0,0 +1,63 @@ +#!/usr/bin/python2 +# Copyright 2009 Nick White +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# See for a copy of the GNU General +# Public License. + +import urllib2 +from cookielib import CookieJar +from urllib import urlencode +from optparse import OptionParser +from os import getenv + +# defaults +username = '' +password = '' +filename = 'lwn.html' +login_url = 'https://lwn.net/login' +bigpage_url = 'https://lwn.net/current/bigpage?format=printable' + +# parse arguments +parser = OptionParser() +parser.add_option("-u", "--user", dest="username", default=username, + help="lwn username") +parser.add_option("-p", "--pass", dest="password", default=password, + help="lwn password") +parser.add_option("-f", "--file", dest="filename", default=filename, + help="name of file to save to", metavar="FILE") +parser.add_option("-d", "--direct", dest="direct", default=False, + help="connect directly, bypassing any proxies", + action="store_true") +(options, args) = parser.parse_args() + +# set up cookiejar to use +credentials=urlencode({'Username': options.username, 'Password': options.password}) +cookiejar = CookieJar() +cookie_handler = urllib2.HTTPCookieProcessor(cookiejar) + +# set up proxy +proxyaddr = getenv('HTTP_PROXY') +if options.direct == True or not proxyaddr: + opener = urllib2.build_opener(cookie_handler) +else: + proxy_handler = urllib2.ProxyHandler({'http': proxyaddr, 'https': proxyaddr}) + opener = urllib2.build_opener(proxy_handler, cookie_handler) + +# login, then retrieve page +opener.open(login_url, credentials) +f = opener.open(bigpage_url) + +# save to a file +savefile = open(options.filename, 'w') +savefile.write(f.read()) +savefile.close diff --git a/software/scripts/index.txt b/software/scripts/index.txt new file mode 100644 index 0000000..93a53cf --- /dev/null +++ b/software/scripts/index.txt @@ -0,0 +1,82 @@ +Scripts +======================================================================= + +"Spending 2 hours to accomplish in 2 seconds what could otherwise be +done in 2 minutes." + + +## [Readability simple](http://git.njw.me.uk/cgit/cgit.cgi/readability-simple/) and [remove links](remove-links.js) + +"The ever-present awareness of possibility to either make or refuse +choice, was to preempt my creating any meditative space for myself" + - *Sean Birketts, The Gutenberg Elegies*. + +[Readability](http://code.google.com/p/arc90labs-readability/) is a +program which decides which parts of a web page make up the core text, +and rewrites the page to remove anything else. Unfortunately it was +designed as a 'bookmarklet,' meaning that one must rely on external +servers for its operation, with the speed, connectivity and privacy +implications which that entails. I lightly reworked the code to remove +some unnecessary functionality and ensure it can be easily used +locally. + +I also created a simple companion script which removes all links from a +page. I currently use these in [uzbl](http://www.uzbl.org), with the +command: `chain 'script @scripts_dir/readability/js/readability.js' +'script @scripts_dir/remove-links.js'` + +[Democracy Now! fetcher](fetchdnow.sh) +----------------------------------------------------------------------- + +The wonderful news programme +[Democracy Now!](http://www.democracynow.org) provide FLAC, Ogg Vorbis +and MP3 files of all of their episodes, but only a RSS feed for the +MP3s. This script downloads the latest episode, in FLAC, Ogg Vorbis +or MP3 format. I use this from a cron job to automatically fetch new +episodes in my prefered format. + +[LWN fetcher](getlwn.py) +----------------------------------------------------------------------- + +The online publication [LWN](http://lwn.net/) provides excellent news +on free software each week. However to access the latest issue one +needs to log in to a subscriber account. This script just automates +the login and download of the latest issue. + +[Encrypt email if possible](encrypt-if-possible.sh) +----------------------------------------------------------------------- + +One feature I really wanted with the [mutt](http://www.mutt.org/) mail +reader was to automatically encrypt email to anyone I have an OpenPGP +public key for. This simple script accomplishes just that, and can be +easily included in any mutt configuration. + +[Gather flagged email](gatherflaggedmail.sh) +----------------------------------------------------------------------- + +I store my email in Maildir format, in a variety of folders, and read +it using the mutt mail reader. This setup worked well for me, except +that there was no way for me to easily see all flagged messages in any +folder. This script enables this, by creating a dynamic folder with +links to all flagged email. + +[File non-personal email](filenonpersonalmail.rc) +----------------------------------------------------------------------- + +I find it useful to keep personal email separate from everything else I +receive. This is a simple procmail rule which moves email from anyone +not in my personal +[alias](http://www.mutt.org/doc/manual/manual-3.html#ss3.2) +file into a different folder. This could be done more neatly with awk, +but it has always worked perfectly so I'm leaving it be. + +[osCommerce Easy SEO URLs](http://addons.oscommerce.com/info/5901) +----------------------------------------------------------------------- + +osCommerce doesn't have a robust plugin system, so it's particularly +important to me that any modifications I make to osCommerce +installations are as simple and maintainable as possible. I found this +contribution to rewrite urls, which nearly did what I needed. I fixed +some serious bugs, added a few little features, and generally made it +a little more robust. I am currently maintaining the releases, and +(time-permitting) handling bug and feature requests. diff --git a/software/scripts/remove-links.js b/software/scripts/remove-links.js new file mode 100644 index 0000000..1defd2b --- /dev/null +++ b/software/scripts/remove-links.js @@ -0,0 +1,31 @@ +/* + * Copyright 2009 Nick White + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Use something like the following to use this in uzbl: + * script @scripts_dir/remove-links.js */ + +function removeNode(n){ + if(n.hasChildNodes()){ + for (var i=0; i 0) { + removeNode(a[a.length-1]); +} -- cgit v1.2.3