Thursday, January 26, 2012

Wednesday, January 25, 2012

Useful URLs for today

Today I am working on forms. My goal is to have forms in the current project look cleaner and more modern than default HTML. 

The base I am building from:
http://line25.com/tutorials/create-a-stylish-contact-form-with-html5-css3

How to make form elements float into the same line instead of vertically stacked:
http://stackoverflow.com/questions/2306117/radio-buttons-and-label-to-display-in-same-line

A good toolset for building HTML5 +CSS + JS forms
www.reformedapp.com/

This appears to be a promising tool for creating tree controls in HTML5+jQuery
http://www.jstree.com

Some tips on styling HTML dropdowns using only CSS:
http://stackoverflow.com/questions/1895476/how-to-style-select-dropdown-with-css-only-without-javascript

Saturday, January 21, 2012

Ultimate Waterfowler's Journal registration codes and instructions

In 2000, I created software called Ultimate Waterfowler's Journal.  I no longer am able to support the software, but I know some people out there are still using it.  Due to the registration system built into UWJ, if you upgrade your computer, UWJ will require reregistration. Without my business website online, that is not possible. 


Since UWJ should work with all versions of Windows including 7, anyone with a UWJ installation disc can keep their journals going by using the information below.  I have heard rumors that whatever version of Windows replaces Win7 will no longer support the architecture that Ultimate Waterfowler's Journal was built on. So, print out your journals while it still works.


STEP 1:
Registration keys:
The 5-character code on the left is what UWJ displays for you to enter into the registration system. The right column contains the key that you need to enter into UWJ to satisfy the registration requirement. So, locate the correct code in the left column below, copy the value out of the right column of the same row, and that will be the key you need:

 
A1JFY SEG0V7U
A1LOO 4BIPN5I
B5XLR MJK2BGY
C4JME QO18QNK
D2QVM J3TFL2W
D7LTP 2CDID0N
E5YGX Q5XOGW1
F3KHN Y5X6LRC
F6NFZ 4HT8VED
F8PTX CQ49DXQ
G6MRW HE5GPJW
G9VLM KFIKE6C
H1EQK IQ2F5CL
H3AHZ PHN7V1O
H3VVP GRZGN19
H6GCB HG4GJ0M
I4OUO J5JNLOB
J1MFZ 35XNKVV
J4YDQ F14YOMY
J9WBY TB54HQQ
K1LRM ZP5PCF3
K4MFI E8CL2WT
L7GJK PF18DQX
M1DEB OFM77KX
M2RTP U2YCC7J
O2YXZ UZ2ER0I
P3KWP IWG2EJ0
Q5VCF JES85CT
R0ODD BH3IY9K
R1DHK HU33KVK
R6ZIM EL5U5LN
R8WKD RKAEE54
S5OHI 7USBK8U
S6KYQ P7L8HRW
T1QSA HZ76KSH
T6MEG BN7UI9U
T8HSK LCKI63U
U4FPX ARYA9C3
X2UJH QLCO6X8
X7OLS 27YJRUB



STEP 2:


Customer ID:
You can make up your own customer ID. It is just the state abbreviation + first 4 characters of your last name + 4 digits of todays date + a random letter. Example: Joe Smith in Texas on Sept. 1 would be "TXSMIT0901X"

Pet peeve: Wasteful packaging

Why is it so many companies use huge boxes to display and ship tiny products? Such wastefulness has bothered me for a long time. Recently, I received an order that was just so ridiculous I had to share.

I ordered a tiny HDMI adapter from a popular online store.  A few days later, I received a large box. I was confused at first, since I knew I hadn't ordered anything so large.  Then I opened the box:

Crazy, eh?

Tuesday, January 17, 2012

Work scratchpad for January 17

Today I am continuing my effort to retrieve contents of a Drupal node in an authenticated session. I started by setting up the XMLRPC server in Drupal 7 Services 3.

8:40 a.m. update:
Using the Poster plugin for Firefox, I was able to successfully retrieve a node while logged into Drupal in Firefox by POSTing this to mysite.com/drupal-folder/xmlrpc-endpoint/node/ :

<?xml version="1.0"?>
<methodCall>
 <methodName>node.retrieve</methodName>
 <struct>
  <member>
    <name>nid</name>
    <value><i4>19</i4></value>
   </member>
 </struct>
</methodCall>

And, predictably, when I logged out of Drupal in Firefox, the same POST from Poster was rejected as being from an anonymous user. Good.

I found this valuable comment on StackOverflow:
If you're using Drupal 7 you must be using Services 3 which doesn't have a node.get method (or node.save as it happens). They've been replaced with node.retrieve and node.create & node.update respectively.
Update 9:10

I was able to get a successful XMLRPC login response and user object from Drupal by POSTing this from Firefox Poster:
<?xml version="1.0" encoding="iso-8859-1"?>
<methodCall>
<methodName>user.login</methodName>
<params>
 <param>
  <value>
   <string>example.user</string>
  </value>
 </param>
 <param>
  <value>
   <string>password</string>
  </value>
 </param>
</params
</methodCall>

Next step, to capture session auth data and learn how to send it back for the node request.

Update 12:15

So, it turns out that our webhost doesn't support the php_xmlrpc extension on our server. They do provide the PEAR XML_RPC package. Unfortunately, the encoding results are very different and the PEAR-produced object does not seem to be compatible with what Drupal wants. I posted a question about this difference on StackOverflow. Now, back to digging...

Update 13:40

I got a helpful response to my StackOverflow question from mario. He suggested:


To get the XML marshalled output you first construct a message instead, and then use 
the ->serialize()  method:
$msg = new XML_RPC_Message("function", array(new XML_RPC_Value(123, "int")));

print $msg->serialize(); 

I tested that code, and the print result was:

<?xml version="1.0" encoding="UTF-8"?><methodCall><methodName>function</methodName><params><param><value><int>123</int></value></param></params></methodCall>

...exactly what I needed. Now I'll modify the example code into the actual parameters and see what I get.

Update 15:00

I spent lots of time installing PEAR XML_RPC and XML_RPC2 packages and trying to locate and repair their dependencies. No success on version 2, which was the recommended solution.

Using the old XML_RPC package, I can talk to the Drupal server and get my user authenticated. However, I have been unable to parse the server's response. I can see the raw XML it returns if I do a PHP var_dump, but attempts to use the XML_RPC methods fail.  The var_dump shows it is a proper XML_RPC object, but trying to use the ->value() method as used in the example at http://pear.php.net/manual/en/package.webservices.xml-rpc.examples.php results in fatal errors.

Example code from above reference:
if (!$resp->faultCode()) {
$val = $resp->value();
$data = XML_RPC_decode($val);
echo $data[0]['name'] . ' is at version ' . $data[0]['version'];
} else {
/*
* Display problems that have been gracefully cought and
* reported by the xmlrpc.php script
*/
echo 'Fault Code: ' . $resp->faultCode() . "\n";
echo 'Fault Reason: ' . $resp->faultString() . "\n";
}
I get this:
Fatal error: Call to a member function kindOf() on a non-object in /mypath/php/XML/RPC.php on line 1948
 even though the var_dump of $resp shows as:

object(XML_RPC_Response)#4
 Frustrated. I'm going to try another method.

Monday, January 16, 2012

Drupal frustrations continue

Remember those old cartoons where the characters would open a door, only to discover another door behind it, then another, and another?  I have used that visual to illustrate the frustrations of software development to non-technical people. There is just no end of bugs to find and fix.Once one is repaired, another pops up.

I have been tracking my current problem down for more than three days now. All I want to do is retrieve a node from Drupal as XML so I can manipulate it in my own PHP coding. It should be simple, and it would be if the Drupal site I was trying to retrieve from was public.

There seems to be a bug or undiscovered setting that is preventing me from retrieving node content from my Drupal installation, which disallows anonymous users entirely.

As I posted earlier, I found an excellent sample of code posted by MichaelCole, and have been using it as my primary reference. Unfortunately, it seems that when trying to do an HTTP GET, passing the session auth data back to Drupal fails. I have tried countless combinations of methods to send the authentication strings, but none work.

These include PHP CURL options such as:
curl_setopt($curl, CURLOPT_COOKIESESSION, false); 
curl_setopt($curl, CURLOPT_COOKIEJAR, "cookiefile.txt");
curl_setopt($curl, CURLOPT_HTTPGET, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/json')); (along with JSON-encoding the session cookie)

Multiple methods of sending the data, including:
$request_data = array(
    $sessData[0] => $sessData[1],
    "method" => "node.get",
    "nid" => 18
    );
$request_data = http_build_query($request_data, '', '&'); // Format post data as application/x-www-form-urlencoded
$service_url.="?$request_data"; //append the data as a GET qstring

According to the REST entry on Wikipedia , GET must be used to retrieve a resource, so utilizing POST as is done in the login procedure seems to not be an option.

I will keep digging at this and post up if when I find a solution (think positive).

Sunrise view from my office

Nice view outside today.

Sunday, January 15, 2012

Peak Digital Productions: Ruminations on a closed business.

In 1995, I was not long out of high school and working for a large corporation. I hated the job and the atmosphere. I knew a lot of people that were self-employed and that seemed like a good fit for me.

I set up a sole proprietorship named Peak Digital Productions, bought several thousand dollars of equipment for video production, and set off to make a living. I was quickly disappointed by the quality of the video output possible with the extremely expensive equipment. Added to that, the licensing burden of popular music to go with video make the service impossible. Frustrated, I quit offering the video service.

Next I started working with photo restoration. I liked that, and got a fair amount of business from it, but nowhere near enough to support my new family. Dealing with individual customers was difficult, and the volume of work available in my area was inadequate.

Sometime around 1998 I started building websites. This became my primary service for the next several years. I enjoyed this work - especially how it allowed me to utilize all my skills and interests. Photography, videography, graphic design, programming, and more went into each custom-built site. I refused to use template sites or pre-packaged coding, always learning each necessary step and building the project from my own effort.

While I enjoyed the work, making a living was difficult.  Earlier, I had done a major programming project for a local government agency and got spoiled by the concept of invoice=payment.  While I had a few clients over the years that were excellent to work with, I also had a few that caused so much stress I could hardly stand to work for them. I got really tired of having to chase down my paychecks.

I tried various contractual variants to control the lack of payment and communication, but with little success. Sometimes the lack of communication was worse than the lack of payment. My benchmark for frustration was the client whose communication was so sparse that it took 16 months to finish a project that had a total of less than 40 billable hours.


Through the years, I gained experience in many skills. Software development became my primary interest and I applied it to both PC-based and web applications. I also got to use my photography skills for displaying client products, video editing to produce videos to place on their sites, graphic design and page layout for creating printed literature to complement the website, and various other miscellaneous jobs.

I started programming in VBA in Excel, moved to Visual Basic 6 around 2000, used ASP for building dynamic-content websites for several years, then moved to PHP when I decided to leave the Microsoft track. I explored Flex and Air for projects destined for web and desktop applications.  I continued to work on keeping up with current technology, re-learning website design to utilize CSS instead of the old methods.

When the economy tanked, what little business I could rely on disappeared. Most of my clients were small businesses, the majority being one-man operations like mine. As their businesses failed, so did mine. I was left with a huge Accounts Receivable register, which I expect I will never see.

The financial loss was frustrating, but my lack of ability to provide for my family was devastating. My stress levels were at unhealthful levels.

I would like to publicly thank Steve Birrer for stepping up and partnering with me on a software project during that time. His belief in my skills and willingness to support my work were a big help. Unfortunately, the project was unable to be completed due to "scope creep" and other issues, but Steve was the best business partner a guy could ask for. Despite the outcome of the project, he continues to be patient as I work to pay back his financial investment in my idea.

With my software partnership completion always just out of reach, I started looking for a job. In February 2010, I was hired at The Peregrine Fund as their webmaster. (Thanks in part to a glowing reference from Steve.) It continues to be the best work experience of my life. It's an amazing place with great people doing great work.

If you happen to be one of my past client that has a balance owing, and you wish to make a payment, please contact me - I would appreciate it.

Drupal frustrations

After more than 10 years of building all my software and website coding from zero with primary programming languages like VB6, ASP, PHP, ActionScript and JS, I have begun adopting open-source packages due to their advanced feature sets.

My newest exploration is Drupal.  In many ways I am very impressed with its capabilities. However, one task that seems to me to be a simplistic task has cost me more than two days of work, and now it's early on a Sunday morning and it's still consuming my thoughts: How to make the content of a node visible on a non-Drupal external site.

I started by installing the Services 3 module, configuring the REST server and its endpoint. After hours of fruitless research, I finally discovered a posting with a good explanation of accessing Drupal data externally with authenticated access via REST.

My attempts to implement that were unsuccessful. As I posted on drupal.stackexchange.com, the Drupal system would recognize my login and authenticate my session, but I still can't retrieve a node's content.

I posted another request for help on any method to see Drupal node data externally, and received the suggestion to use feeds. So, this morning I have been researching that avenue.  So far, success has been very limited. Based on http://www.group42.ca/drupal_6_rss_omnibus I was able to finally see something from my Drupal site by requesting the url my-site.com/drupal-folder/rss.xml.

However, due to the purpose of my Drupal installation, it is locked down to require authenticated access for everything. At this point I am stymied by two problems using the Atom/RSS technique: I haven't seen documentation to do an auth login to request RSS data, and so far I can only see as RSS what appears on the Drupal front page.

Back to the research...

Saturday, January 14, 2012

Waterfowl photography morning

I went to a local fishing pond this morning where waterfowl congregate.  I brought back over 200 photos after lots of culling in the camera. Here are a few that I like.



Monday, January 9, 2012

Cereal

Since this is supposed to be a more or less random collection of miscellaneous things, along with being a reference for my own later use, here is a recipe for cereal. I have given up on finding a high protein, low sugar, low fat commercially made cereal.  I just want a simple breakfast that doesn't leave me hungry 3 hours before lunch.

I don't know if it would be considered a granola or muesli, but here it is, based loosely on my Mom's recipe from when I was a kid.

6 cups old fashioned oats
2 cups sliced raw almonds
3 Tbsp flax meal
1/4 cup quinoa
1/4 cup millet
1/2 cup wheat germ
1/2 cup soy protein
1 cup unsweetened coconut flakes
1/2 cup grape oil
1 cup honey
sprinkle of vanilla extract
dash salt
2 tsp cinnamon

Mix everything together, bake at 400 degrees, turning every 5 minutes, until browned.

Add:
1/2 cup dried cranberries
1 cup raisins

and stir them in while the previous ingredients are still very hot. I learned a long time ago not to put the fruit in before baking unless you like the taste of charcoal.