diff options
author | Nick White <git@njw.me.uk> | 2010-08-07 12:45:13 +0100 |
---|---|---|
committer | Nick White <git@njw.me.uk> | 2010-08-07 12:45:13 +0100 |
commit | 6f116ca59eef1fac8e16535cce3fad6c3b63ff69 (patch) | |
tree | 727f07944d9a974665a4a95021045e7acfc86225 /scripts | |
parent | 4a43cd79f1cd901f7988260b1872d1d306f2a848 (diff) | |
download | njw-website-6f116ca59eef1fac8e16535cce3fad6c3b63ff69.tar.bz2 njw-website-6f116ca59eef1fac8e16535cce3fad6c3b63ff69.zip |
Reorganise software section
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/encrypt-if-possible.sh | 26 | ||||
-rw-r--r-- | scripts/fetchdnow.sh | 93 | ||||
-rw-r--r-- | scripts/filenonpersonalmail.rc | 21 | ||||
-rw-r--r-- | scripts/gatherflaggedmail.sh | 32 | ||||
-rw-r--r-- | scripts/getlwn.py | 63 | ||||
-rw-r--r-- | scripts/index.txt | 82 | ||||
-rw-r--r-- | scripts/remove-links.js | 31 |
7 files changed, 0 insertions, 348 deletions
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 <http://www.gnu.org/licenses/> 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 <http://www.gnu.org/licenses/> 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 <http://www.gnu.org/licenses/> 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 "<sync-mailbox><shell-escape>gatherflaggedmail.sh\n -# <change-folder>=flagged<enter>" "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 <http://www.gnu.org/licenses/> 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<n.childNodes.length; i++){ - n.parentNode.insertBefore(n.childNodes[i].cloneNode(true),n); - } - } - n.parentNode.removeChild(n); -} - -var a = document.getElementsByTagName("A"); -while (a.length > 0) { - removeNode(a[a.length-1]); -} |