Friday, September 19, 2014

A software developer goes to Nome

The Town



In the evening of August 22, I stepped off a plane onto the tarmac of the Nome airport. A life milestone was reached - after many years of dreaming of it, I was finally in Alaska. What brought me, a software developer, to Nome - a place known more for gold and sled dogs than technology?



The purpose of my visit had nothing to do with technology, which was a welcome break from my daily routine. I was the guest of my colleagues David Anderson and Paul Juergens, biologists for The Peregrine Fund. They were there to research Gyrfalcons. I had been invited to share the Alaska experience and photograph their efforts.


Nome is a town of about 3,500 people on the Seward Peninsula. Access is possible only by air or water. This isolation and distance from manufacturing results in high prices - more than $4 for a dozen eggs, $5 for a glass of orange juice at the cafe, and gas is over $6 per gallon.  However, there are three roads extending from Nome out into the tundra, and these are key to the research project.  The Teller, Council and Kougarok roads lead into some of the most unique and beautiful country I have ever seen.


It was interesting to me to drive through areas I had learned about in history classes. The road to Safety Sound is the final leg of the Iditarod sled dog race.  We passed by the winter trail markers used in the race and other winter travel, which are wooden tripods with tall poles to ensure visibility in deep snow.  The same area was the site of a late nineteenth-century gold rush on the beaches of the Bering Sea.




The Tundra


Someone once told me that tundra is flat. That isn’t true around Nome. The hills, of varying steepness, rolled on seemingly without end into the Seward Peninsula. This was the first time I had walked on tundra. I had heard it was spongy and difficult to walk on. In many spots, it was indeed. It was unique to watch what appeared to be solid ground give way under my boots, with water rushing in around the toes. After stepping forward, the plant-covered ground rebounded, erasing my boot marks.  


From a distance, the tundra looks barren and featureless. A closer look, though, reveals a remarkable diversity of plant life. Multiple types of berries thrive there, including blueberries harvested by locals and visitors alike. Though it was late in the summer, a few flowers were visible.


The vast wetlands around Safety Sound, where the tundra meets the Bering Sea, appear to be an ideal haven for a multitude of bird species. Unfortunately, during the time of our trip, birds were sparse.  That meant it would take a lot more effort to locate the Gyrfalcons.




The Work


My work as a software developer generally involves sitting long hours at a computer in a comfortable chair, with coffee or other preferred drink easily at hand. Usually, I can adjust the air temperature to whatever I want. Whenever I need to, I can take a break to stretch my legs.  It didn’t take long to discover that biologists’ field work is quite different.


Paul and David search for Gyrfalcons
Starting early in the morning, sometimes with breakfast being whatever could be grabbed and eaten in the truck, we were driving. Each of the three roads took us through different terrain and types of habitat, so each was explored frequently.  One hope had been to locate a concentration of prey species, and therefore Gyrfalcons, on the coast. Evidently due to the mild weather, the passerines and shorebirds had not yet gathered. So, our days were long, filled with driving and checking every dot that might be a falcon.  


The first two days we found Gyrfalcons. While I have seen gyrfalcons used for falconry and education, this was my first opportunity to see them in the wild. Their size, speed and maneuverability is impressive.  The first falcon sighted was nearly captured, but evaded at the last moment. After that, things became more difficult.  The closest encounter we had was when driving out one morning. A Gyrfalcon streaked off the hill above us, crossed our windshield less than 25 yards away, then disappeared into a brushy river channel.


Gyrfalcons often perch on a high point and use their excellent eyesight to spot prey far in the distance. Much time was spent with binoculars and spotting scope inspecting bumps on the skyline as we passed through areas with rocky outcroppings, or gray or white spots on the hills. Some areas have a lot of vertical rocks the same size and shape as a Gyrfalcon. These frequently resulted in the truck coming to an abrupt halt and three sets of binoculars going up. Those rocks earned the name of “gyrrockens” for their annoying resemblance to the birds we were searching for.



The Wildlife


One of my main reasons for wanting for so many years to visit Alaska is the wildlife.  This trip did not disappoint.  Less than 10 minutes outside of town on the first day, two muskox were visible from the road. We saw more muskox throughout the trip.


We saw six species of raptors. In addition to Gyrfalcons, we saw Peregrine Falcons, Northern Harriers, Golden Eagles, Merlins and Rough-legged Hawks. Once we watched a Northern Harrier flush out several ptarmigan, their white wings flickering across the tundra as they tried to reach cover.
Reindeer herd on the Teller road.


Though we never encountered a large concentration of birds, we saw Pintails, lesser Canada Geese, swans, Wheatears, curlews, Sandhill Cranes, jaegers, ravens, and of course gulls.


We saw herds of reindeer many times. They had no fear of us. One day, we had to wait for them to move off the road four times. Their gait is quite different from the deer and elk I am familiar with at home. Their hind hooves kicked out to the sides as they trotted up the road, and they grunted loudly as they finally moved off the road into the tundra so we could pass.


At the time of our trip, salmon were in the rivers to spawn. We saw coho (silver), sockeye, pink, and chum salmon. The sockeyes’ bright red and green coloration was especially memorable. Due to the focus on finding falcons, I had little time to fish. During one of the few and brief roadside breaks, I managed to catch my first silver salmon. It had been in fresh water a long time, and was deep red from kype to tail.


We saw this grizzly bear far up one of the roads out of Nome.
One of the highlights of the trip for me was seeing a grizzly bear. The bear came down a small hill not far off the road, and once it was able to catch our scent, moved quickly away from us. It wasn’t a large bear, but it was the first grizzly I have seen outside of Yellowstone National Park.


By the end of a week, I was ready to return home, to seemingly cheap $3.88 gas and my somewhat predictable daily schedule of computer work. Before I ever got on the plane, though, I was already planning my return to Alaska.

Tuesday, April 30, 2013

Converting Photoshop actions into JavaScript

I have a collection of complex Photoshop actions that I have built.  Now, I am needing to move from actions to scripting to accomplish new tasks in Photoshop.  Since I didn't want to rebuild everything as new scripts, I searched for a tool to recycle my existing actions.

PS-Scripts.com provided a link to a solution.

Running that script in Photoshop CS5 (File>Scripts>Browse) creates .jsx files that replicate the original .atn action files. Now, I can copy relevant sections of JavaScript out and utilize them in my new scripts.

Thanks to xbytor for sharing the solution.

Saturday, January 5, 2013

Problems with Adobe CS2 software activation

I am reconfiguring my computer and need to run my old Adobe Creative Suite 2 Premium software.  After spending time installing it, I received an error that it could not be activated.  A brief search turned up the fact that Adobe recently shut off their activation server for this old version. 

They provided a page with links to download a version of CS2 that bypasses the need for the activation server, but it appears to not provide all the software in CS2 Premium.  I'm not the first to have this issue: http://forums.adobe.com/thread/1114930?tstart=0

I started a separate discussion for Mac CS2 Premium at http://forums.adobe.com/thread/1129934?tstart=30

Thursday, December 27, 2012

Solving erratic mouse behavior in Ubuntu 12.10 inside VirtualBox

My Ubuntu installation within a VirtualBox VM has been nearly unusable due to random, erratic behavior of the mouse cursor. Problems have included:
  •  a click near the middle of the screen activates a button in the launcher on the left side
  •  occasional hits on the exit button of a window, though the cursor was far from it
  •  inability to drag to select text; the selection would jump upward while I was trying to drag down
  •  other dragging operations would create unpredictable and unwanted results

I did research and found these two references:
http://askubuntu.com/questions/202789/cursor-jumps-when-moving-and-some-other-times
https://forums.virtualbox.org/viewtopic.php?f=3&t=51727&start=45

Based on these, I typed the following into the terminal.
sudo apt-add-repository ppa:a7x/bug1041063
sudo apt-get update
sudo apt-get install xserver-xorg-core

My initial tests show this to be a successful fix for the problems listed above.

Monday, November 5, 2012

Dell Optiplex 780 noise after upgrading to Windows 7

I just finished upgrading my Dell Optiplex 780 to Windows 7 64-bit.  The tower was producing a very irritating high-pitched noise after this upgrade.  After a bit of searching, I found this discussion that seemed to match my problem:
http://en.community.dell.com/support-forums/desktop/f/3514/p/19292677/19546282.aspx

I tested the BIOS setting change for C State Control suggested by carl.hobbs and petewitt.  It solved the problem instantly.


Thursday, October 11, 2012

Drupal REST process update

I posted earlier about the problems I have had integrating Drupal 7 REST with an external site.  Since my last post on the topic,  it has been working flawlessly.

Today, though, I upgraded the Drupal site to use Services 7.x-3.2, and configured the site to require TLS for all traffic.

The REST connection died with no explanation.

After an hour of stressful debugging, I found two separate causes:

1. The upgrade of the Services module reset the REST resources settings. I had to re-enable parsing of application/x-www-form-urlencoded  and the node resource. http://stackoverflow.com/questions/8535820/drupal-login-via-rest-server

2. Requiring all traffic to route through https (TLS) killed the PHP cURL methods.  For a debugging quick fix, adding curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); solved the problem. For a better solution, see http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/

Thursday, August 23, 2012

Google Maps API 3 inside jQuery Accordion

I am working on a web page that utilizes multiple JS libraries including jQuery and Google Maps. My map is inside a jQuery Accordion pane, and has been presenting a problem with partial rendering as described on a StackOverflow topic. In my case, the code was configured to initialize the map at the time of the first click on the accordion panel that contained the map. It worked fine, unless the user switched to a different pane then tried to return to the map. Then, it would only draw approximately 1/4 of the map canvas, with the remainder being gray.

In my research, calling google.maps.event.trigger(map, "resize"); was a consistent suggestion, but the first few locations I tried calling it did not work. I finally solved the problem by binding the trigger to the click event of the jQuery Accordion pane, based on an example at essentialwebconcepts.com.

My code:
function triggerMapResize()
    {
    google.maps.event.trigger(map, "resize");
    }

jQuery(document).ready(function() {
    jQuery("#the-accordion").bind('accordionchange', function(event, ui) {
        if (ui.newContent.attr('id') == 'the-pane-id')
            {
            triggerMapResize();
            }
        });
    });
The only remaining problem is that the center of the map changes when the user returns to the map pane after looking at a different pane.  I started a topic on SO for this issue.

Update August 24:
Several changes were required to get this to work on all browsers including IE. IE failed upon page load when I was trying to initialize the map. Originally I was using window.onload = function () { initialize_map(); } but that resulted in a vague IE error.

I added code to capture the map's center LatLng when the user moves the mouse outside the map canvas, and more code to move the center to that point upon returning to the map.

          var map=null;
    var currMapCenter = null;

    jQuery(document).ready(function() {
    jQuery("#accordion").bind('accordionchange', function(event, ui) {
    if (ui.newContent.attr('id') == 'region-list')
    {
    if(map==null) {
    //first load; call map initialization
    initialize_map();
    }
    triggerMapResize();
    }
    });

    function initialize_map() {
   
    //do initialization here...
   
    google.maps.event.addListener(map, 'mouseout', function() {
    currMapCenter=map.getCenter();
    });
    }

    function triggerMapResize() {
    google.maps.event.trigger(map, "resize");
    map.setCenter(currMapCenter);
    }

A side note about another problem I ran across in IE8 that has limited documentation online: When creating LatLng arrays, double-check syntax to be sure there is no comma after the final element. While the map looked perfect in standards-compliant browsers, in IE8 each polygon had a segment extending up to near the North Pole.

var polygonPoints= [
        new google.maps.LatLng(24.3250983277945,-79.4028109345145),
        new google.maps.LatLng(48.9377507851552,-142.984008088915),
        new google.maps.LatLng(37.9247004907078,-131.891417410329),
        new google.maps.LatLng(29.8055038628199,-122.143142289543),
        new google.maps.LatLng(21.6909424687438,-114.135809333967),
        new google.maps.LatLng(24.3250983277945,-79.4028109345145),
        ];

This mistake cost me an hour of confusion. Finally I found a discussion mentioning trailing commas with Google Maps in Internet Explorer and discovered the improper extra comma at the end of each array.   It was caused by creating the LatLng object using concatenation in Excel without manually trimming the last value.

Saturday, August 18, 2012

The power of introverts



I just finished reading Quiet, by Susan Cain. It is by far the best book I have read in a very long time. I can relate completely to her description of extroversion being prized by society, and quietness being condemned.  I have lived with such condemnation my entire life. I have even sought medical treatment to be "cured" of the affliction. This book made me aware that I am not alone in this. It has also given me a new perspective on my place and value in society.
 
This is worth sharing:
In a culture where being social and outgoing are prized above all else, it can be difficult, even shameful, to be an introvert. But, as Susan Cain argues in this passionate talk, introverts bring extraordinary talents and abilities to the world, and should be encouraged and celebrated.


I am very thankful to have finally found employment in an organization that has other people like me, and values my contribution and strengths rather than coercing me to be something I am not.  If only other groups of people in my life could be as understanding.

Wednesday, August 8, 2012

Capturing Facebook Atom feed via PHP cURL

I have been working on how to retrieve the RSS feed of our company Facebook page for inclusion in our website. Thanks to the answer by Francois Deschenes on a Stack Overflow topic, I have the beginnings of a functional solution:

$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL,"https://www.facebook.com/feeds/page.php?format=atom10&id=111111111111111"); curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT,5);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl_handle, CURLOPT_USERAGENT, array('User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Safari/534.45'));
curl_setopt($curl_handle, CURLOPT_VERBOSE, true);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);

if (empty($buffer))
    {
    print "Sorry, request failed.";
    }
else
    {

    (do stuff with the feed)
           }

I will update this posting as this project progresses.


Wednesday, July 25, 2012

Google Maps API multiple markers and infowindows

I was having trouble with binding InfoWindows to markers. No matter which marker was clicked, the InfoWindow for the last marker to be created was displayed.  I found the answer to the problem here:
http://stackoverflow.com/questions/2357323/trying-to-bind-multiple-infowindows-to-multiple-markers-on-a-lgoogle-map-and-fail

Simply creating a separate function to add the event listener solved the problem.

Wednesday, July 18, 2012

January Drupal frustration solved.

I posted on January 16 about problems integrating Drupal 7 with an external website. I had to set it aside and work on other things until this week. I finally located the cause of the problem today. As are most time-consuming problems, this had a simple solution. I just had to step away from it long enough to reset, then look through the code with a fresh outlook.

The culprit in this case was running the Drupal login function targeted at http://www.mydomain.com, but then trying to retrieve the Drupal node from http://mydomain.com. Since the domain didn't match, my session auth failed.

Sunday, May 27, 2012

Quotes from James Dyson

I recently read an interview with Sir James Dyson. There were two quotes from him in it that really struck a chord with me.

"I don't care how long things take. Failure is to be celebrated - that is how we learn ... We invest in and rejoice in failure, and we stick at it. I learned from each of my mistakes. That's how I came up with a solution."

Many people think I am a perfectionist, but I don't see myself that way. Things must be as good as possible - but that doesn't require perfection at stage one. This quote states my thoughts about software development and programming very well:

"'Perfect' is in fact the completely wrong word to use. You start with a goal and you make the best possible version you can make at that moment. You give the customer the best available at that moment, and then you set another goal and start working on it again." 

He may invent and engineer vacuums and other mechanical devices, but his words make good sense for software architecture as well.




Wednesday, May 16, 2012

JavaScript references

I just found Chris Shiflett's April 26 posting with a great list of references for JavaScript. The first one I have started reading is "JavaScript for PHP Developers" by Stoyan Stefanov. It is one of the most clear and concise descriptions I have found to date as I try to apply my knowledge of other programming languages to JavaScript.

Thursday, April 19, 2012

Avian neighbors

I was able to telecommute today. The weather was perfect and the birds were active. I kept the window open and enjoyed the fresh air and bird songs drifting in.

I kept my camera by my computer and got a few photos of my avian neighbors on the feeder outside my window and in the tree.





Saturday, April 7, 2012

Opinions

Thought for the day: "Opinions have caused more ills than the plague or earthquakes on this little globe of ours." - François-Marie Arouet de Voltaire, 1694 – 1778.

How true.  One of the things I enjoy about writing software is that it involves solely logic and math, in a highly creative manner.

The effectiveness of a UI is certainly subject to opinion, and the methodology used in coding could be debated as well. However, the inner workings of a program are immune to such problems. It either works, or it doesn't.

My work, in a way, is an escape from the pressures of society, in which ignorant prejudices frequently trump reality.

Wednesday, April 4, 2012

The waste of free time

I am currently reading Flow by Mihaly Csikszentmihalyi. It is very interesting - many things I have never thought of, along with many things that make me say "of course!"

Page 162 contains the most concise and clear conveyance of my views that I have ever seen. In part: "The tremendous leisure industry that has arisen in the last few generations has been designed to help fill free time with enjoyable experiences... instead of using our physical and mental resources to experience flow, most of us spend many hours each week watching celebrated athletes playing in enormous stadiums. Instead of making music, we listen to platinum records cut by millionaire musicians...This vicarious participation is able to mask, at least temporarily, the underlying emptiness of wasted time. But it is a very pale substitute for attention invested in real challenges...The energy that could be used to focus on complex goals, to provide for enjoyable growth, is squandered on patterns of stimulation that only mimic reality...Mass leisure, mass culture... are parasites of the mind. ... Their purpose is to make money for someone else. If we allow them to, they can suck out the marrow of our lives, leaving only feeble husks... 'The future,' wrote C.K. Brightbill, 'will belong not only to the educated man, but to the man who is educated to use his leisure wisely'."

Thank you, Dr. Csikszentmihalyi.

As I reach the years of my upper thirties, I am increasingly needing to find ways to understand myself better. It is very helpful to find expressions of others who have already been in the place I find myself now.

Back to something more challenging than typing a blog post...

Thursday, March 15, 2012

JS OOP and kestrel nest box research

Today's goal is to implement JavaScript objects.  I am familiar with OOP in Flex(ActionScript), PHP and other languages from years ago. However, JavaScript's lack of classes will require some re-routing of my neural circuitry.

I am starting my research with these two articles by Douglas Crockford:

The first object I have to create is to represent a kestrel nest box. (Want to build one? - A real box, not a JS object to represent one- Instructions here)  The box has parameters including height, width, depth, height off ground, entrance diameter, direction the entrance faces, what the box is mounted on, and more.

My current project will allow researchers across North America (and maybe South America too) to track data from their kestrel boxes. Using OOP and MVC methods will be essential to keep the software flexible enough to satisfy the preferences of such a diverse audience and allow future expansion of the project.

Update 10:35

More valuable references:
https://developer.mozilla.org/en/JavaScript/Guide/Working_with_Objects
https://developer.mozilla.org/en/JavaScript/Guide/Details_of_the_Object_Model
https://developer.mozilla.org/en/JavaScript/Guide/Inheritance_Revisited

Update 17:40

I successfully met my goal. In some ways it was easier than expected, but at the same time, a bit confusing. My object is created simply by retrieving the parameters from the database, via jQuery's Ajax functionality, as JSON.

var request = $.ajax({
    url: "getBoxParams.php",
    type: "POST",
    data: {id : nestBoxClicked, user: userToken},
    dataType: "JSON"
    });

request.done(function(boxData) {
     var kbox=new nestBox(boxData);                    
     populateBoxForm(kbox);
     });


Then, I manipulate the object properties in the populateBoxForm() function.

I still prefer working with strongly typed languages and classes, but it appears JavaScript can do what I need for a fully-functional web app, without losing speed or user-friendliness.

Douglas Crockford's article about JavaScript code conventions is another good resource I found today. 

Wednesday, March 14, 2012

Miscellaneous notes and thoughts

While working on integrating an instance of SlickGrid into a project file today, I discovered that all the rows had white backgrounds. In all the examples, the rows alternate colors for easier reading.  It took a while, but I traced the problem down to a conflict in the CSS for .ui-widget-content .  After adding the following to a .css file that loads at the end of the queue, my SlickGrid now has alternating gray and white rows as needed:

.ui-widget-content.slick-row.odd
    {
    background-color:white;   
    }
.ui-widget-content.slick-row.even
    {
    background-color:rgb(250,250,250);   
    }

The current problem I am working on is the inconsistent alignment and width of SlickGrid headers and their associated data cells. It is similar to the problem shown here: http://stackoverflow.com/questions/8559487/slick-grid-header-row-cell-alignment

Update 12:20

What appears to be happening is that the column width is set, for example, to 50. However, the elements added for the sortable and resizable properties add width to the header (about 10 pixels), but not to the cell.



Strangely, it very always becomes properly aligned if I hold down the shift key and refresh the page, even though no changes are made to code or CSS between page loads.

If I set the resizable and sortable properties to false, then everything consistently aligns properly on every page load/refresh.
Update 16:05 

I have spent much of today researching this error, with little advancement.  I tried to rebuild and reproduce the problem in jsfiddle.net, but it aligned properly there.  I tend to think that the cause is related to browser rendering and CSS caching or interpretation. It has been tested on Mac and Windows in Firefox, Chrome and IE. The misalignment is not consistent or predictable.  In Firefox, if I first use Chris Pederick's Web Developer toolbar to clear the cache, the SlickGrid always loads with proper alignment.

So far I am impressed by the capabilities of SlickGrid. My current project has so many jQuery plugins, other modules and CSS files there are bound to be conflicts.

Update 18:50

I haven't been able to consistently reproduce the problem discussed above, so I have moved on. I am now working on retrieving data from the database via jQuery ajax. In the past I have always written my own ajax functions, but have decided to go with jQuery for this project since its requirements may eventually grow beyond the simple tools I have previously built.

So far, the method has been very simple. I need the ajax to be called when a user clicks on a row in the SlickGrid.  In the grid's setup JS, I added:

grid.onClick.subscribe(function(e, args) {
        var cell = grid.getCellFromEvent(e);
        var rowClicked=cell.row;
        var clickedItem = gridData[rowClicked].id;

        var request = $.ajax({
              url: "myScript.php",
              type: "POST",
              data: {id : clickedItem},
              dataType: "html"
            });

            request.done(function(msg) {
              alert(msg);
              });

            request.fail(function(jqXHR, textStatus) {
              alert( "Request failed: " + textStatus );
            });
        });

Now I need to write PHP code to retrieve the specified record from the database, convert the data into JSON and send it back in order to populate the form for editing.

Wednesday, March 7, 2012

Thought for the day: Craftsmanship

It has always been important to me to try to get my projects' source code to be as organized and perfectly laid out as the visible user interface. Why? Partly because it makes future maintenance and upgrades easier, but there's also something to be said for pride of craftsmanship. Even though virtually no one is going to view the source of the websites and apps I design, there is value to me in knowing every part of the project is done as clean and artful as possible.

This concept was highlighted by a quote I read by Steve Jobs' biographer Walter Isaacson:
"One of the most important things he taught Steve was [that] it's important to be a great craftsman, even for the parts unseen. When they were building a fence, he said, 'You have to make the back of the fence that people won't see look just as beautiful as the front, just like a great carpenter would make the back of a chest of drawers ... Even though others won't see it, you will know it's there, and that will make you more proud of your design.'"
( source )

Now that I am using the Eclipse IDE for my work, I expect that making beautiful source code will be easier than ever.

The day's work awaits... Today I will return to working on a GIS UI in JavaScript and PHP, with jQuery and the Google Maps API.