tSome updates. - scripts - random scripts
git clone https://git.parazyd.org/scripts
Log
Files
Refs
---
commit 933852ecce46bffbae79861a41c6213a2440105e
parent af0786393d19457ffe414f3f3c75315c723c96d3
Author: parazyd 
Date:   Mon, 11 May 2020 23:16:29 +0200

Some updates.

Diffstat:
  M autoup                              |       6 +++++-
  M chandl                              |      10 +++++++++-
  M ff                                  |       9 +++++++--
  A mladmin                             |      33 +++++++++++++++++++++++++++++++
  M radio                               |      71 ++++++++++++++-----------------
  M takeoffdir                          |       4 ++--
  A torrentwatch                        |       6 ++++++
  M update-gits                         |      23 ++++++++++++++++++++---
  D vipe                                |      74 -------------------------------
  M xkcd                                |      35 ++++++++++++++-----------------

10 files changed, 131 insertions(+), 140 deletions(-)
---
diff --git a/autoup b/autoup
t@@ -16,6 +16,10 @@ case "$1" in
         shift
         webdir=tmp/photo
         ;;
+-t)
+        shift
+        webdir=tmp
+        ;;
 esac
 
 
t@@ -25,7 +29,7 @@ filename=$(basename $1)
 case "$filename" in
 *_scrot.*|mpv-shot*.*)
         webdir=tmp/screenshots
-        num=$(echo $(lynx -dump https://$server/pub/tmp/screenshots \
+        num=$(echo $(lynx -dump http://$server/pub/tmp/screenshots \
                 | tail -n1 | tr -d '[a-z]./:' | awk '{print $2}') + 1 | bc)
         if [ "$num" -lt 100 ]; then
                 num="00$num"
diff --git a/chandl b/chandl
t@@ -1,7 +1,8 @@
 #!/bin/sh
 
 case "$1" in
-*boards.4chan.org*)
+*4chan.org*)
+        #imgs='is2.4chan.org'
         imgs='i.4cdn.org'
         ;;
 *8ch.net*)
t@@ -13,6 +14,12 @@ case "$1" in
 *arisuchan.jp*)
         imgs='.* https:\/\/arisuchan.jp\/.*/src\/'
         ;;
+*enrive.org*)
+        imgs='enrive.org\/media\/'
+        ;;
+*endchan.xyz*)
+        imgs='endchan.xyz\/\.media\/'
+        ;;
 *)
         echo 'Unsupported URL.'
         exit 1
t@@ -20,4 +27,5 @@ case "$1" in
 esac
 
 lynx -dump "$1" | awk '/^References/,EOF' | awk '/'"$imgs"'/ {print $2}' |
+        grep -v player | 
         sort | uniq | while read foo ; do wget -c "$foo" ; done
diff --git a/ff b/ff
t@@ -1,4 +1,5 @@
 #!/bin/sh
+
 case "$(basename $0)" in
 cb)
         xhost si:localuser:ff && \
t@@ -6,7 +7,11 @@ cb)
         ;;
 
 ff)
-        xhost si:localuser:ff && \
-        exec sudo -u ff /usr/bin/firefox -no-remote -ProfileManager $@
+        xhost si:localuser:ff
+        if [ -z "$1" ]; then
+                exec sudo -u ff /usr/bin/firefox --ProfileManager
+        else
+                sudo -u ff /usr/bin/firefox $@
+        fi
         ;;
 esac
diff --git a/mladmin b/mladmin
t@@ -0,0 +1,33 @@
+#!/bin/sh
+
+mailman_url="https://mailinglists.dyne.org/cgi-bin/mailman/admin"
+
+listname="$1"
+
+if [ "$listname" = "" ]; then
+        echo "Usage: $(basename "$0") listname"
+        pass ls ml
+        exit 1
+fi
+
+pw="$(pass show ml/$listname)"
+tmp="$(mktemp)"
+
+cat < "$tmp"
+
+  
+    Mailman admin for $listname
+  
+  
+    

Go to mailman admin: $listname

+
+ + +
+ + +EOF + +surf "$tmp" + +(sleep 10; rm -f "$tmp") &
diff --git a/radio b/radio
t@@ -1,45 +1,40 @@
-#!/bin/sh
+#!/usr/bin/env python3
 
-usage() {
-    cat <
diff --git a/takeoffdir b/takeoffdir
t@@ -1,10 +1,10 @@
 #!/bin/sh
 
-TAKEOFF_DIR=/tmp/takeoff
+TAKEOFF_DIR=/home/parazyd/tors
 
 mkdir -p $TAKEOFF_DIR
 
 # file either created or modified
 wendy -m 136 -f $TAKEOFF_DIR -v | while read ev file; do
-    $HOME/bin/autoup "$file"
+    scp "$file" alderaan.parazyd.org:torrents/
 done
diff --git a/torrentwatch b/torrentwatch
t@@ -0,0 +1,6 @@
+#!/bin/sh
+
+TAKEOFFDIR="$HOME/tors"
+
+exec wendy -m 136 -w "$TAKEOFFDIR" \
+        sh -c 'scp -Bq "$WENDY_INODE" alderaan.parazyd.org:torrents/ && rm -f "$WENDY_INODE"'
diff --git a/update-gits b/update-gits
t@@ -1,12 +1,29 @@
 #!/bin/sh
 
-#[ -n "$TORIFY" ] && tor=torsocks
+if [ -n "$1" ]; then
+        cat </dev/null
         }
 done
diff --git a/vipe b/vipe
t@@ -1,74 +0,0 @@
-#!/usr/bin/perl
-
-=head1 NAME
-
-vipe - edit pipe
-
-=head1 SYNOPSIS
-
-command1 | vipe | command2
-
-=head1 DESCRIPTION
-
-vipe allows you to run your editor in the middle of a unix pipeline and
-edit the data that is being piped between programs. Your editor will
-have the full data being piped from command1 loaded into it, and when you
-close it, that data will be piped into command2.
-
-=head1 ENVIRONMENT VARIABLES
-
-=over 4
-
-=item EDITOR
-
-Editor to use.
-
-=item VISUAL
-
-Also supported to determine what editor to use.
-
-=back
-
-=head1 AUTHOR
-
-Copyright 2006 by Joey Hess 
-
-Licensed under the GNU GPL.
-
-=cut
-
-use warnings;
-use strict;
-use File::Temp q{tempfile};
-
-$/=undef;
-
-my ($fh, $tmp)=tempfile();
-die "cannot create tempfile" unless $fh;
-print ($fh ) || die "write temp: $!";
-close $fh;
-close STDIN;
-open(STDIN, "&STDOUT") || die "save stdout: $!";
-close STDOUT;
-open(STDOUT, ">/dev/tty") || die "reopen stdout: $!";
-
-my @editor="vi";
-if (-x "/usr/bin/editor") {
-        @editor="/usr/bin/editor";
-}
-if (exists $ENV{EDITOR}) {
-        @editor=split(' ', $ENV{EDITOR});
-}
-if (exists $ENV{VISUAL}) {
-        @editor=split(' ', $ENV{VISUAL});
-}
-my $ret=system(@editor, $tmp);
-if ($ret != 0) {
-        die "@editor exited nonzero, aborting\n";
-}
-
-open (IN, $tmp) || die "$0: cannot read $tmp: $!\n";
-print (OUT ) || die "write failure: $!";
-close IN;
-unlink($tmp);
diff --git a/xkcd b/xkcd
t@@ -2,31 +2,28 @@
 #
 # grab a random xkcd comic, append title and alttext, and save to a dir
 
+from os import environ
+from re import search
+from random import randrange
+
 from PIL import Image, ImageDraw, ImageFont
 from requests import get
-from random import randrange
-from textwrap import wrap
-from json import loads
-from re import search
-import os
 
-download_dir = os.environ['HOME']+'/xkcd/'
-title_fontsize = 28
-alt_fontsize = 18
-line_offset = 10
+DOWNLOAD_DIR = environ['HOME']+'/xkcd/'
+TITLE_FONTSIZE = 28
+ALT_FONTSIZE = 18
+LINE_OFFSET = 10
 
-def add_text(image, title, alt, tfont=download_dir+'xkcd.ttf',
-             afont=download_dir+'xkcd.ttf'):
+def add_text(image, title, alt, tfont=DOWNLOAD_DIR+'xkcd.ttf',
+             afont=DOWNLOAD_DIR+'xkcd.ttf'):
     try:
         img = Image.open(image)
     except OSError:
         return
 
-    tfont = ImageFont.truetype(tfont, title_fontsize)
-    afont = ImageFont.truetype(afont, alt_fontsize)
+    tfont = ImageFont.truetype(tfont, TITLE_FONTSIZE)
+    afont = ImageFont.truetype(afont, ALT_FONTSIZE)
 
-    twidth, theight = tfont.getsize(title)
-    awidth, aheight = afont.getsize(alt)
     line_padding = 5
     draw = ImageDraw.Draw(img)
     lines = text_wrap(tfont, title, img.size[0])
t@@ -65,8 +62,8 @@ def add_text(image, title, alt, tfont=download_dir+'xkcd.ttf',
 def text_wrap(font, text, image_width, i=0):
     lines = [[]]
     text = text.split(" ")
-    while len(text) > 0:
-        while len(text) > 0 \
+    while text:
+        while text \
             and font.getsize(" ".join(lines[i]))[0] < image_width:
             if font.getsize(text[0]+" "+" ".join(lines[i]))[0] > image_width * 0.95:
                 if len(lines[i]) == 0:
t@@ -107,13 +104,13 @@ def main():
 
     image = num+search("\.([a-z])+$", info['img']).group()
 
-    with open(download_dir+image, 'wb') as image_file:
+    with open(DOWNLOAD_DIR+image, 'wb') as image_file:
         req = get(info['img'], stream=True)
         for block in req.iter_content(1024):
             if block:
                 image_file.write(block)
                 image_file.flush()
         if not search("\.gif", info['img']):
-            add_text(download_dir+image, title, alt)
+            add_text(DOWNLOAD_DIR+image, title, alt)
 
 main()