URI: 
       tmore scripts - scripts - random scripts
  HTML git clone git://parazyd.org/scripts.git
   DIR Log
   DIR Files
   DIR Refs
       ---
   DIR commit 05e11c89f3d75626468a745ab2716242c63f6f32
   DIR parent f0548ed927ef73a18ecab704c461bbaf1f91f77b
  HTML Author: parazyd <parazyd@dyne.org>
       Date:   Thu, 16 Jun 2016 14:03:30 +0200
       
       more scripts
       
       Diffstat:
         A colordump                           |      19 +++++++++++++++++++
         A epubtohtml.pl                       |      21 +++++++++++++++++++++
         A git-update-all                      |      20 ++++++++++++++++++++
         A mycosmos                            |      72 +++++++++++++++++++++++++++++++
         A topdf                               |      12 ++++++++++++
       
       5 files changed, 144 insertions(+), 0 deletions(-)
       ---
   DIR diff --git a/colordump b/colordump
       t@@ -0,0 +1,19 @@
       +#!/bin/bash
       +# Usage: colordump
       +# Dump 256 ansi colors to the terminal.
       +
       +printf "How each ANSI color is displayed on your terminal:\n\n"
       +
       +i=0
       +row=0
       +while [ $i -lt 255 ];
       +do
       +    newrow=$(expr $i / 10)
       +    test $newrow -ne $row && printf "\n"
       +    row=$newrow
       +    printf "\e[%dm %03d \e[0m" $i $i
       +    i=$(expr $i + 1)
       +done
       +
       +printf '\n\n     e.g., "\\e[41mTEXT\\e[0m" '
       +printf "\e[41m(for TEXT like this)\e[0m\n"
   DIR diff --git a/epubtohtml.pl b/epubtohtml.pl
       t@@ -0,0 +1,21 @@
       +#!/usr/bin/perl -w
       +
       +# General use: unzip your file, head over to the directory where the *.html
       +# files exist and just execute the script. You'll find a nice "Previous/Next
       +# Page" link at the bottom of each page
       +
       +use strict;
       +use 5.012;
       +use Cwd;
       +
       +my $dir = getcwd;
       +my $filenames;
       +my @filenames = glob "$dir/*.html";
       +
       +my $i = 0;
       +
       +for ($i = 0; $i < $#filenames; $i++) {
       +  open my $fh, '>>', $filenames[$i] or die "Cound not open $filenames[$i]: $!";
       +  print $fh "<a href=\"$filenames[$i-1]\">Previous Page</a> <a href=\"$filenames[$i+1]\">Next Page</a>";
       +  close $fh;
       +}
   DIR diff --git a/git-update-all b/git-update-all
       t@@ -0,0 +1,20 @@
       +#!/bin/sh
       +#
       +# parazyd - (c) wtfpl 2016
       +# update all git repos in current folder
       +
       +for i in *; do
       +        if test -d "$i/.git"; then
       +                cd "$i"
       +                echo "[$i] updating"
       +                git remote update
       +                git pull --rebase
       +                if test $? -eq 1; then
       +                        echo "[$i] backing out rebase, fix manually"
       +                        git rebase --abort
       +                fi
       +                cd - >/dev/null
       +        else
       +                echo "[$i] not a git repo" 1>&2
       +        fi
       +done
   DIR diff --git a/mycosmos b/mycosmos
       t@@ -0,0 +1,72 @@
       +#!/bin/sh
       +
       +# send sms messages using the mail.mycosmos.gr service
       +# depends: curl
       +
       +if test -z "$4"
       +then
       +    echo usage: $0 user pass target message
       +    exit
       +fi
       +
       +USER=$1
       +PASS=$2
       +TARGET=$3
       +MESSAGE="$4"
       +
       +# should be 140 chars max
       +if test "$(echo -n $MESSAGE | wc -m)" -gt 140
       +then
       +    echo message too long
       +    exit
       +fi
       +
       +LOGINURL='http://mail.mycosmos.gr/mycosmos/login.aspx'
       +SENDURL='http://mail.mycosmos.gr/mycosmos/SMS_Send.aspx'
       +COOKIEJAR=$(mktemp)
       +
       +# visit login page
       +VIEWSTATE=$(curl --cookie-jar $COOKIEJAR $LOGINURL 2> /dev/null \
       +    | grep VIEWSTATE | sed 's/.*value="\(.*\)".*/\1/')
       +FRESH=$(grep mycosmos $COOKIEJAR \
       +    | awk '{print $6"="$7";"}' | tr '\n' ' ' | sed 's/; $//')
       +COOKIES=$FRESH
       +
       +# do login
       +curl --cookie-jar $COOKIEJAR \
       +    --cookie "$COOKIES" \
       +    --form "__VIEWSTATE=$VIEWSTATE" \
       +    --form "tbUsername=$USER" \
       +    --form "tbPassword=$PASS" \
       +    --form "btLogin=Log On" \
       +    --silent $LOGINURL > /dev/null
       +
       +FRESH=$(grep mycosmos $COOKIEJAR \
       +    | awk '{print $6"="$7";"}' | tr '\n' ' ' | sed 's/; $//')
       +COOKIES="$COOKIES; $FRESH"
       +
       +# clear cookies
       +rm $COOKIEJAR
       +
       +# visit send page
       +VIEWSTATE=$(curl --cookie "$COOKIES" $SENDURL 2> /dev/null \
       +    | grep VIEWSTATE | sed 's/.*value="\(.*\)".*/\1/')
       +
       +# send text message
       +STAT=$(curl --cookie "$COOKIES" \
       +    --form "__VIEWSTATE=$VIEWSTATE" \
       +    --form "txtMobile=$TARGET" \
       +    --form "txtMessage=$MESSAGE" \
       +    --form "btnSend=Send" \
       +    --silent $SENDURL)
       +
       +# report status
       +if test "$(echo $STAT | grep 'Success=True')"
       +    then SENT=yes
       +    else SENT=no
       +fi
       +if test "$(echo $STAT | grep 'LimitReached=false')"
       +    then LAST=no
       +    else LAST=yes
       +fi
       +echo "sent=$SENT last=$LAST"
   DIR diff --git a/topdf b/topdf
       t@@ -0,0 +1,12 @@
       +#!/bin/sh
       +#
       +# parazyd - (c) wtfpl 2016
       +# convert documents to pdf using the doc2pdf.net service
       +
       +if test -z "$1"; then
       +    echo usage: $(basename $0) document && exit 1
       +fi
       +
       +SRV=http://www.doc2pdf.net/convert/document.pdf
       +
       +curl -F "inputDocument=@$1" $SRV > "${1%.*}.pdf"