Until you have given a pair of underwear to a person with Alzheimer’s do you realize what a complex piece of clothing they really are. There are so many combinations of holes, directions and appendages that can go in them. Just with the legs along (which is the appropriate way to begin to wear underwear), there are 36 permutations of legs vs holes combinations, and that not even taken into consideration forwards and back. I have yet to see them put on the arms (which is where socks often go), but I have seen them used as a headpiece. Of course, that is something I also remember from my high school/college partying days. So next time you put on your underwear correctly, pat yourself on the back for a job well done! Especially if you are a man and you have the extra pocket in the front, which might lead to additional complexities and challenges.
Ice Cream, Alzheimer’s and a Pandemic
Squirrel vs. Bike
Today, while riding my bike, a squirrel darted out in the road ahead of me about 20 yards away, so well out of h. arms way However, it stopped dead in its tracks in the middle of the road. Without much though I aimed my front wheel right at it figuring that it was either going to go forward or go back, but rest assured, it would not be in the same spot that I was currently aiming at.
As I drew closer, the squirrel did not move! Proportionately my confidence that it would move started to fade as my anxiety about running the little guy over increase. I could feel a rush of adrenaline suggesting I act. Memories of running over a squirrel with my bike a few years ago flashed through my mind, as well as the horror of watching it run off into the bushes dragging its now broken hind legs behind it. Certainly, I owe a karmic dept to that poor soul as it surely lived out the rest of its shortened life suffering.
I did not want that to happen to this creature that was still motionless with the doom of a speeding bike drawing rapidly closer to it. I made the quick decision to veer left to the stern of the squirrel. Squirrels, as you may know are very quick and can turn on a dime to dart in any direction. Just because its front was facing the other way was no guarantee that it would head in that direction, but that was the gamble that I took in that moment.
The rest of the bike ride was uneventful. I finished the 26 mile loop in just a little over two hours … slower than I’d prefer, but at least I was free of guilt as the squirrel and I chose alternate paths that did not test the theory that two object cannot occupy the same space. That experiment, i can try another time … in a safe and controlled environment.
Trifecta, Comedy of Errors
My New Year started with a trifecta of comedy of errors. I got up early to pilot 100 swimmers from Alcatraz, the annual South End Rowing Club New Years Day Alcatraz. I’ve swum it a couple times during the hey-day of my San Francisco Bay swimming. Now I mostly just pilot swims.
My wallet had been missing for a few days. I could log in to my various financial accounts and could tell that there was no account activity. I just put it somewhere and could not remember where. I did a quick search around my house but did not turn anything up. I would do a more thorough search later. I could not think of anything I would need it for, but my sister was concerned if I was driving around without my license that I might get in trouble, and yes, I did wind up having to talk to a cop later in the day.
I also did not have my cell phone charger cable. It disappeared out of my hands the other day. This is the one I use in my car. It’s one of those fancy ones that retracts and is the one I like to use in the car. I took it out of my car and had it in my pocket the other night and then it just disappeared when I was putting it back in the car. Maybe it fell on the street or under the seat, but I looked everywhere. It’s one of those silly minor things that makes me sad to have lost it. I have yet to admit defeat and put one of the other many charger cables that I have at home back in the car.
I had 100% charge on my phone as I left. I figured that would be enough even if I were taking lots of pictures or the swim out on the bay.
The swim went off without a hitch … well without a hitch relevant to this story. I took many pictures while keeping the swimmers safe. By the end of the swim, I had 40% charge on my phone. This was still plenty to get me home. It was only an hour drive.
I had a little extra time before I had committed to being home so elected to swing by our rental unit in the City. We are doing some renovating due to a fire. I wanted to see what work had been done last week.
Because of the renovating, we have a lockbox outside with keys to the units that we are renovating for the various contractors. What I discovered when I arrived is that the lockbox had been missing. In retrospect, it was not too smart to attach it to the garage door handle, which was easily kicked off. A missing lockbox meant the building and apartments were compromised.
OK, missing wallet and the cell phone charger are a part of the trifecta comedy of errors. The break-in was not. One of the apartments was ransacked and items were stolen. That was when I called the police, all the while thinking about my sister’s warning of getting caught driving without my license. When the officer asked me for my ID, I just explained that I didn’t have it. He just took my information verbally.
By the time I was done at the apartment, all the texts and phone calls, my battery was at 1%. While waiting for the police I actually hopped in the car to go to the local drug store to purchase a charger but quickly remembered, I had no wallet! You can see where this is going! I asked the tenant, whose apartment was ransacked if she had a charger. “Yes,” she said and went to go get it. Well, let’s just say it is now on the list of items that got stolen. I really didn’t need a phone for the ride home … so I thought.
The missing wallet and dead phone, two of the legs on the trifecta comedy of errors. What is the third?
I have a modern car with digital readouts. I usually keep it on display for average miles per gallon. I like to get it at 27. However, when I get close to an empty tank, I switch it over to “Cruising Range,” that tells me how many miles I have left on the tank of gas. When I left this morning it was at 60, which is more than enough to get to the City and back. I like to fill up at the Safeway in Vallejo as it is less expensive and figured I’d hit it on the way home. With the extra trip to the apartments, however, the display was now at 19 as I started my trip home. I might be able to make it to the Vallejo Safeway but had better stop for gas just to be on the safe side. I knew the best stations on the way.
“Oh, s#$&,” I thought as I started to pull up to the gas station, “I don’t have my wallet!” I looked at my phone, which was now dead. I fumbled around the car looking for a lost $5 bill that might be there. There was about 40 cents in change. That would not help! I continued driving. The trifecta complete!
The good news is that the trifecta jogged my memory enough to remember where my wallet was. When I stayed the night at my father’s house the other night, I put it on the bookshelf. I remembered putting it there, but I did not remember removing it when I left. I’m sure it must still be there. This was perfect because that is where someone was who could come rescue me if I ran out of gas. If I could call! I most likely would run out of gas.
The adventurous side of me wanted to try to make it home, but the practical side of me thought I should just find a safe place and try to call … but no phone. It’s better than being stuck on the side of the road … with no phone. “What are my options,” I thought. “Starbucks!” Someone at Starbucks will have a charger. There are even some Starbucks that have wireless charging stations. If I found someone kind enough to charge my phone I could buy them a coffee with my Starbucks app! All the things we take for granted with all our creature comforts and technology. Funny, I didn’t even think of a paid phone … if they still exist. I had 40 cents in change. Or, what else would have people done in the “old” days? Going into a business and borrowing a phone. These things never crossed my mind.
As I drew near to Starbucks I saw a Best Buy coming up on the right. “That’s a better option,” I thought. Across the street from Best Buy was an AT&T store. Somewhere, I was going to be able to get my phone charged! Best Buy came through. The kind folks at the mobile phone center plugged it in for me. I waited until it got to 5% before calling my brother, who lives at my father’s. “Guess where I am?” I asked. As my partner owning the apartments (along with my father), I had been keeping him apprised of the situation with the robbery and my phone battery. I told him that he’d never guess so volunteered the information, “I’m at the Best Buy in Pinole getting my phone charged.” Then I asked, “Is my wallet on the bookshelf in the spare room?” “Yes,” he replied after going back to the room to check. “OK, could you bring it to me. I ran out of gas.” We laughed.
Soon, my wallet and I were back together, phone charged to 25% and a gas station down the road. I coasted in on fumes, but was soon back on full!
Phone charger, wallet, and gas … don’t leave home without them!
Voice From Beyond
My friend Danny passed away way too young at the age of 24. He drove off an embankment and that was the sad end for him. A while after I was in my trailer where I lived in Arcata, CA when the phone rang. “Hey man it’s Dan,” the voice on the line said. I don’t know any other Dan and clearly from the tone he not only expected me to know him, but expected me to be surprised too. I can’t describe the feeling of getting a phone from the “other side.” It felt like the blood rushed out of my body. I’m sure I turned as “white as a ghost” as the expression goes … as white as the ghost that apparently was speaking to me.
We often talk about ghosts and the after life, do we believe or not, but for the most part we do not know. Here I was facing the prospect of moving from the whelm not knowing to having an actual experience. What will become of me now? I’d be that crazy guy swearing he knows and has talked to the dead, perhaps delivering messages to his family. My world was about to change for sure … one I replied. There was a chilling cold accompanying the vacant feeling of blood.
“What? Danny?” I managed to say rather meekly. “No, Ken, man. It’s Ken,” came a reply of relief. My consciousness came back to reality. It was my old buddy Ken from when I lived in Maine. He was still alive and kicking … and perfectly capable of making a phone call. It felt good to get the blood circulating through my body again. However,it would have been good to talk to Danny one more time.
How the Niagara Falls Formed
I left Niagara Falls without knowing much of how it was formed, so I did my own research and learned some very interesting things:
Niagara Falls was formed around 11,000 years ago when the receding glaciers carved out the great lakes.
The melt water began to flow over the Niagara Escarpment which is a wonder in itself. It is a long cliff that extends 1,000 miles from east-central Wisconsin to Upstate New York. It forms the northern boundary of Lake Michigan and Huron and Southern boundary to Lake Ontario. It has existed for 400 million years and is believed to be the edge of an ancient basin, the Michigan Basin.
When the glaciers retreated the escarpment was exposed and the melting water water began to flow over its edge. The water eroded the softer rock at the base of the escarpment wearing it away until the harder rock at the top of the cliff caves away. This keeps the flowing water flowing in a vertical fashion (a falls) rather than eroding into a cascade as the falls carved its way southward along the Niagara River. Over the 11,000 years that falls existed it carved the basin, moving it 6.8 miles southward from its original location at Lewiston, New York.
If you do the math that comes to and average of about 3 feet 4 inches per year, however while the water was flowing the erosion was probably greater. You see, after the falls was formed, for a few thousand years there was a time that it ceased to exist.
There is evidence that 8,000 years ago the water levels of the Great Lakes were lower by about 40 to 50 meters. During that time Niagara Falls would have dried up until the water levels rose again.
At the bottom of Lake Huron in the Bruce Peninsula there are the remnants of many waterfalls, many of these falls were greater than Niagara Falls, that used to exist during the time when the water levels were low.
Today the erosion caused by the Falls is greatly reduced by human intervention, mainly channeling about 75% of the water for hydroelectric power production.
Information for this article was gather from the following sources:
https://en.wikipedia.org/wiki/Niagara_Escarpment
http://onmilwaukee.com/visitors/articles/niagaraescarpment.html
https://en.wikipedia.org/wiki/Bruce_Peninsula
https://en.wikipedia.org/wiki/Michigan_Basin
http://historyoftheearthcalendar.blogspot.com/2014/03/march-12-michigan-basin.html
CORS POST to AWS S3 using PHP and AJAX
I’m going to post this here in case it helps someone down the line. I spent days trying to get this to work including countless hours with AWS (Amazon Web Services) support, who go above and beyond to try to help. Note: I modified the code a bit from my working, live example, so the code below is untested. There may be a few minor bugs that I will let you work out :-) And, sorry for the lack of formatting on the code below.
The problem is to upload a file from an HTML form on a website and have it go directly to an AWS S3 Bucket. Sounds easy, right? Here are the issues:
- The POST upload will work directly, however when we put the request in AJAX we run into issues with the denial of Cross Origin Requests Sharing (CORS). This means a request from one domain is not accepted by a different domain … unless it is approved on the receiving domain’s server configuration.
- The request requires a policy and a signature that need to be generated on the requesting server. The signature includes information (filename) of the file being uploaded, so it needs to be generated AFTER the file is selected. Unless the filename is set in advance.
- The secret access key needs to be secure so the public may not see it.
- The AJAX upload POST request needs to be in a particular format.
The solutions:
- A few years ago AWS began to allow CORS on the S3 Buckets. THis needs to be configured. I’ll show you how to do in in a bit.
- I found many examples how to do this with Rails, but not with PHP. The policy and signature may be done with AJAX requests to PHP scripts. I’ll show you how i did this in a bit.
- The secret access key may be hidden in the PHP scripts as mentioned above.
- I’ll show you this. I found it in this StackOverflow question here: http://stackoverflow.com/questions/11240127/uploading-image-to-amazon-s3-with-html-javascript-jquery-with-ajax-request-n. I modified it a bit to work with PHP.
Here is the code below:
Enabling CORS on your S3 Bucket
Log into your AWS account and browse over to S3. Select the bucket that you wish you upload to and click on “Properties.” Open the “Permissions” area. Click on “Edit CORS Configuration.” There you will see the CORS Configuration. Change it to the code below substututing [YOUR_FULL_DOMAIN] for your full domain name. This si the domain from where the POST request will originate. You may use one wildcard (ex: http://*.yourdomain.com). You may also just use a straight wildcard here * to open it up to all origins. This is helpful for testing and debugging.
<?xml version=”1.0″ encoding=”UTF-8″?>
<CORSConfiguration xmlns=”http://s3.amazonaws.com/doc/2006-03-01/”>
<CORSRule>
<AllowedOrigin>[YOUR_FULL_DOMAIN]</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
PHP Scripts to Generate Policy and Signature
I use two different scripts. Each will be called with an AJAX request. These will be separate PHP files on your server:
PHP to generate the policy. (I saved this as filename: php/s3_upload_create_policy.php):
<?php
$key = $_GET[‘key’]; // This is the filename as it will be uploaded to S3
$type = $_GET[‘type’]; // TThis is the file typedate_default_timezone_set(‘America/Los_Angeles’); // Update to your time zone
$now = strtotime(date(“Y-m-d\TG:i:s”));
$expire = date(‘Y-m-d\TG:i:s\Z’, strtotime(‘+ 10 hours’, $now)); // This sets the policy expiration time. I select 10 hours from now, but it can be much less. Keep in mind time zone differences from your instance time to the time of the AWS region that your bucket is located.$aws_access_key_id = ‘[YOUR_ACCESS_KEY_ID]’; // Substitute for your access key ID
$bucket = ‘[YOUR_S3_BUCKET]’; // Substiture for your S3 Bucket name (ex: my_aws_bucket)$acl = ‘public-read’; // if you prefer you can use ‘private’
$url = ‘http://’.$bucket.’.s3.amazonaws.com’;$policy_document=’
{“expiration”: “‘.$expire.'”,
“conditions”: [
{“bucket”: “‘.$bucket.'”},
[“starts-with”, “$key”, “‘.$key.'”],
{“acl”: “‘.$acl.'”},
[“starts-with”, “$Content-Type”, “”]
]
}’;// create policy
$policy = base64_encode($policy_document);echo $policy;
?>
PHP to generate the signature. (I saved this as filename: php/s3_upload_create_signature.php):
<?php
$policy = $_GET[‘policy’];
$aws_secret_key = ‘[AWS_SECRET_ACCESS_KEY]’; // Substitute for your secret access keyfunction hmacsha1($key,$data)
{
$blocksize=64;
$hashfunc=’sha1′;
if (strlen($key)>$blocksize)
$key=pack(‘H*’, $hashfunc($key));
$key=str_pad($key,$blocksize,chr(0x00));
$ipad=str_repeat(chr(0x36),$blocksize);
$opad=str_repeat(chr(0x5c),$blocksize);
$hmac = pack(
‘H*’,$hashfunc(
($key^$opad).pack(
‘H*’,$hashfunc(
($key^$ipad).$data
))));
return bin2hex($hmac);
}function hex2b64($str)
{
$raw = ”;
for ($i=0; $i < strlen($str); $i+=2)
{
$raw .= chr(hexdec(substr($str, $i, 2)));
}
return base64_encode($raw);
}$signature = hex2b64(hmacsha1($aws_secret_key, $policy));
echo $signature;?>
Page Script
And finally we need the HTML page script. This includes the javascript and the form.
Here is the javascript. This is mainly copied from the StackOverflow question mentioned above, with a few minor tweaks including nested AJAX requests to the PHP documents above to generate policy and signature. You will need JQuery as well. I’m using 2.1.3:
<script type=”text/javascript” src=”/js/jquery-2.1.3.min.js”></script>
<script type=”text/javascript”>function uploadFile() {
bucket_name = [YOUR_AWS_BUCKET_NAME]; // Substitue with your bucket name
access_key_id = [ACCESS_KEY_ID]; // Substitue with your Acess Key IDvar file = document.getElementById(‘file’).files[0];
var fd = new FormData();var key = ‘uploaded/’+file.name;
var type = file.type;theSource = ‘/php/s3_upload_create_policy.php?key=’+key+’&type=’+type;
var xmlhttp;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else {// code for IE6, IE5
xmlhttp=new ActiveXObject(“Microsoft.XMLHTTP”);
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
policy = xmlhttp.responseText;theSource2 = ‘/php/s3_upload_create_signature.php?policy=’+policy;
var xmlhttp2;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp2=new XMLHttpRequest();
} else {// code for IE6, IE5
xmlhttp2=new ActiveXObject(“Microsoft.XMLHTTP”);
}
xmlhttp2.onreadystatechange=function() {
if (xmlhttp2.readyState==4 && xmlhttp2.status==200) {
signature = xmlhttp2.responseText;fd.append(‘key’, key);
fd.append(‘acl’, ‘public-read’);
fd.append(‘Content-Type’, file.type);
fd.append(‘AWSAccessKeyId’, access_key_id);
fd.append(‘policy’, policy);
fd.append(‘signature’,signature);fd.append(“file”,file);
var xhr = new XMLHttpRequest();
xhr.upload.addEventListener(“progress”, uploadProgress, false);
xhr.addEventListener(“load”, uploadComplete, false);
xhr.addEventListener(“error”, uploadFailed, false);
xhr.addEventListener(“abort”, uploadCanceled, false);xhr.open(‘POST’, ‘https://’+bucket_name+’.s3.amazonaws.com/’, true); //MUST BE LAST LINE BEFORE YOU SEND
xhr.send(fd);
}
}
xmlhttp2.open(“GET”,theSource2,true);
xmlhttp2.send();}
}
xmlhttp.open(“GET”,theSource,true);
xmlhttp.send();}
function uploadProgress(evt) {
if (evt.lengthComputable) {
var percentComplete = Math.round(evt.loaded * 100 / evt.total);
document.getElementById(‘progressNumber’).innerHTML = percentComplete.toString() + ‘%’;
}
else {
document.getElementById(‘progressNumber’).innerHTML = ‘unable to compute’;
}
}function uploadComplete(evt) {
/* This event is raised when the server send back a response */
alert(“Done – ” + evt.target.responseText );
}function uploadFailed(evt) {
alert(“There was an error attempting to upload the file.” + evt);
}function uploadCanceled(evt) {
alert(“The upload has been canceled by the user or the browser dropped the connection.”);
}</script>
And finally here is the HTML. This is mainly copied from the StackOverflow question mentioned above:
<form id=”form1″ enctype=”multipart/form-data” method=”post”>
<div class=”row”>
<label for=”file”>Select a File to Upload</label><br />
<input type=”file” name=”file” id=”file”/>
</div>
<div id=”fileName”></div>
<div id=”fileSize”></div>
<div id=”fileType”></div>
<div class=”row”>
<input type=”button” onClick=”uploadFile()” value=”Upload” />
</div>
<div id=”progressNumber”></div>
</form>
The last mystery will be how to get the Access Key ID and Secret Access Key. This is done in AWS’s IAM service. I will not go into detail. You need to set up an IAM user that has access to the S3 Buckets. I did this a long time ago and do not have the specific steps.
Raccoon Communication
I woke up early this morning. After making use of the time to get a little work done, I lay myself down to try to sleep a little bit more. It was working too, however just as I was about to doze off I heard a strange sound … like a cooing. I discounted it at first, but the cooing persisted. It was coming from outside, I could tell, so I wasn’t worried about it. I knew it was likely a raccoon. As long as it didn’t find its way through the cat door and inside to the cat food, we won’t have any trouble. There hasn’t been a raccoon invasion in a long time. Until now I had not known if they had just not been around or if they had given up trying to get through the cat door. I used to block it off every night since the last invasion. However, I had grown lazy about it after a month or so of consistent cat door closure and stopped doing it. Six or so months had past without an incident. I, as well as the cats, have been happy about that.
The cooing outside continued. Sometimes closer, sometimes at a greater distance. I had to investigate, and I looked out the window into the dark street. I could hear the cooing across the street. Then I got a visual and saw the critter running down the sidewalk. The silouette definitely looked like a raccoon, but I was not sure. I watched as it crossed the streets, up and down, back and forth. Then into our yard where it climbed up the tree. I had to go out to investigate, and I put on my robe.
I turned on the porch light and cracked open the front door. I heard nothing so walked on out onto the lawn. Then, I heard the rustling of the tree and the scampering of the critter as it ran away. That would have put an end to my raccoon adventure for the night, had it not been for my curious and humorous mind. “What strange behavior,” I thought, for a creature of the night … the scampering back and for and the constant chattering. Wouldn’t a thieving animal want to be more stealthy as it went about its mission? The only thing that I could think of is that it had a partner in crime and had been separated from it. It was running around looking for it … back and forth, calling out to its friend “coo, coo.” No, the poor raccoons did not have the convenience of cell phone technology to text each other, “Where the f$#% are you.” Or did they? Perhaps it was running back and forth and up the tree trying to get the best signal. The cooing … the phone seeking out a signal. Raccoon Cellular is just not that strong in Southampton, Benicia.
It’s Not the Truth …
“It’s not the truth. It’s what I believe to me the truth.” Huh? Here we are distinguishing between the truth and what one believes to be the truth. OK, people have a hard time telling the difference. To compare the truth with a belief about the truth is like comparing a painting of a landscape with the actual landscape. Even to most accurate painting is going to have some variation. On top of that, the canvas is just not big enough to include the entire landscape. A belief is the canvas for which the person paints their estimation of the landscape of truth. It will never be 100% accurate, but it gives us somewhere to roam, otherwise we only will roam within our immediate surroundings.
On a simple level, I have to believe that there is a roadway, a bridge and that my car is in the driveway before I will attempt to go out the front door and drive to another City. Those beliefs are based on my experience of reality. However I have not experienced everything. On each journey, I will add more to those beliefs. Each time expanding the beliefs a fraction of an inch closer to reality.
I must be humble to know by beliefs will never 100% be the truth about reality. And, one piece of new information may change everything.
A Real Abbott and Costello Moment
The scene: Mom & Jay watching the Giants’ baseball game. Mike Krukow and Duane Kuiper are announcing:
Krukow: He does that a lot like Bobby Bonds always did.
Mom (look of confusion on her face): Bobby Bonds? Who is Bobby Bonds?
Jay: Bobby Bonds was Barry Bonds’ father. (Mom still looks confused).
Jay (trying to guess what she is confused about. Sadly, her cognitive abilities have been declining with her age): Barry Bonds was the Giants’ big star that retired a few years ago.
Mom: I know that, but I’ve never heard of Bobby Bonds (she’s trying to put things into perspective)
Mom (here it comes): Who played 1st?
Jay (in disbelieve she just asked that question. I can’t think of how to reply until I just start laughing): They both played left field.
Mom (starts laughing and references Abbott & Costello): Who played first (laughing).
She meant who played in Major League Baseball before the other.