scripts

shell scripts
git clone git://git.bitsmanent.org/scripts
Log | Files | Refs | README

commit 087e16397f859fea6597c15ff2743c1b9e809b10
parent 7a7bb2a0c7aefcbf1c20a413b96e8b790db2a587
Author: clamiax <smoppy@gmail.com>
Date:   Thu, 19 Mar 2015 22:27:38 +0100

Remove a broken (and useless) script

Diffstat:
MREADME.md | 4----
Dvegask | 94-------------------------------------------------------------------------------
2 files changed, 0 insertions(+), 98 deletions(-)

diff --git a/README.md b/README.md @@ -58,10 +58,6 @@ spawncgi -------- Spawn the CGI daemon. -vegask ------- -Get vegan people from Wikipedia. Written for fun. - pronunciask ----------- Get pronunciations from forvo.com. Written for fun. diff --git a/vegask b/vegask @@ -1,94 +0,0 @@ -#!/bin/bash -# Get vegan people from Wikipedia. Written for fun. - -SOURCE="http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&titles=List_of_vegans" -GETTER="wget -t1 -qO -" -DB="/tmp/vegask.db" - -update() { - items=$($GETTER "$SOURCE" | grep -A2 '!scope=' |tr -d '[]\n' |sed 's/--/\n/g' |cut -d' ' -f3- |sed -e 's/{{\(sortname|\)\(.*\)}}/\2/g' -e 's/&amp;/\&/g' -e 's/&quot;/"/g') - - # clear the db - echo -n > "$DB" - - IFS=' - ' - for item in $items - do - country=$(echo $item |rev |cut -d'|' -f1 | rev) - occupation=$(echo $item |rev |cut -d'|' -f2 | rev) - fullname=$(echo $item |rev |cut -d'|' -f3- | rev) - - strip=$(echo $fullname |grep -c '|') - if [ $strip -eq 1 ]; then - fullname="$(echo $fullname |awk -F'|' '{print $1 $2}')" - fi - - echo "$fullname|$occupation|$country" >> "$DB" - done - unset IFS -} - -usage() { -echo -n "Usage: $0 [-hu1r] [-n <num>] [<pattern>] ... --u Update the people's database --n <num> Limit the output to <num> items --1 Pick only one item (alias for -n1) --r Randomize --h Show this helps -" - -exit 1 -} - -show() { - item="$@" - fullname="$(echo $item |cut -d'|' -f1)" - occupation="$(echo $item |cut -d'|' -f2)" - country="$(echo $item |cut -d'|' -f3)" - echo "$fullname, $occupation. ($country)" -} - -pick() { - n=$1 - r=$2 - - if [ $r -ne 0 ]; then - items="$(cat $DB |sort -R |head -$n)" - else - items="$(cat $DB |head -$n)" - fi - - for i in $(seq 1 $n) - do - show $(echo "$items" |tail -$i) - done -} - -main() { - UPDATE=0 - LIMIT=0 - RANDOMIZE=0 - - while getopts "hur1n:" opt; do - case $opt in - h) usage;; - u) UPDATE=1;; - n) LIMIT=$OPTARG;; - 1) LIMIT=1;; - r) RANDOMIZE=1;; - esac - done - - if [ ! -f "$DB" ]; then - update - UPDATE=0 - fi - - [ "$UPDATE" -eq 1 ] && update - [ "$LIMIT" -eq 0 ] && usage && exit - pick $LIMIT $RANDOMIZE -} - - -main "$@"