Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

export1 on 20110419-22:42:40

  • Loading branch information...
commit 1f5eeb52b8aa538665af8488234c5b8195b2a151 1 parent 65351d6
@jakobi authored
View
4 README.epl
@@ -1,4 +1,6 @@
-[# #]
+[#
+ see https://github.com/rtomayko/rdiscount/blob/master/man/markdown.7 for this markup implementation
+ #]
[-
$escmode=0;
-]
View
1  cli.HTML/COLLECT
@@ -584,6 +584,7 @@ firefox BOOK.html
# non-COLLECT version for chm / extracting chm: chm2pdf
# (also: cs2w/chm_http(extract), xchm/gnochm/chmsee/kchmviewer; generation is windows/prop only)
# firefox hates imagefile;ID img sources and strips ;ID on fs access - consider hardlinks
+chm2pdf --book x.chm
chm2pdf --continuous x.chm
chm2pdf --webpage --size=a4 x.chm # --extract-only
View
5 cli.HTML/LINKS
@@ -76,7 +76,10 @@ foreach(@files) {
# ugly hack: transform option value to bogus href's for reports later on;
# keeping linecount intact
- $lines=~s/(<option[^<>]+?value([^<>]+?)>)/do{$tmp1=$1; $tmp2=$2; $tmp2=~s@[\r\n\j]@ @go; "<a href$tmp2>VALUELINK $tmp1<\/a>"}/geoi if $values;
+ $lines=~s/(<option[^<>]+?value([^<>]+?)>)/do{
+ $tmp1=$1; $tmp2=$2; $tmp2=~s@[\r\n]@ @go;
+ "<a href$tmp2>VALUELINK $tmp1<\/a>"
+ }/geoi if $values;
# url translations
$lines=&db_cgi::changeurls($h0, $lines, $_, $rold, $mode) if ($root);
View
2  cli.HTML/sub.mime
@@ -162,7 +162,7 @@ sub unbase64 {
local($body)=@_;
my($len, $len1, $newbody, $tmp, $i);
$body=~tr#A-Za-z0-9+/##cd; # remove non-base64 chars incl. newlines
- $body=~tr#A-Za-z0-9+/# -_#; # convert to uuencoded format
+ $body=~tr#A-Za-z0-9+/# -_#; # convert b64 to uuencode form
$len1=length($body);
for($i=0;$i<=$len1;$i+=40) {
$tmp=substr($body,$i,40); # HACK I don't care now about the last (possibly incomplete) character...
View
2  cli.conf/dir.mc/ini
@@ -92,7 +92,7 @@ auto_save_setup_panels=1
[Layout]
equal_split=1
-first_panel_size=114
+first_panel_size=88
message_visible=1
keybar_visible=1
xterm_title=1
View
17 cli.firefox/firefox
@@ -89,10 +89,14 @@
# unknown options like -P to firefox (or firefox3).
+# Related:
+# http://www.cs.indiana.edu/~kinzler/webrowse/ - cutbuf / inbrowse / webbrowse
+
+
# variables with user settings
t=thunderbird
-f3=/usr/bin/firefox-3.0
-f=$(which firefox-3.5)
+f3=/usr/bin/firefox-3.6
+f=$(which -a firefox | grep -v -- $0 | head -1)
[ "$f" = "" ] && f=/usr/bin/firefox
fs=/usr/bin/mozilla # 64bit
#fs=/usr/local/seamonkey/seamonkey # 32bit official build - currently FAIL
@@ -257,8 +261,9 @@ while [ "$1" != "" ]; do
# exit with suitable test status code
-procall) ps -ef | egrep -v egrep | egrep -e 'firefox*/firefox' -e thunderbird -e firefox-bin -e 'firefox.*-bin' -e mozilla; exit $? ;;
- -proc) firefoxversion=${f##*-}; ps -ef | egrep -v egrep | grep "firefox-$firefoxversion/firefox"; exit $? ;;
- -kill) firefoxversion=${f##*-}; $kill "firefox-$firefoxversion/firefox"; exit $? ;;
+ -proc) ps -ewwo user,pid,ppid,nice,pri,vsize:7,rssize:7,tty:6,start,pcpu,pmem,time,cmd | grep -E -i 'firefox[-]bin' ; exit $? ;;
+ -watch) exec watch --interval=10 "ps -ewwo pid,vsize:7,rssize:7,pmem,time,cmd | grep -E -i 'firefox[-]bin'" ;;
+ -kill) killproc firefox-bin ; exit $? ;;
-ping) $f -remote "ping()"; exit $? ;;
-ping-tb) $t -remote "ping()"; exit $? ;;
@@ -304,11 +309,9 @@ while [ "$1" != "" ]; do
esac
done
-
-
[ "$firefox_to_start" = "-1" -a "$#" = "0" ] && checkfirefox
if [ "$firefox_to_start" = "1" -a "$1" = "" ]; then
- ( date > $fl.url; nice $nice $f > $fl 2>&1 </dev/null ) &
+ ( date > $fl.url; exec nice $nice $f > $fl 2>&1 </dev/null ) &
exit
fi
View
3  cli.firefox/firefoxgrep
@@ -52,7 +52,8 @@ if (not $file or not $file=~/:/ and not -r $file) {
# try find a default in .mozilla
if (not $file or not $file=~/:/ and not -r $file) {
# allows for migration from firefox to a hopefully more current firefox-<...>
- my $firefoxhome=`ls -dr1 ~/.mozilla/firefox{,-*}| head -1`; $firefoxhome=~s/\n//g;
+ my $firefoxhome=`ls -dr1 ~/.mozilla/firefox{-*,} 2>/dev/null | head -1`; $firefoxhome=~s/\n//g;
+## WARNING: ASSUMES THAT OUR PROFILE OF INTEREST ENDS IN *default - use FIREFOXGREPPATH to explicitely set it!
chomp($file=`ls -dt1 $firefoxhome/*default/bookmarks.html $firefoxhome/*default/places.sqlite 2>/dev/null | head -1`);
}
View
16 cli.firefox/firefoxgrepsqlite
@@ -6,7 +6,7 @@
# copyright: (c) 2009 jakobi@acm.org, GPL v3
# archive: http://jakobi.github.com/script-archive-doc/
# created: jakobi@acm.org 20090211
-# last change: jakobi@acm.org 20090620
+# last change: jakobi@acm.org 20110419 - for firefox4/sqlite3 3.7.x WAL journaling mode and my too-ancient-DBD
# in addition to the html dumper, we use ::: as delimeter in listing
# multiple pathes (e.g. due to tags or similar) instead of returning
@@ -27,7 +27,19 @@ use Data::Dumper;
package bm;
my($o_tree, $file)=@ARGV;
-system(qq!cp '$file.journal' '${file}0.journal' 2>/dev/null; cp '$file' '${file}0'!); $file.="0"; # enforce creation of a lockfree corrupt db copy
+
+## enforce creation of a lockfree corrupt db copy
+#
+# perl -e 'undef $/;$_=<>;s/\A(.{18})../$1\x01\x01/;print' places.sqlite0 > places.sqlite1
+# sqlite3.7: WAL mode: http://www.sqlite.org/wal.html#bkwrds !!
+# sigh - I utterly refuse to code this sqlite3 3.7.x ugliness in perl proper...
+system(qq!cp '$file.journal' '${file}0.journal' 2>/dev/null!);
+system(qq!cp '$file-wal' '${file}0-wal' 2>/dev/null!); # not that this helps, considering the ugliness below to change \x2\x2 back to \x1\x1 for ancient software
+system(qq!cp '$file-shm' '${file}0-shm' 2>/dev/null!);
+system(qq!cp '$file' '${file}0'!);
+system(qq!perl -i.bak -e 'undef \$/;\$_=<>;s/\\A(.{18})../\$1\\x01\\x01/;print' '${file}0'!); # and hack/remove the WAL version for old sqlite3 < 3.7 / old perl DBD::SQLite::db
+$file.="0";
+
my(%node, %place);
View
17 cli.list.rename/emv
@@ -8,7 +8,7 @@
# http://translate.google.com/translate?tl=en&sl=de&u=http%3A%2F%2Fwww.pro-linux.de%2Fberichte%2Fappfokus%2Femv%2Femv.html]
-my $version="2.00pj.4";
+my $version="2.00pj.5";
# last changes:
# 2007XXXX PJ jakobi@acm.org changed to include line numbers in the editor,
# allowing arbitrary editor commands and reordering (perl scraps)
@@ -22,6 +22,7 @@ my $version="2.00pj.4";
# when unsetting $mv2, --nopathtrack, --todir/--nodir, --perlpostedit
# 20090826 PJ fixed emvx bug - when did appending $deltaorg @orgfile change to @newfile!?
# 20090913 PJ fixed my($_) for older perls
+# 20110304 PJ empty target names: skip lines
# Copyright (c) 2006-2009 jakobi@acm.org placed under GPL v3 and newer
# archive: http://jakobi.github.com/script-archive-doc/
@@ -63,7 +64,7 @@ my $version="2.00pj.4";
# [won't modify for now]
# ? filenames containing [", ']: works. However I'm less certain
# about say utf8 w/wo locale conflicts and invalid chars like e.g.
-# a latin1 umlaut in filenames - wil the shell accept the command,
+# a latin1 umlaut in filenames - will the shell accept the command,
# or return an error (either would be caught correctly)?
# Or worse: will the a questionable shell or mv implementation
# irresponsibly silently strip the character in question
@@ -581,10 +582,12 @@ sub sq{ # escape hack for single-quoting
}
sub pr { # return printable chars -- protect the tty against control codes below \x80
- # Q: 9b vs. utf8 - leave alone for now
+ # aso add CSI x9b to be save (added whole range: http://invisible-island.net/xterm/ctlseqs/ctlseqs.html ,
+ # http://en.wikipedia.org/wiki/C0_and_C1_control_codes )
local($_)=@_;
# s/[\0-\x1f\x7f]/"%".unpack("H2",$&)/ge;
- s/[\0-\x08\x0a-\x1f\x7f]/?/go; # emv: still allow tabs (convenience cmd!)
+ # s/[\0-\x08\x0a-\x1f\x7f\x80-\x9f]/?/go; # emv: still allow tabs (convenience cmd!)
+ s/[\0-\x08\x0a-\x1f\x7f]/?/go; # assuming UTF8 host environment, CSI \x9b, etc _IS_ occurring as part of valid utf8 chars
return $_;
}
@@ -620,7 +623,8 @@ ${commentchar} emvp [-p|-i] perlop (without myrename: e
${commentchar} emvs [-r] (sort keeping dirs and dir-children together)
${commentchar} sed cut -f 2- sort -k 2.1 grep . (-l: -f 3-, -k 8.1)
${commentchar} editors like vim complement this: :help range, :help visual-block
-${commentchar} :set number :set list :23,25s/^/#/ [V] + IDir/<ESC>
+${commentchar} :set number :set list :set fileencoding=utf-8
+${commentchar} :23,25s/^/#/ visual block mode [V] + IDir/<ESC>
${commentchar} :sort /\\t/ [V]+:s=\\t=&Dir/= :%g=X=d :%g!/./d gf
${commentchar} (-l) :sort /#\\t/ :.,\$s=#\\t=&Dir/= :sort n/\\d\\+ \\d/r [V]+gf
${commentchar} emv line format is <WS>* NUMBER <TAB> NAME
@@ -944,7 +948,8 @@ sub parseeditorresults {
unshift @lin,""; # 1-base it
@new=grep /\S/, map {s/^\s+//; s/^["#].*//; # skip comments
# did strip meta info here
- s@/$@@; # strip dir-/
+ s@/$@@; # strip final dir-/
+ s/^\d+\t?$//; # strip numbered lines w/w-o tab but without a new filename
$_} @$newref;
conveniencecommands(\@lin,\@new);
View
2  cli.list.various/randomcat
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# randomize lines
+# randomize lines (see also: debian: shuf)
my $version="0.1";
# created PJ 2002XXXX jakobi@acm.org
View
1  cli.processes/zap
@@ -18,6 +18,7 @@ my $version="0.5.3";
# 11.09.09 pj added cpulimit for higher nice values
# (c) perl artistic licence
+# snice/skill is a 1999-era interactive C variant of this theme
#========================================================= Variables 1
View
120 cli.shell.functions/dir.shell/dict.func
@@ -1,5 +1,5 @@
# created PJ 200907XX jakobi@acm.org
-# copyright: (c) 2009 jakobi@acm.org, GPL v3 or later
+# copyright: (c) 2009-2011 jakobi@acm.org, GPL v3 or later
# archive: http://jakobi.github.com/script-archive-doc/
# translation functions
@@ -17,11 +17,16 @@ function xlatef { # francais
lynx -width=$COLUMNS -dump -nolist "HTTP://dict.leo.org/?lang=de&lp=frde&search="`perl -e 'print join "%20", grep {s/ /%20/g;$_} @ARGV;' "$@"` | xlate_filter
}
# translations D/J (req. netscape): http://bunmei7.hus.osaka-u.ac.jp:591/WadokuJT/search.htm
-function xlatej { # japanese/english
- lynx -width=$COLUMNS -dump -nolist "HTTP://dict.regex.info/cgi-bin/j-e/tty/dosearch?sDict=on&H=PS&L=J&WC=none&T="`perl -e 'print join "%20", @ARGV;' "$@"` |\
- perl -e 'undef $/; $_=<STDIN>; $_="" if /Roman?ji Conversion Error|No Matches Found/i; s/\A[\s\S]*?Found//mgoi; s/ *_____[\s\S]*//mgoi; print' | grep .
- lynx -width=$COLUMNS -dump -nolist "HTTP://dict.regex.info/cgi-bin/j-e/tty/dosearch?sDict=on&H=PS&L=E&WC=none&T="`perl -e 'print join "%20", @ARGV;' "$@"` |\
- perl -e 'undef $/; $_=<STDIN>; $_="" if /Roman?ji Conversion Error|No Matches Found/i; s/\A[\s\S]*?Found//mgoi; s/ *_____[\s\S]*//mgoi; print' | grep .
+function xlatej {
+ : japanese/english
+ : typeset url=http://www.gokanji.com/cgi-bin/j-e/dict
+ : "ex. waka AND ENG separate OR understand AND NOT wakare OR wakari (with OR binding MORE TIGHTLY than AND!!)"
+ typeset url=http://enterprise.ottix.net/cgi-bin/j-e/utf8/tty/
+ lynx -width=$COLUMNS -dump -nolist "$url/dosearch?sDict=on&H=PS&L=J&WC=none&IR=on&T="`perl -e 'print join "%20", @ARGV;' "$@"` |\
+ perl -e 'undef $/; $_=<STDIN>; $_="" if /Roman?ji Conversion Error|No Matches Found/i; s/\A[\s\S]*?(Found|First \d+ Matches:)//mgoi; s/ *_____[\s\S]*//mgoi; print' | grep .
+echo ==
+ lynx -width=$COLUMNS -dump -nolist "$url/dosearch?sDict=on&H=PS&L=E&WC=none&IR=on&T="`perl -e 'print join "%20", @ARGV;' "$@"` |\
+ perl -e 'undef $/; $_=<STDIN>; $_="" if /Roman?ji Conversion Error|No Matches Found/i; s/\A[\s\S]*?(Found|First \d+ Matches:)//mgoi; s/ *_____[\s\S]*//mgoi; print' | grep .
true
}
@@ -37,6 +42,15 @@ function xl_is_latin {
function xl_to_ascii { cat ${1+"$@"} | noumlaut | recode -f ..flat ;}
function xl_to_utf { cat ${1+"$@"} | recode -f latin1..utf8 ;}
+function xlatel {
+ _arg="$(perl -e '$_=join " ", @ARGV; s/([\(\)\[\]\{\}\&\;\+\s])/"%".unpack(H2,$1)/geo; print' "$@")"
+ w3m -dump "http://translate.google.com/translate_t?hl=&ie=UTF-8&sl=la&tl=en&text=$_arg" |\
+ perl -e 'undef $/; $_=<STDIN>; /[\s\S]+?Latin to English.*\n([\S\s]*?)\n.*(contribute a better translation|\Z|View detailed dictionary)/i and $_=$1 or $_=""; print' | grep .
+ echo
+ w3m -dump "http://translate.google.com/translate_t?hl=&ie=UTF-8&tl=la&sl=en&text=$_arg" |\
+ perl -e 'undef $/; $_=<STDIN>; /[\s\S]+?English to Latin.*\n([\S\s]*?)\n.*(contribute a better translation|\Z|View detailed dictionary)/i and $_=$1 or $_=""; print' | grep .
+ true
+}
function xlatej2 { # japanese/english phrase+romaji translation via google
# using w3m for it's utf8 support (lynx doesn't work regardless of -assume*, but that might be google's http headers)
# - a local romaji conversion would be e.g.
@@ -47,12 +61,13 @@ function xlatej2 { # japanese/english phrase+romaji translation via google
# - see also: http://php.net/manual/en/function.recode-string.php (e.g. romaji to hiragana transliteration)
# - detecting non-ascii/non-sane: perl -lne 'exit 1 if not /[^\x20-\x7e]/' # maybe allow for CRLF and TAB or even ESC/CSI
# - DEC, EUC, SJIS are older non-compatible kanji encodings
- arg="$(perl -e '$_=join " ", @ARGV; s/([\(\)\[\]\{\}\&\;\+\s])/"%".unpack(H2,$1)/geo; print' "$@")"
- w3m -dump "http://translate.google.com/translate_t?hl=&ie=UTF-8&sl=ja&tl=en&text=$arg" |\
- perl -e 'undef $/; $_=<STDIN>; /[\s\S]+?Japanese to English.*\n([\S\s]*?)\n.*contribute a better translation/i and $_=$1 or $_=""; print' | grep .
+ : use head -1 for romaji
+ _arg="$(perl -e '$_=join " ", @ARGV; s/([\(\)\[\]\{\}\&\;\+\s])/"%".unpack(H2,$1)/geo; print' "$@")"
+ w3m -dump "http://translate.google.com/translate_t?hl=&ie=UTF-8&sl=ja&tl=en&text=$_arg" |\
+ perl -e 'undef $/; $_=<STDIN>; s/Dictionary - View.*\n|Japanese to English.*\n|\[\s+\].*\n//g;/\s+Cancel.*\n([\S\s]*?)\n.*(contribute a better translation|\Z|Google.Translate for)/i and $_=$1 or $_=""; print' | grep .;
echo
- w3m -dump "http://translate.google.com/translate_t?hl=&ie=UTF-8&tl=ja&sl=en&text=$arg" |\
- perl -e 'undef $/; $_=<STDIN>; /[\s\S]+?English to Japanese.*\n([\S\s]*?)\n.*contribute a better translation/i and $_=$1 or $_=""; print' | grep .
+ w3m -dump "http://translate.google.com/translate_t?hl=&ie=UTF-8&tl=ja&sl=en&text=$_arg" |\
+ perl -e 'undef $/; $_=<STDIN>; /[\s\S]+?English to Japanese.*\n([\S\s]*?)\n.*(contribute a better translation|\Z|View detailed dictionary)/i and $_=$1 or $_=""; print' | grep .
true
}
function xlatej_url { # japanese/english via google or babelfish
@@ -93,7 +108,83 @@ function xlate_ref { # www.reference.com
echo '#lynx "'$url'"'
}
-
+function xlate_answers {
+ w3m -no-proxy -M "http://www.answers.com/"`perl -e 'print join "%20", grep {s/ /%20/g;$_} @ARGV;' "$@"`
+}
+
+function xlate_idiom {
+ w3m -no-proxy -M "http://idioms.thefreedictionary.com/"`perl -e 'print join "%20", grep {s/ /%20/g;$_} @ARGV;' "$@"`
+}
+
+function xlate_dictw {
+ w3m -no-proxy -M "http://en.wiktionary.org/wiki/"`perl -e 'print join "%20", grep {s/ /%20/g;$_} @ARGV;' "$@"`
+}
+
+
+function xlate_mkpw {
+ : "xlate_pw [-s seed string or url] [length or sample-string]"
+ : "generate a pastable pw of specified length"
+ : "if invoked with -s, always generate the same pw for the same seed,"
+ : "provided Perl's rand is as stable over releases as it should be"
+ : " probably better: crypt hash instead of randomizing for -s (think unixpw)"
+ : " hash(salt + domain) -> (pw, list of uid suggestions)"
+ perl -lXe '
+ if($ARGV[0] eq "-s"){srand(unpack "%L*",$ARGV[1]);shift;shift}else{srand};
+ $l=$ARGV[0]//=8;$l=length($l) if $l=~/[^0-9]/; $#l=$l-1;
+ $_="abcdefghijklmnopqrstuvwxyz";@c=split "",$_.uc.q!+-_%:0123456789!;
+ print map{$c[int(rand $#c+1)]} @l
+ ' -- ${1:+"$@"}
+ # see also
+ # perl's randpass, String::MkPasswd (unreadable, w constraints)
+ # Crypt::RandPasswd (readable pw)
+ # mkname (xlate_mkname, readable names, also acc to word lists)
+ # language confluxer lc (http://www.ruf.rice.edu/~pound/)
+ # also there: werd, a tiny grammar-controlled name/language-wordlist generator
+ # Data::Password (e.g. IsBadPassword()) # dict
+ # Data::Password::Entropy # usage-freq stats, but ignores dict/qwerty-distances,
+ # primitive l=1 style obfuscation, (char/seq)-usage-frequencies
+ # setting PAM to NSA-style pw:
+ # perl -p -i.prekickstart -e 'BEGIN {print stderr "Configure password quality module\n";};s{(^password\s+requisite\s+)(pam_cracklib.so)(.*)}{$1 pam_passwdqc.so min=disabled,disabled,16,12,8} ;' /etc/pam.d/system-auth
+ # get 100 10-char passwords in ksh: (500 chars to have probably enough
+ # alphanum chars to make up the password; piping to uue might be better)
+ # - L=10;i=1;while [ $i -le 100 ];do head -c 500 /dev/urandom|tr -dc a-zA-Z0-9|head -c $L;echo;let i+=1;done
+ # get a 18-byte random uue string from 10-byte (+33% cum padding)
+ # - head -c 10 /dev/urandom | perl -e '$_=<>;print pack("u",$_)'
+ # - head -c 10 /dev/urandom | base64 | head -c 12
+ # - head -c 10 /dev/urandom | cat -vet
+ # openssl rand -base64 32 # 45 char pw (32byte thru uue)
+ # date|md5sum
+}
+function xlate_mkname {
+ : "restricted to about maxsize of word in /u/s/d/words or similar: <=22"
+ : "strip the usual 's used as hint suffix in the wordlist"
+ if [ "$1" != "" ]; then
+ ~/bin/xlate_mkname -m $1 -M $1;
+ else
+ ~/bin/xlate_mkname
+ fi
+}
+function xlate_mkpassphrase {
+ : see xlate_pw, but insteads of password, do generate a passphrase from /usr/share/dict/words
+ : note that word list updates make -s URL -style seeding QUICKLY unstable/unreliable
+ perl -e '
+ if($ARGV[0] eq "-s"){srand(unpack "%L*",$ARGV[1]);shift;shift}else{srand};
+ $l=$ARGV[0]//=8;
+ @c=`cat /usr/share/dict/words|sed "s/[^a-zA-Z].*//"|sort -u`;chomp @c;
+ while(@p<$l){push @p,$c[int(rand $#c+1)]};
+ print join(" ",@p),"\n";' -- ${1:+"$@"}
+}
+function xlate_pwquality {
+ : see also Data::Password::Entropy / xlate_pwentropy
+ : BUG: tests only against 1st readable dictionary file, no dvorak
+ perl -le '
+ use Data::Password qw(:all);
+ $MAXLEN=2000000;
+ push @DICTIONARIES, map {s!^!/usr/share/dict/!;$_} map {$_}
+ qw(american-english british-english ngerman ogerman);
+ $_=shift;s/ /_/g;
+ print IsBadPasswordForUNIX("nobody",$_)//"ok"' -- ${1:+"$@"}
+}
# requires ispell, ingerman, iogerman, iamerican
function ispellwort {
@@ -115,10 +206,6 @@ function ispellword {
# -------------------------------------------------------------
alias feiertage='gcal -q de_BA -n'
-function answers {
- w3m -no-proxy -M "http://www.answers.com/$1"
-}
-
function wikid {
w3m -no-proxy -M "http://de.wikipedia.org/wiki/$1"
}
@@ -126,6 +213,7 @@ function wikie {
w3m -no-proxy -M "http://en.wikipedia.org/wiki/$1"
}
alias wiki=wikie
+alias wiki.de=wikid
# vim:filetype=sh
View
32 cli.shell.functions/dir.shell/grep.func
@@ -1,5 +1,5 @@
# created PJ 200907XX jakobi@acm.org
-# copyright: (c) 2009 jakobi@acm.org, GPL v3 or later
+# copyright: (c) 2009-2011 jakobi@acm.org, GPL v3 or later
# archive: http://jakobi.github.com/script-archive-doc/
function gr_catfile {
@@ -71,6 +71,7 @@ function gr_HELP {
gr_D, gr_BASEDIR -- truncate to basedir (implies uniq)
gr_S, gr_STRIP -- strip ' :: '-comments from input (e.g. '<filename> :: <ogg tags>+')
gr_STRIPX1 -- strip \\x01 characters from input
+ gr_ep -- grep - short for Grep.pm -i -B
# similar, but suppressing already cached lines (-k is case insignificant):
gr_NEW F -- uniq, but suppress lines from cache file F, appending new
@@ -115,7 +116,12 @@ function gr_HELP {
gr_SHORT0 -- magical paren removal + ~~-shorten for long filenames
gr_MIXED2UTF -- coping with mixed latin/utf8 pipe content:
if line doesn't seem to be utf8, try latin1-to-utf8
+ gr_LS -- return find -ls output for the given file names
+ gr_PR -- strip some non-printable chars (tty control codes mostly)
+ # list generating
+ gr_(r)dir -- find (-maxdepth 0) -- * | gr_ep
+
Notes:
- only gr_UNIQ/gr_NEW* support ignoring case for dupe detection
(-i or export \$gr_UNIQ_IGNCASE=1). All others are case-significant.
@@ -124,7 +130,21 @@ Notes:
EOF
}
+
+
+
# gr_* family of filters for handling reporting lists of files (changed to uniq/unsort, caches all seen entries)
+
+function gr_ep {
+ Grep.pm -i -B ${1:+"$@"}
+}
+function gr_dir {
+ find -- * -maxdepth 0 | gr_ep ${1:+"$@"}
+}
+function gr_rdir {
+ find -- * | gr_ep ${1:+"$@"}
+}
+
function gr_STRIP0 {
perl -lne 'next if $c{$_}; do{print;$c{$_}++;next} if -e $_; s/ :: +(\S.*|)?$// and do{next if $c{$_};do{print;$c{$_}++;next} if -e $_};'
}
@@ -172,6 +192,10 @@ function gr_SHORT0 {
s@~~@$se~~@go;
}; print if not $c{$_}++'
}
+function gr_LS {
+ # note that find -ls escapes special chars
+ cat0 | xargs0 sh -c 'find "$@" -maxdepth 0 -ls' find
+}
function gr_SLURP {
perl -0ne 'use ARGV::readonly;$x.=$_; END{print $x}' ${1:+"$@"}
@@ -319,6 +343,12 @@ function gr_NEWCLR {
function gr_MIXED2UTF {
perl -lne 'use Encode; $o=$_; $_=decode("utf8",$_); $_=decode("latin1",$o) if /\x{FFFD}/ and not $o=~/\xef\xbf\xbd/; print encode("utf8",$_)'
}
+function gr_PR { # filter non-printable chars (i.e. tty control chars) to avoid display messup
+ perl -lpe 's/[\x0-\x1f\x7f]/?/g' # cannot strip CSI \x9b, etc, as it's part of valid utf8 chars
+}
+function gr_PR2 {
+ perl -lpe 's/[\x0-\x1f\x7f\x80-\x9f]/!/g'
+}
# schwartzian transform support, allowing for temporary destructive
# line changes.
View
10 cli.shell.functions/dir.shell/media.func
@@ -15,12 +15,18 @@ function say {
}
# XV - its about time to avoid this proggy...
-# N: on save reduced image, consider to removing the
+# N: on save reduced image, consider removing the
# save-normal-size-flag set in Xdefaults
#XV=${XV:--geometry 1000x1000 -fixed}# max size, but always scales
XV=${XV:--expand .5} # just half the size for now
function xv {
- /usr/local/bin/xv $XV "${1:+$@}";
+ if [ "$1" == "test" ]; then
+ # monitor test image
+ /usr/local/bin/xv ~/images/l46a1024.bmp
+ /usr/local/bin/xv -rotate 90 ~/images/l46a1024.bmp
+ else
+ /usr/local/bin/xv $XV "${1:+$@}";
+ fi
}
function gwenview {
View
4 cli.shell.functions/dir.shell/misc.func
@@ -2,7 +2,9 @@
# copyright: (c) 2009 jakobi@acm.org, GPL v3 or later
# archive: http://jakobi.github.com/script-archive-doc/
-alias psg='ps -efww | grep -i'
+alias psg0='ps -efww | egrep -i'
+alias psg='ps -ewwo user,pid,ppid,tty,cmd | grep -v grep.-E.-i | grep -E -i'
+alias psgl='ps -ewwo user,pid,ppid,nice,pri,vsize:7,rssize:7,tty:6,start,pcpu,pmem,time,cmd | grep -v grep.-E.-i | grep -E -i'
alias wget0='wget --retry-connrefused --limit-rate=500k --waitretry=10 --wait=3 --random-wait'
if [ -n "_IS_BASH" ]; then
View
4 cli.various/ALARM
@@ -68,6 +68,10 @@ if [ "$DISPLAY" != "" ] ; then
# FreeDesktops notification area / systray via e.g. a full Gtk app using
# e.g. Menues and Gtk2::TrayIcon [even worse than wall]
+ # see also: notify-send -i icon.gfx 'TITLE' 'MSG'
+ # http://www.thegeekstuff.com/2010/12/ubuntu-notify-send/
+ # https://wiki.ubuntu.com/NotificationDevelopmentGuidelines
+
# OSD notification, annoying and for a day
export tmp=$(echo "$msg" | tr '()' '{}')
# however, these don't queue like maybe
View
2  cli.various/dir.printing/lpr
@@ -23,7 +23,7 @@ else if echo "$ADDON_PATH" | grep -i firefox >/dev/null ||
unset MYPSNUPREROUTEALL
# enter your customized print command below
# maybe pop a requester if DISPLAY seems to work to allow modifications?
- mypsnup $opt
+ mypsnup $opt >> $HOME/.lpr.debug
else
echo "final else" >> $HOME/.lpr.debug
/usr/bin/lpr "$@"
View
4 cli.various/dir.printing/mypsnup
@@ -44,8 +44,8 @@ while(@ARGV) {
/^\+s3$/ and do{$MYPSNUPBND="-m0.5cm -b-2cm"; shift; next}; # scale mini page up, mini page boundaries
/^\+s2$/ and do{$MYPSNUPBND="-m1cm -b-1.5cm"; shift; next}; # scale mini page up, mini page boundaries
/^\+s1$/ and do{$MYPSNUPBND="-m0.0cm -b-0.7cm"; shift; next};
- /^[-\+]s0?$/ and do{$MYPSNUPBND="-m0.0cm"; shift; next}; # scale final page down - outer page boundary
- /^-s1?$/ and do{$MYPSNUPBND="-m0.5cm"; shift; next};
+ /^[-\+]s0?$/ and do{$MYPSNUPBND="-m0.0cm"; shift; next}; # don't scale (though note the -b-0.5 or similar as default below)
+ /^-s1?$/ and do{$MYPSNUPBND="-m0.5cm"; shift; next}; # scale final page down - outer page boundary
/^-s2$/ and do{$MYPSNUPBND="-m0.7cm"; shift; next};
/^-?-debug$/ and do{$debug=1; shift; next};
/^-[Pd](.*)$/ and do{$MYPSNUPPRT=$1; shift; $MYPSNUPPRT=shift if not $MYPSNUPPRT; next}; # destination printer
View
2  versions
@@ -12,7 +12,7 @@
./cli.list.grep/cat0:0.1
./cli.list.grep/cat0par:0.1.1
./cli.list.grep/expansyn:0.2
-./cli.list.rename/emv:2.00pj.4
+./cli.list.rename/emv:2.00pj.5
./cli.list.rename/myrename:0.2
./cli.list.rename/myrename.mangle:0.1
./cli.list.tagls/tagls:0.2.2
Please sign in to comment.
Something went wrong with that request. Please try again.