Re: Tao Te Ching: The Book of The Way

@ tunafish - it is not done yet.  I am just starting to look into it  but I was sharing how I wanted it to be - can't get there if I don't know where is 'there'.

I thinking a lyrics script from conky piped to twmn may be a start.

Re: Tao Te Ching: The Book of The Way

^ it shouldn't be too difficult to write a script for this. just don't use my tao-script, because it grabs the information in a certain way, a way which you don't want. build your own that will grab it just how you want from the .txt.

if you don't know how this should be done (i have no idea how much you know about bash-scripting), i could probably give you some pointers. hell, i could write the script myself. but if you are really interested in this, it is a perfect way to learn some scripting yourself.

Re: Tao Te Ching: The Book of The Way

A blast from the past here! Was introduced to the TTC many years ago but didn't really understand it. It seems to make a bit more sense now. Thanks Rhowaldt!

John
------------------------
( a boring Japan blog , and idle twitterings )
“Good morning sir, which way up would you like your reality today?”  "As it comes, Jeeves, as it comes..."

Re: Tao Te Ching: The Book of The Way

^ glad to be able to re-introduce you to a great text. i must admit i don't feel i 'get' half of what is in there either, but i just keep reading because the writing (ok, this translation) is beautiful and i feel that i'll eventually understand what most of it is about smile

Re: Tao Te Ching: The Book of The Way

@Aalis: here's your script. i hoped to adapt the one by Luc, which is awesome in how concise it is. however, i ended up not being able to use much of it so made my own again. Luc, feel free to make your adaptations! big_smile

#!/bin/bash
# a script for outputting a small portion of the Tao Te Ching.
# this script starts from a random full stop, then prints the following
# sentence(s) until reaching a full stop.

tao="tao_te_ching.txt"
# you can chose between /dev/random which is slow but provides ``more random''
# numbers than the faster /dev/urandom
dev_rand=/dev/urandom
#dev_rand=/dev/random
startline_num=0
lines=($(cat tao_te_ching.txt | grep -n -s "\." | sed 's/:.*//'))

# shuffle function based on Knufth-Fisher-Yayes shuffle algorithm
# http://mywiki.wooledge.org/BashFAQ/026 thank you!
# takes an array as input through 'shuffle ARRAY[@]', outputs arr[@]
shuffle() {
   local i tmp size max rand
   arr=("${!1}") # retrieve array from $1
   # $RANDOM % (i+1) is biased because of the limited range of $RANDOM
   # Compensate by using a range which is a multiple of the array size.
   size=${#arr[*]}
   max=$(( 32768 / size * size ))

   for ((i=size-1; i>0; i--)); do
      while (( (rand=$RANDOM) >= max )); do :; done
      rand=$(( rand % (i+1) ))
      tmp=${arr[i]} arr[i]=${arr[rand]} arr[rand]=$tmp
   done
}

# if we have no arguments we pick a random verse
if [ $# -eq 0 ]; then
   shuffle lines[@] && startline_num=${arr[1]}
else
   # we got the wrong number of arguments
   echo "Stop giving arguments. They will make you stray from the path." >&2
   exit 1
fi

startline_num=$(($startline_num+1))
startline="$(sed -n "$startline_num"'p' $tao)"

while [[ ${startline:0:1} == "" ]] || [[ ${startline:0:1} == "-" ]]; do
   startline_num=$(($startline_num+1))
   startline=$(sed -n "$startline_num"'p' $tao)
done

stopline_num=$startline_num
stopline="$startline"
stopline_length=$((${#stopline}-1))

while [[ ${stopline:$stopline_length:1} != "." ]]; do
   stopline_num=$(($stopline_num+1))
   stopline="$(sed -n "$stopline_num"'p' $tao)"
   stopline_length=$((${#stopline}-1))
done

sed -n "$startline_num,$stopline_num"'p' $tao

how it works is explained in the comments at the start of the script.

it gives pretty okay results:

[21:44:31]$ taoshort
He never expects results;
thus he is never disappointed.

[21:44:33]$ taoshort
You can use it any way you want.

[21:44:38]$ taoshort
When they know that they don't know,
people can find their own way.

[21:44:40]$ taoshort
Content with an ordinary life,
you can show all people the way
back to their own true nature.

the ones which are clearly broken up remind me of Brian Eno and Peter Schmidt's awesome 'Oblique Strategies' set of texts, so i suppose that is okay too smile

edit: here's the twmn-script: http://crunchbanglinux.org/forums/post/186179/#p186179

now all i got left to do is have that script pop-up at random times, to surprise myself with weird texts. smile

Last edited by rhowaldt (2012-02-03 21:21:24)

Re: Tao Te Ching: The Book of The Way

btw, edited the first post:
- added a full stop after line 10 of the full Tao Te Ching text, which was missing. you might want to change that in your own copy too.
- added a short P.S. at the end of the post to explain why you sometimes encounter 'he' and sometimes 'she' when the author refers to a person (if you noticed at all!)

Re: Tao Te Ching: The Book of The Way

My brother, and fellow follower of the Way of Unix, rhowaldt, you have laboured long and hard to preserve the wisdom of Lao Tzu, as only became fully clear to me upon transcribing your words to my desk. My finger was much wearied from holding down the mouse button by the time the fullness of copying was attained.  Yet, I wonder If your thirst for knowlege has not led your mind into overly narrow tortuous paths, into preoccupation with the Thousand Objects...

It may be that the Randomness of Shuf is insufficient for your spiritual needs, but should that not be the case, behold the One Line:

awk 'BEGIN {RS="."} /^#/{sub(/^#.*rhowaldt/,"")}{gsub (/\n/," ");gsub(/---[0-9]+---/,"");sub(/^[ \t]*/,"");print $0 "."}' <tao_te_ching.txt | shuf -n1

I was fortunate to be assisted by the Master Awk - he has many skills that might help you along the path.
http://ompldr.org/vYTUxZQ

Last edited by johnraff (2012-02-04 16:09:04)

John
------------------------
( a boring Japan blog , and idle twitterings )
“Good morning sir, which way up would you like your reality today?”  "As it comes, Jeeves, as it comes..."

Re: Tao Te Ching: The Book of The Way

^ hahaha that made me laugh so hard big_smile

still, aside from the fact that you've missed a 't' at the end when copy-pasting (tao_te_ching.tx ?), i'm not 100% sure what this code accomplishes, aside from just printing out the entire text in one go, while omitting the verse-numbers..?

when i started out with these scripts, i looked into awk. however, i could not wrap my brain around it (maybe needs more time but okay, maybe wasn't in the right mood smile) so i let it go and sought other methods. declared awk 'awkward' in my brain big_smile

Re: Tao Te Ching: The Book of The Way

^Please accept my most humble apologies. In my eagerness, some valuable teachings were indeed omitted from The Line. That has now been remedied.

Along with Awk, our other helper is Shuf, but as I mentioned, I am unaware if his randomness is as complete as that of /dev/random

John
------------------------
( a boring Japan blog , and idle twitterings )
“Good morning sir, which way up would you like your reality today?”  "As it comes, Jeeves, as it comes..."

Re: Tao Te Ching: The Book of The Way

I don't know what to do, I just do it

Re: Tao Te Ching: The Book of The Way

How about Statler quoting from the Tao instead of fortune?
Following the instructions here: http://tech-hanoosh.blogspot.com/2009/0 … -file.html
I made a slightly modified version of rhowaldt's tao file here: http://crunchbanglinux.org/pastebin/1476 which I called tao-fortune.
If you think some sections are too long you can intersperse a line with % on it to break them up.
Now run

strfile tao-fortune

to get tao-fortune.dat. Copy tao-fortune and tao-fortune.dat into /usr/share/games/fortunes and you can get tao quotes in your terminal with 'fortune tao-fortune'.

Now edit /usr/bin/cb-fortune:
Change part of line 20 from "fortune -s" to "fortune tao-fortune". You might also wamt to edit lines 19 and 26 for different titles and icons, but at the moment I'm enjoying a tao-quoting Statler. smile

John
------------------------
( a boring Japan blog , and idle twitterings )
“Good morning sir, which way up would you like your reality today?”  "As it comes, Jeeves, as it comes..."

Re: Tao Te Ching: The Book of The Way

@johnraff: ahhh, i see now! the corrected one-liner indeed does exactly the same thing as my script: outputting snippets! pretty cool... awk sure is good for this sort of thing, maybe i should borrow your teacher for a bit.

Re: Tao Te Ching: The Book of The Way

rhowaldt bringing enlightment
one #! screen at a time.
because the tao that can be told is not the real tao.

thanks, nice script.

39

Re: Tao Te Ching: The Book of The Way

@master john
upon reading it this programmer was enlighted.
Thank you for the links and the awk line.

Re: Tao Te Ching: The Book of The Way

Hi luc!

It's a pity Master Foo's web server seems to be misconfigured. It sends a header for the wrong encoding when it should be utf-8, making the page a bit messy-looking. You can reset it to utf-8 in your browser, but a nuisance.

John
------------------------
( a boring Japan blog , and idle twitterings )
“Good morning sir, which way up would you like your reality today?”  "As it comes, Jeeves, as it comes..."

Re: Tao Te Ching: The Book of The Way

^ nonono, you misunderstand. Master Foo did that on purpose. you will reach enlightenment through confusion.

Re: Tao Te Ching: The Book of The Way

http://ompldr.org/vYTZ5aw

John
------------------------
( a boring Japan blog , and idle twitterings )
“Good morning sir, which way up would you like your reality today?”  "As it comes, Jeeves, as it comes..."

Re: Tao Te Ching: The Book of The Way

^ nonono, you misunderstand. Master Foo did that on purpose. you will reach enlightenment through confusion.

  big_smile

Coming in on this a bit late but how about a Launcher button that runs this little pop up script..
Modify the first line to reflect your dir where you saved rhowaldt's  scripts..
You can also change the icon reference to your choice of icons in the script...

#!/bin/bash
cd /home/sqlpython/Documents/Bash
xfce4-terminal -I "/usr/share/icons/gnome/32x32/actions/address-book-new.png" --geometry 58x20 -T "Tao Te Ching" -H -e "/home/sqlpython/Documents/Bash/tao.sh"

As I am also working with PyQt widgets I did a little  QT widow launcher that does the same. You can do the same with a GTK widget or Wx widgets..etc..

Anyway...
http://img407.imageshack.us/img407/1379/screenshotteching.th.png

Last edited by sqlpython (2012-02-10 05:12:14)

OHCBR #!, Wheezy, Squeeze, Siduction, Slackware 13.xx,

Re: Tao Te Ching: The Book of The Way

well, i'm more of a terminal-type-of-guy, but i like what you did with that.