From 227b7baff6fb0d417243450f19f6a3ad810ea06d Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 19 Jul 2011 16:42:05 +0200 Subject: util make-data-url: initial commit NAME make-data-url - create a "data" URL scheme item SYNOPSIS make-data-url [file...] DESCRIPTION The make-data-url is a best efforts generator of "data" URL scheme compatible items as described by RFC 2397. Each file is read, analyzed, and printed as single-lined "data" URL to stdout. OPERANDS The following operands shall be supported: file A pathname of a file. The content of each file is printed as single-lined "data" URL to the standard output. The mime-type of the file's content gets guessed by the file utility. STDIN None INPUT FILES Input files can be any file type. ENVIRONMENT VARIABLES The following environment variables shall affect the execution of make-data-url: None. ASYNCHRONOUS EVENTS Default. STDOUT Each line shall contain a "data" URL item for the respective file operand. STDERR The standard error shall be used only for diagnostic messages. OUTPUT FILES None. EXTENDED DESCRIPTION None. EXIT STATUS The following exit values shall be returned: 0 The program has terminated. CONSEQUENCES OF ERRORS Default. The following sections are informative APPLICATION USAGE Default. EXAMPLES Test your backup scheme: sudo rm -fR /home RATIONALE None. FUTURE DIRECTIONS None. SEE ALSO RFC 2397, file BUGS None, this is enterprise-grade software and behaves exactly as specified. AUTHOR KREBS COPYTIGHT Copytight (c) 2011, KREBS. This program is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See http://sam.zoy.org/wtfpl/COPYING for more details. COPYRIGHT Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology -- Portable Operatingg Systems Interface (POSIX), The Open Group Base Specification Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . Deal with it! --- util/bin/make-data-uri | 7 +++++++ util/bin/make-data-url | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100755 util/bin/make-data-uri create mode 100755 util/bin/make-data-url (limited to 'util/bin') diff --git a/util/bin/make-data-uri b/util/bin/make-data-uri new file mode 100755 index 00000000..a9d014e6 --- /dev/null +++ b/util/bin/make-data-uri @@ -0,0 +1,7 @@ +#! /bin/sh +set -euf +for path; do + type="`file -bi "$path"`" + data="`base64 -w 0 "$path"`" + echo "data:$type;base64,$data" +done diff --git a/util/bin/make-data-url b/util/bin/make-data-url new file mode 100755 index 00000000..a9d014e6 --- /dev/null +++ b/util/bin/make-data-url @@ -0,0 +1,7 @@ +#! /bin/sh +set -euf +for path; do + type="`file -bi "$path"`" + data="`base64 -w 0 "$path"`" + echo "data:$type;base64,$data" +done -- cgit v1.2.3 From 5f674950fa1aca10cc51f75bb4f9cb85d50584d1 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 20 Jul 2011 22:40:22 +0200 Subject: util krebsdate: initial commit --- util/bin/krebdate | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 util/bin/krebdate (limited to 'util/bin') diff --git a/util/bin/krebdate b/util/bin/krebdate new file mode 100755 index 00000000..b2aa02d2 --- /dev/null +++ b/util/bin/krebdate @@ -0,0 +1,10 @@ +#! /bin/sh +set -euf + +if test "${nosudo-false}" != true -a `id -u` != 0; then + echo "we're going sudo..." >&2 + exec sudo "$0" "$@" + exit 23 # go to hell +fi + +date --date="`ssh krebs 'date --rfc-3339=s'`" -- cgit v1.2.3 From bf07a6e361dd814d423de57d8129cac286417678 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 20 Jul 2011 22:49:15 +0200 Subject: util make-data-uri: rm legacy code --- util/bin/make-data-uri | 7 ------- 1 file changed, 7 deletions(-) delete mode 100755 util/bin/make-data-uri (limited to 'util/bin') diff --git a/util/bin/make-data-uri b/util/bin/make-data-uri deleted file mode 100755 index a9d014e6..00000000 --- a/util/bin/make-data-uri +++ /dev/null @@ -1,7 +0,0 @@ -#! /bin/sh -set -euf -for path; do - type="`file -bi "$path"`" - data="`base64 -w 0 "$path"`" - echo "data:$type;base64,$data" -done -- cgit v1.2.3 From 4711007535169368dbef79fa1d97919305ab88d4 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 22 Jul 2011 11:48:08 +0200 Subject: util google.suggest: initial import --- util/bin/google.suggest | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100755 util/bin/google.suggest (limited to 'util/bin') diff --git a/util/bin/google.suggest b/util/bin/google.suggest new file mode 100755 index 00000000..9bde17dc --- /dev/null +++ b/util/bin/google.suggest @@ -0,0 +1,8 @@ +#! /bin/sh + +uri="http://google.com/complete/search?output=json&q=$*" + +curl -sS "$uri" | sed -n ' + s:^window.google.ac.h(\|)$::gp +' +echo -- cgit v1.2.3 From 709d5fc73f00e58e98c6b97dfaa9d1ff31ee1441 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 24 Jul 2011 20:15:22 +0200 Subject: rm kvutils and move anonbox.net to proper place --- util/bin/anonbox.net | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 util/bin/anonbox.net (limited to 'util/bin') diff --git a/util/bin/anonbox.net b/util/bin/anonbox.net new file mode 100755 index 00000000..d038cd0a --- /dev/null +++ b/util/bin/anonbox.net @@ -0,0 +1,57 @@ +#! /bin/bash +#### anonbox.net [--check] +#### anonbox account creator +set -euf + +## +script_begin_date="`date --rfc-3339=ns`" + +## +GET() { + wget --quiet --no-check-certificate -O- https://anonbox.net/en/ +} + +## retrieve data +eval "$(${GET-GET} | + sed -rn ' +s^

([[:alnum:]@.]+)

$\ + email="\1" ; p +s^

.*

$\ + uri="\1/" ; p +s^

([0-9]+)/([0-9]+)/([0-9]+) ([0-9]+):([0-9]+) ([ap]).m.

$\ + Y=20\3 ; \ + m=\1 ; \ + d=\2 ; \ + H=\4 ; \ + M=\5 ; \ + p=\6 ; p')" + +## make best-before-date RFC-3339-(seconds)-conform +case "$p" in + p) H="`echo $H+12 | bc`" ;; +esac +s=00 +z=+02:00 +best_before="$Y-$m-$d $H:$M$z" + +## +script_end_date="`date --rfc-3339=ns`" + +## +for key in email uri best_before script_begin_date script_end_date ; do + eval "val=\"\$$key\"" + echo "$key=\"$val\"" +done + +## +if echo "$*" | tr "$IFS" ' ' | egrep -q "(^| )--check( |$)"; then + file="/tmp/save-$email" + echo "file=\"$file\"" + echo >&2 + echo "# downloading email..." >&2 + while ! curl -ksS "$uri" | tee "$file" | grep .; do + sleep 10 + done +fi + +#### end of file. -- cgit v1.2.3 From 19f48ebe9a90e4af6e0657d3368be031e051d456 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 30 Jul 2011 12:43:57 +0200 Subject: my-global-ipv4-addr: initial commit --- util/bin/my-global-ipv4-addr | 51 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 util/bin/my-global-ipv4-addr (limited to 'util/bin') diff --git a/util/bin/my-global-ipv4-addr b/util/bin/my-global-ipv4-addr new file mode 100755 index 00000000..305d3f80 --- /dev/null +++ b/util/bin/my-global-ipv4-addr @@ -0,0 +1,51 @@ +#! /bin/sh +# +# usage: my-global-ipv4-addr [URL] +# +# if URL is provided then fetch and parse it for IPv4 addrs +# else try all known urls +# +if test $# = 1; then + has() { type "$1" 1>/dev/null 2>/dev/null; } + parse() { + sed -rn 's/.*((1?[0-9][0-9]|2[0-5][0-9])\.(1?[0-9][0-9]|2[0-5][0-9])\.(1?[0-9][0-9]|2[0-5][0-9])\.(1?[0-9][0-9]|2[0-5][0-9])).*/\1/p' | grep . + } + get () { + # TODO get random valid user agent + if has curl; then + curl -m 1 -A Mozilla -sS "$1" 2>/dev/null + elif has wget; then + wget -T 1 -U Mozilla -O "$1" 2>/dev/null + else + echo 'Error 1: You are made of stupid!' >&2 + exit 23 + fi + } + + #addrs="`get "$1" | parse`" + #echo "$1:" $addrs >&2 + #echo "$addrs" + get "$1" | parse +else + + vote() { + sort | uniq -c | sort -r -n + } + winner() { + head -n 1 | awk '{print$2}' + } + + grep -v ^# | + sed -n '1,$p' | + xargs -P 42 -n 1 "$0" | vote | winner +fi< Date: Sun, 31 Jul 2011 01:17:28 +0200 Subject: randline: initial commit --- util/bin/randline | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 util/bin/randline (limited to 'util/bin') diff --git a/util/bin/randline b/util/bin/randline new file mode 100755 index 00000000..cd9476e7 --- /dev/null +++ b/util/bin/randline @@ -0,0 +1,12 @@ +#! /bin/sh +# +# choose a line randomly. +# +set -euf + +lines="`cat`" +count=`echo "$lines" | wc -l` +random=`od -An -t u8 -N 8 /dev/urandom` +choice=`echo "$random % $count + 1" | bc` + +echo "$lines" | sed -n "${choice}p" -- cgit v1.2.3 From 718fcb70fa813422496cb5322b5532d3f4f6df52 Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 31 Jul 2011 02:16:15 +0200 Subject: randline: reimplemented --- util/bin/randline | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'util/bin') diff --git a/util/bin/randline b/util/bin/randline index cd9476e7..75618664 100755 --- a/util/bin/randline +++ b/util/bin/randline @@ -1,12 +1,5 @@ #! /bin/sh -# -# choose a line randomly. -# -set -euf +# Author: tv,makefu +# Info: for old version see commit b9924 -lines="`cat`" -count=`echo "$lines" | wc -l` -random=`od -An -t u8 -N 8 /dev/urandom` -choice=`echo "$random % $count + 1" | bc` - -echo "$lines" | sed -n "${choice}p" +cat | shuf | head -n 1 -- cgit v1.2.3 From d0e5025b103f6e02500f2d9f48d4c3d0c5b2b084 Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 31 Jul 2011 02:16:15 +0200 Subject: randline: reimplemented --- util/bin/randline | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'util/bin') diff --git a/util/bin/randline b/util/bin/randline index cd9476e7..051734c5 100755 --- a/util/bin/randline +++ b/util/bin/randline @@ -1,12 +1,3 @@ #! /bin/sh -# -# choose a line randomly. -# -set -euf -lines="`cat`" -count=`echo "$lines" | wc -l` -random=`od -An -t u8 -N 8 /dev/urandom` -choice=`echo "$random % $count + 1" | bc` - -echo "$lines" | sed -n "${choice}p" +cat | shuf | head -n 1 -- cgit v1.2.3 From 604b6d64312a7ca711a3fdd1b5863984953e2fc8 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 31 Jul 2011 02:33:49 +0200 Subject: translate.google: initial commit --- util/bin/translate.google | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 util/bin/translate.google (limited to 'util/bin') diff --git a/util/bin/translate.google b/util/bin/translate.google new file mode 100755 index 00000000..50d37cc3 --- /dev/null +++ b/util/bin/translate.google @@ -0,0 +1,29 @@ +#! /bin/sh +set -euf + +A=Mozilla +url=http://translate.google.com/ + +{ + for arg; do echo "$arg"; done | sed -rn ' + s/^--(.*=.*)/\1/p;t + s/.*/text="${text+$text }&"/p;t + ' + cat< Date: Sun, 31 Jul 2011 02:36:09 +0200 Subject: translate.google: esnure query is ready --- util/bin/translate.google | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'util/bin') diff --git a/util/bin/translate.google b/util/bin/translate.google index 50d37cc3..56cd7ee0 100755 --- a/util/bin/translate.google +++ b/util/bin/translate.google @@ -4,6 +4,11 @@ set -euf A=Mozilla url=http://translate.google.com/ +pwd="$(dirname "$(readlink -f "$0")")" + +# ensure query is ready +(cd "$pwd/../.." && git submodule update --init) + { for arg; do echo "$arg"; done | sed -rn ' s/^--(.*=.*)/\1/p;t @@ -11,7 +16,7 @@ url=http://translate.google.com/ ' cat< Date: Sun, 31 Jul 2011 03:22:00 +0200 Subject: translate.google: add all the submodules --- util/bin/translate.google | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'util/bin') diff --git a/util/bin/translate.google b/util/bin/translate.google index 56cd7ee0..943675f4 100755 --- a/util/bin/translate.google +++ b/util/bin/translate.google @@ -6,6 +6,15 @@ url=http://translate.google.com/ pwd="$(dirname "$(readlink -f "$0")")" +for x in \ + "$pwd/../../submodules/github/tmpvar" \ + "$pwd/../../submodules/github/mikeal" \ + "$pwd/../../submodules/github/NV" \ + "$pwd/../../submodules/github/tautologistics" \ +; do + export NODE_PATH="`readlink -f "$x"`${NODE_PATH+:$NODE_PATH}" +done + # ensure query is ready (cd "$pwd/../.." && git submodule update --init) @@ -22,7 +31,6 @@ pwd="$(dirname "$(readlink -f "$0")")" -d "js=\${js-n}" \\ -d "prev=\${prev-_t}" \\ -d "hl=\${hl-en}" \\ - -d "ie=\${ie-UTF-8}" \\ -d "layout=\${layout-2}" \\ -d "eotf=\${eotf-1}" \\ -d "sl=\${sl-auto}" \\ -- cgit v1.2.3 From d42b585a1e8dfaf8184021a4664bbbe2b3fc10a9 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 31 Jul 2011 04:16:20 +0200 Subject: translate.google: fix encoding --- util/bin/translate.google | 2 ++ 1 file changed, 2 insertions(+) (limited to 'util/bin') diff --git a/util/bin/translate.google b/util/bin/translate.google index 943675f4..1a1be6b6 100755 --- a/util/bin/translate.google +++ b/util/bin/translate.google @@ -33,6 +33,8 @@ done -d "hl=\${hl-en}" \\ -d "layout=\${layout-2}" \\ -d "eotf=\${eotf-1}" \\ + -d "ie=UTF-8" \\ + -d "oe=UTF-8" \\ -d "sl=\${sl-auto}" \\ -d "tl=\${tl-en}" \\ -d "text=\$text" \\ -- cgit v1.2.3 From d82a176e310d8f8f1f686b8f8331204ba0b43510 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 5 Aug 2011 01:59:42 +0200 Subject: naturalvoices.att: initial commit --- util/bin/naturalvoices.att | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 util/bin/naturalvoices.att (limited to 'util/bin') diff --git a/util/bin/naturalvoices.att b/util/bin/naturalvoices.att new file mode 100755 index 00000000..e329694f --- /dev/null +++ b/util/bin/naturalvoices.att @@ -0,0 +1,40 @@ +#! /bin/sh +set -euf + +A=Mozilla +baseURL="http://192.20.225.36" +url="$baseURL/tts/cgi-bin/nph-talk" + +pwd="$(dirname "$(readlink -f "$0")")" + +for x in \ + "$pwd/../../submodules/github/tmpvar" \ + "$pwd/../../submodules/github/mikeal" \ + "$pwd/../../submodules/github/NV" \ + "$pwd/../../submodules/github/tautologistics" \ +; do + export NODE_PATH="`readlink -f "$x"`${NODE_PATH+:$NODE_PATH}" +done + +# ensure query is ready +(cd "$pwd/../.." && git submodule update --init) + +{ + for arg; do echo "$arg"; done | sed -rn ' + s/^--(.*=.*)/\1/p;t + s/.*/text="${text+$text }&"/p;t + ' + cat< Date: Fri, 5 Aug 2011 21:20:13 +0200 Subject: wiki.firstpar: initial commit of galileo --- util/bin/wiki.firstpar | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 util/bin/wiki.firstpar (limited to 'util/bin') diff --git a/util/bin/wiki.firstpar b/util/bin/wiki.firstpar new file mode 100755 index 00000000..df66f707 --- /dev/null +++ b/util/bin/wiki.firstpar @@ -0,0 +1,23 @@ +#! /bin/sh +set -euf + +A=Mozilla + +pwd="$(dirname "$(readlink -f "$0")")" + +for x in \ + "$pwd/../../submodules/github/tmpvar" \ + "$pwd/../../submodules/github/mikeal" \ + "$pwd/../../submodules/github/NV" \ + "$pwd/../../submodules/github/tautologistics" \ +; do + export NODE_PATH="`readlink -f "$x"`${NODE_PATH+:$NODE_PATH}" +done + +# ensure query is ready +#(cd "$pwd/../.." && git submodule update --init) + +query() { + node "$(readlink -f "$pwd/../../submodules/github/visionmedia/query")" "$@" +} +curl -sS -A "\${A-Mozilla}" "$1" | query 'p' 'first' | w3m -T text/html -dump -- cgit v1.2.3 From af257d3f13e66b15e3940b734a13156d8da61b11 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 5 Aug 2011 22:20:32 +0200 Subject: added galileo --- util/bin/galileo | 2 ++ util/bin/wiki.firstpar | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100755 util/bin/galileo (limited to 'util/bin') diff --git a/util/bin/galileo b/util/bin/galileo new file mode 100755 index 00000000..8ca7d834 --- /dev/null +++ b/util/bin/galileo @@ -0,0 +1,2 @@ +#!/bin/sh +./wiki.firstpar http://de.m.wikipedia.org/wiki/::Random | xargs ./naturalvoices.att diff --git a/util/bin/wiki.firstpar b/util/bin/wiki.firstpar index df66f707..d2181f1b 100755 --- a/util/bin/wiki.firstpar +++ b/util/bin/wiki.firstpar @@ -1,4 +1,4 @@ -#! /bin/sh +#! /bin/bash set -euf A=Mozilla @@ -15,9 +15,9 @@ for x in \ done # ensure query is ready -#(cd "$pwd/../.." && git submodule update --init) +(cd "$pwd/../.." && git submodule update --init) query() { node "$(readlink -f "$pwd/../../submodules/github/visionmedia/query")" "$@" } -curl -sS -A "\${A-Mozilla}" "$1" | query 'p' 'first' | w3m -T text/html -dump +curl -b redirect=seen -L -e http://de.wikipedia.org/wiki/$RANDOM -sS -A "\${A-Mozilla}" "$1" | query 'p' 'first' |w3m -T text/html -dump| cut -c -750 -- cgit v1.2.3 From 25236810321db809db0622adb4edaade4b69f7d0 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 5 Aug 2011 23:57:18 +0200 Subject: util wikipedia: from DNS --- util/bin/wikipedia | 5 +++++ 1 file changed, 5 insertions(+) create mode 100755 util/bin/wikipedia (limited to 'util/bin') diff --git a/util/bin/wikipedia b/util/bin/wikipedia new file mode 100755 index 00000000..cad0d8b1 --- /dev/null +++ b/util/bin/wikipedia @@ -0,0 +1,5 @@ +#! /bin/sh +set -euf +for w in "$@"; do + dig +short txt "$w.wp.dg.cx" +done -- cgit v1.2.3 From 971398ccbf7f2612193737dad2dfbd6873b5e6e5 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 6 Aug 2011 00:05:05 +0200 Subject: util naturalvoices: enable symlink calls --- util/bin/naturalvoices.att | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util/bin') diff --git a/util/bin/naturalvoices.att b/util/bin/naturalvoices.att index e329694f..656a2c5e 100755 --- a/util/bin/naturalvoices.att +++ b/util/bin/naturalvoices.att @@ -29,7 +29,7 @@ done node "$(readlink -f "$pwd/../../submodules/github/visionmedia/query")" "\$@" } curl -sS -A "\${A-Mozilla}" \\ - -d "voice=\${voice-klara}" \\ + -d "voice=\${voice-`basename "$0"`}" \\ -d "txt=\$text" \\ -d "downloadButton=DOWNLOAD" \\ "$url" | -- cgit v1.2.3 From c1fb8bcc96c83d27bdc32a2881969f88cc3ceb37 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 6 Aug 2011 00:14:09 +0200 Subject: util naturalvoices: enable symlink calls --- util/bin/naturalvoices.att | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'util/bin') diff --git a/util/bin/naturalvoices.att b/util/bin/naturalvoices.att index e329694f..7955db63 100755 --- a/util/bin/naturalvoices.att +++ b/util/bin/naturalvoices.att @@ -5,6 +5,10 @@ A=Mozilla baseURL="http://192.20.225.36" url="$baseURL/tts/cgi-bin/nph-talk" +if test -h "$0"; then + voice="${voice-"`basename "$0"`"}" +fi + pwd="$(dirname "$(readlink -f "$0")")" for x in \ -- cgit v1.2.3 From 08f27d02e568d028eba22726005924689f7d0de6 Mon Sep 17 00:00:00 2001 From: makefu Date: Sat, 6 Aug 2011 20:08:33 +0200 Subject: util/bin/galileo: compliance to changed tts-behavior --- util/bin/galileo | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'util/bin') diff --git a/util/bin/galileo b/util/bin/galileo index 8ca7d834..854f1302 100755 --- a/util/bin/galileo +++ b/util/bin/galileo @@ -1,2 +1,3 @@ #!/bin/sh -./wiki.firstpar http://de.m.wikipedia.org/wiki/::Random | xargs ./naturalvoices.att +export voice=klara +./wiki.firstpar http://de.m.wikipedia.org/wiki/::Random | xargs ./naturalvoices.att -- cgit v1.2.3