Day Sculptor 1.0 – Time and Choices

Yesterday, was a day where only 3 events were accomplished.  This allowed me the intense focus that I needed to concentrate.  The result is a much improved day_sculptor program.  Although it can probably crash, if one interacts with it in pretty predictable ways, it does what I want it to do – a lot more intervention from me on the choices.

1) Computer programming:  a new bash script posted below with both dependencies – random_set.c and random_order.c – reposted.  Directory /mnt/home may need to be edited in the file to correspond to the directory where you install the program.  I run it off of a USB port flash drive that is inserted before I boot up, and thus automatically gets the /mnt/home path as its default directory.

2) Dog work:  started to clip Petey’s nails, but nicked him, so I only got 1 paw done.  Now he’s sensitive, so I’m having to retrain him to like nail clipping with treats.  10 sits, downs, and paws with each dog, 30 commands each.

3) Personal relationship work:  the exciting news is I have a date with someone for coffee later today.  The person is Latino, so I am very excitedly trying to learn Spanish conversational dating today.  So, looking up some topics to talk about:  travel, current events, music, work and hobbies.  I need to develop a Spanish vocabulary list on these topics, and maybe look up some polite words as well.

2 Phone calls now that I have minutes.  It was a $2 “unlimited phone day”.

Phone call 1:  I talked to my parents who unfortunately have just learned that their life-long friend was diagnosed with stage 4 lung cancer.

Phone call 2:  I had a long 2 hour conversation with my friend who is caring for her mother with Alzheimer’s.  We talked about what she still can do, some very short distance slow driving, and worried about showers, stairs, and cooking.  Later, I told her about my date and that I had learned the past perfect pretty well in Spanish.  We practiced trying, with a little discussion about whether it should be podia (imperfect) or pude (preterite).  It’s an irregular verb:

“Por que dos cervantes había bebida, no podía conducir el cocho.”

We talked about clothes, and how to say “no” if I don’t feel comfortable at any point.  Need some Spanish words for this, too.

#!/bin/bash
# Day_sculptor 1.0 A bash script that helps to organize a day according to a set of goals, and implements both
# random selection of events and random reordering of events.  This version accepts a “to do list”
# extracting only valid events from it.  It also allows the user to ask for a help menu, and
# allows the user to reorder the list, insert or delete items from the list, and it updates the list
# only to those events that have not been done.  Summary output directs to a /mnt/home/logfile
# Dependencies:  needs random_order
# and random_set compiled c programs in the /mnt/home directory.
#
# submitted by livedoggb on 3/16/2012
#
function print_choice {
echo ”                       ”
echo “You chose to proceed in the following order: $choice”
echo ”                  ”
for i in ${choice}
do
echo “${event_array[$i]}”
done
return
}
#
function random_reassign {
echo ”               ”
echo “Would you like the computer to randomly reorder the events? (y or n)”
read reorder
if [ $reorder == “y” ]
then
count=0
trimmed_choice=””
#     for j in ${choice}
#       do
#            count =($count + 1)
#            if ($count > $current_pos)
#               then
#                  trimmed_choice=echo $trimmed_choice ${choice[$j]} ” ”
#               fi
#       done
echo $trimmed_choice
new_choice=$(/mnt/home/random_order $choice)
echo new_choice is “$new_choice”
choice=$new_choice
echo “The new order is:”
print_choice
fi
return
}
#
#
function neworder {
echo “Please take a few minutes to identify urgent matters that can be solved today.”
read urgent
echo $urgent “is urgent and can be solved today.”
echo ” ”
echo “Please take a few minutes to identify urgent matters that will require more time.”
read urgentneedingtime
echo $urgentneedingtime “is urgent and needs priority time over the next few days.”
echo ”                       ”
echo ”                  ”
echo “Please enter numbers in the order you would like to proceed separated”
echo “by spaces.  Simply enter 0 to ignore. Enter r at anytime in the describe activity space to redefine order of day.  Enter e at anytime in the describe activity space to exit gracefully and end program.”
echo ”                  ”
echo ”                       ”
echo ”                       ”
local i=1
while [ $i -lt $num_events ]
do
echo “$i. ${event_array[$i]}.”
i=$(( $i + 1 ))
done
echo ”                  ”
echo ”                  ”
echo “Do you have a list of things that HAVE to get done today? (y or n)”
read to_do_list
if [ $to_do_list == “y” ]
then
echo “enter items separated by commas using category numbers from above to start.”
echo “i.e. 1. Walk Petey, 8. Ask an elderly person if there is anything I can do for them, 9. Fix bicycle, 7. Sweep and Mop floors”
read real_to_do_list
fake_to_do_list=”1) Walk Petey, 9) Fix bicycle, 6) Do situps,”
#     real_to_do_list=$fake_to_do_list
remainder=$real_to_do_list
startlist=$(echo $remainder | tr “[);:\”\’.a-zA-Z,]” ” “)

#      echo $startlist
count=0
for k in ${startlist}
do
#          echo “k is” $k
if [ $k -lt 13 ]
then
if [ $k -gt 0 ]
then
k_ok=1
else
k_ok=2
fi
else k_ok=2
fi
case “$k_ok” in
1) num_in_startlist=$(( $count + 1 ))
#             echo “1-12 option”
;;
2) startlist=$(echo $startlist | sed “s/$k//”)
#             echo “not 1-12 option”
;;
esac
done
#         echo $startlist
fi
let_comp_pick=”y”
echo “Would you like the computer to randomly pick some more activities for the day? (y or n)”
read let_comp_pick
if [ $let_comp_pick == “y” ]
then
echo “Enter the number of events the computer should schedule in addition to your \”to do\” list:”
read num_ev
real_num_events=$(( $num_events-1 ))
choice=$(/mnt/home/random_set $num_ev 1 $real_num_events)
else
echo “Enter events to schedule in addition to your \”to do\” list:”
read choice
fi
choice=$(echo $startlist $choice)
echo “choice is now:” $choice

#    print_choice

#for i in ${choice}
#do
#        echo “${event_array[$i]}”
#done

random_reassign

#print_choice
return
}
#
function remove_done_things_from_list {
echo “Time to redefine your day.  The old order was:”
echo $choice
for j in ${choice}
do
echo $j “${event_array[$j]}”
done
echo
echo “The first ” $count ” events have been done.  The remaining events are: ”

newchoice=””
n=0
for j in {$choice}
do
n=$(( $n + 1 ))
if [ $n -gt $count ]
then
newchoice=$( echo $newchoice ” ” $j )
fi
done
choice=$( echo $newchoice| sed “s/}//” | sed “s/{//” )
num_sched_events=$(( num_sched_events – $count ))
#     neworder
echo $choice
for j in ${choice}
do
echo $j “${event_array[$j]}”
done
return
}
#
function insert_event {
echo “Time to redefine your day.  The current list is:”
echo $choice
n=0
for j in ${choice}
do
n=$(( $n + 1 ))
echo “pos ” $n “:” $j “${event_array[$j]}”
done
num_in_list=$n
echo
echo “What event would you like to add to the list?”
echo “Available options are:”
local i=1
while [ $i -lt $num_events ]
do
echo “$i. ${event_array[$i]}.”
i=$(( $i + 1 ))
done
echo ”                  ”
echo “Enter a number, or enter R to have computer randomly select one.  Event to add?”
read new_event
echo “Enter the desired position in the list for this event, or R to randomly place it:”
read desired_pos
newchoice=””
n=0
if [ $new_event == “R” ]
then
new_event=$(/mnt/home/random_set 1 1 $real_num_events)
echo “Picked ” $new_event ” as the new activity.”
fi
if [ $desired_pos == “R” ]
then
desired_pos=$(/mnt/home/random_set 1 1 $num_in_list)

fi
for j in {$choice}
do
n=$(( $n + 1 ))
if [ $n == $desired_pos ]
then
newchoice=$( echo $newchoice ” ” $new_event )
fi
newchoice=$( echo $newchoice ” ” $j )
done
choice=$( echo $newchoice| sed “s/{//” | sed “s/}//” )
num_sched_events=$(( num_sched_events – $count ))
#     neworder
echo $choice
for j in ${choice}
do
echo $j “${event_array[$j]}”
done

return
}

function delete_event {
echo “Time to redefine your day.  The current list is:”
echo $choice
n=0
for j in ${choice}
do
n=$(( $n + 1 ))
echo “pos ” $n “:” $j “${event_array[$j]}”
done
echo
echo “Enter the position of the event you would like to remove from the list:”
read remove_pos

echo “The new list after deletion is: ”
newchoice=””
n=0
for j in {$choice}
do
n=$(( $n + 1 ))
if [ $n != $remove_pos ]
then
newchoice=$( echo $newchoice ” ” $j )
fi
done
choice=$( echo $newchoice| sed “s/}//” | sed “s/{//” )
num_sched_events=$(( num_sched_events – $count ))
#     neworder
echo $choice
for j in ${choice}
do
echo $j “${event_array[$j]}”
done

return
}

#
function execute_events {
count=0
i=””
num_sched_events=0
for i in ${choice}
do
num_sched_events=$(( $num_sched_events + 1 ))
done
for i in ${choice}
do
finished=””
eventbgn=””
description=””
echo ” ”
echo ” ”
echo “You have accomplished ” $count ” of ” $num_sched_events ” events still undone on your list.”

echo “Some more options if you aren’t ready for this activity:”

echo “h for help.  Other options are r, R, i, d, and e.”
echo “${event_array[$i]]} anticipated.”
echo “Describe your activity.”
read description
case “$description” in
h)

remove_done_things_from_list
echo “e to exit.”
echo “r to personally reorder items on list.”
echo “R to have the computer randomly reorder items on list.”
echo “i to insert an item into the list.”
echo “d to delete an item from the list.”
execute_events
break
;;
i)
remove_done_things_from_list
insert_event
execute_events
break
;;
d)
remove_done_things_from_list
delete_event
execute_events
break
;;
r)
remove_done_things_from_list
echo “Enter a new order for the remaining ” $num_sched_events “events:”
read choice
echo ”                  ”
echo “The new order is:”
echo $choice
for j in ${choice}
do
echo “${event_array[$j]}”
done
finished=”not”
echo   “Program is continuing with a new order.”
execute_events
break
;;
e)
echo “Ending gracefully.  Bye.”
break 10
;;
R)
remove_done_things_from_list
echo “Randomly reassigning.”
random_reassign
execute_events
break
;;
esac

echo “Please press enter when you begin ${event_array[$i]}.”
read bgn
date
# eventbgn=”$(expr $(”date | awk ‘{print $4}”’|sed “s/:.*//”)*60+
#            expr $(”date | awk ‘{print $4}”’|sed “s/^..:\(..\).*/\1/”))”
eventbgn=”$(expr $(”date | awk ‘{print $4}”’|sed “s/:.*//”)*60+
expr $(”date | awk ‘{print $4}”’|sed “s/^..:\(..\).*/\1/”))”
# echo $eventbgn
echo “Please press enter when you have finished to ${event_array[$i]]}.”
read finished
while [ -n “$finished” ];
do
break
done
date

eventend=”$(expr $(”date | awk ‘{print $4}”’|sed “s/:.*//”)*60+
expr $(”date | awk ‘{print $4}”’|sed “s/^..:\(..\).*/\1/”))”
echo
echo “You spent $(($((eventend))-$((eventbgn)))) minutes to $description ”
echo “thereby accomplishing your ${event_array[$i]]} activity.”
echo “You spent $(($((eventend))-$((eventbgn)))) minutes to $description thereby accomplishing your ${event_array[$i]]} activity.” >> /mnt/home/logfile
echo “Comments on success in achieving goal?”
read goalmet
echo $goalmet
count=$(expr $((count+1)))
echo -n $count “.  ”
case “$i” in
0)
echo “It’s ok.  We all have bad days.”
;;
1)
echo “Dog walk and  dog care done.  Your dogs say: “I love you””.
;;
2)
echo “It feels good to be smarter.”
;;
3)
echo “Mother Nature embraces you!  Thank you for doing your part to care for her.”
;;
4)
echo “Good job telling the computer what to do!”
;;
5)
echo “Find people that treat you well, and try to care for those who don’t.”
;;
6)
echo  “Work out done.  Your body says thank you for caring!”
;;
7)
echo  “Clean up done.  Good job!!!!!”
;;
8)
echo “You are making a positive difference in the world.”
;;
9)
echo “Building challenges your relationship with reality.  Do it with excellence, pride, and attention to detail.  Rest.”
;;
10)
echo “Write to remember.  Write to explore.  Write to be the master of your own universe.”
;;
11)
echo “Music and art can make the world beautiful.”
;;
12)
echo “There is always something new to explore.”
;;
esac
done
finished=”done”
return
}
if [ -e “/mnt/home/logfile” ]
then
echo “Old logfile exists.  Do you want to append to it? (y or n)”
read append_ans
if [ $append_ans == “n” ]
then
rm /mnt/home/logfile
fi
date >> /mnt/home/logfile
fi
description=””
event_array=(“nothing” “dog work” “studying” “environmental work” “computer activities” “personal relationship activities” “exercising” “cleaning up” “world improvement” “building work” “writing” “music/art activities” “exploring”)
num_events=13
date
echo “Today is a brand new day.  How would you like to start?”
echo ”                       ”
choice=(1 2 3 4 5 6 7 8 9 10 11 12)
neworder
execute_events
# while  [  -n $finished -o $description == “r” ];
#while [ “$description” != “” ]
#   do
#       case “$description” in
#              r)
#              echo “Working on events.”
#              execute_events
#              ;;
#              R)
#
#              esac
#   done
echo “Program completed.  Goals for the day achieved.  VERY WELL DONE.”
#
#
#
#

——————————————————————————–

random_set.c

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
MAX_ALLOWED=10000;

/*”random_set.c a program to pick n random integers between  two integers*/
/*entered as parameters submitted by livedoggb 3/03/2011 */
 
main(int argc, char *argv[4], char *envp[]){
/* parameters to the program are # of random integers desired, low int range inclusive, high int range inclusive */
/* command should be “random_set 5 1 12” for 5 random numbers between 1 and 12.*/

   int i, num_ran, min=1, max=12, rn[MAX_ALLOWED], sd;
   int random1(int min_value, int max_value);
  
   srand(sd);
 
/*   printf(“Enter the maximum value of random number (up to %d)”, MAX_ALLOWED);
   scanf(“%d”,&max);*/
   num_ran = atoi(argv[1]);
   min = atoi(argv[2]);
   max = atoi(argv[3]);
     
   for (i=0; i<num_ran;i++) {
       rn[i]=random1(min, max);
          printf(“%d “, rn[i]);}
          printf(“\n”);
   return 0;
};
   int random1(int lowint, int highint)
   {
  
   int r, x;
   float r_real, rmax=2100598400.0*1.022400;
   r = random();
   r_real=r;
   highint=highint-lowint;
   x = ((r_real / rmax)*(highint+1)+lowint);    
   return x;
};

———————————————————————————

random_order.c

#include<stdio.h>
#include<stdlib.h>
MAX_ALLOWED=10000;

/* “random_order.c” a program to take as input a list of integers and permute them using a mapping
algorithm ———– submitted by livedoggb 3/9/2012 */
 
main(int argc, char *argv[MAX_ALLOWED], char *envp[]){

   int num, sd, a,c, counter, missing_value_index, n, junk, max, ar[MAX_ALLOWED], orig_array[MAX_ALLOWED], init_values[MAX_ALLOWED], count[MAX_ALLOWED], temp1[MAX_ALLOWED], temp2[MAX_ALLOWED], values[MAX_ALLOWED];
   int randomize(int num_values, int max_value, int *count, int *init_values);
   int bin_analyze(int max_value, int num, int *init_values, int *count);
   int map(int *temp1, int *temp2, int n, int missing_value_index);
   int permute(int *count);
 
/*   printf(“Enter the number of random numbers you want “);
   scanf(“%d”,&n);*/
   n=argc-1;
/*   printf(“The number of values needing randomization is: %d\n”, n);*/
  
 
/*   printf(“Enter the maximum value of random number (up to %d)”, MAX_ALLOWED);
   scanf(“%d”,&max);*/
   max=MAX_ALLOWED;
 
/*   printf(“Enter the values of the 5 numbers you want to randomize:\n”);*/
      for (c=1; c<=n; c++) {
    ar[c]=atoi(argv[c]);
/*    printf(“init_values[%d]=%d”, c, ar[c]);*/
   };
/*   printf(“\n”);
  scanf(“%d %d %d %d %d”, &ar[1], &ar[2], &ar[3], &ar[4], &ar[5]);
   printf(“The 5 numbers are: %d %d %d %d %d”, ar[1], ar[2], ar[3], ar[4], ar[5]);*/
 
   num=n;
   srand(sd);
/*   randomize(n, max, count, init_values); */
  
   for (c=1; c<=num; c++) {
    init_values[c]=ar[c];
   };
  
  
   for (c=1; c<=num; c++){
    orig_array[c]=init_values[c];
   };
/*   bin_analyze(max, num, init_values, count);*/
   /* randomize picks n numbers between 0 and max, */
   a=num;
   counter=1;
  
   while (a>0){
   missing_value_index=randomize(1,n, count, temp2); /*pick 1 # between 0 and n from a set of init_values*/
   /* randomize picks 1 number between 0 and n, and returns
    the value of that position in the array init_values*/
   if (missing_value_index==0){missing_value_index++;};
/*   printf(“\n %d is missing value index before map.\n”, missing_value_index);*/
   map(temp1, init_values, n, missing_value_index); /*take missing_value out of set*/
   values[counter]=init_values[missing_value_index];
/*   printf(“picked value is values[%d]=%d \n”, counter, values[counter]);*/
   counter++;
/*   printf(“The rest of the numbers are:\n”);*/
/*    for (c=1; c<n; c++) {
     printf(“%d “,temp1[c]);
   }; 
    scanf(“%d”,&junk);*/ 
/*   printf(“Init_values array after reassignment should be temp1: “); */
   for (c=1;c<n; c++) {
     init_values[c]=temp1[c];
/*     printf(“%d “, init_values[c]);  */
   };

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s