Sunday, October 28, 2012

Reading the PHP manual...

Today I decided to read as much of the PHP manual as I could.  While working through examples, multiple times the thought "coding horror" came to mind.  But I can't afford to be that kind of snob can I?


I finally hit a language "feature" where variable names can be created by other variables.  They are called "Variable variables".  So if a script assigns a string to a variable $a:

$a = "horrifying";

that string can become the name of another variable:

$$a = $a." is as ".$a." does.";

It can be referenced as ${$a}.  Or it can be referenced as $horrifying.


Did I mention coding horrors?  Can anyone explain a legitimate use of such a construct?  What drove the language to put it in there in the first place?

This language feature reminds me of the first assembly language code I wrote in High School, on a Sharp PC-1500 Hand-held Computer.  [I had to use POKE commands to enter the ASM code in by hand - there wasn't any assembler.]  What was cool was that the code was self-modifying!  It wrote to a relative address in the code itself to increment a comparison, and change the minimum pitch of an oscillating tone.  At the time, I didn't know that self-modifying code was a bad idea.  It was just pretty cool how it all worked to make a wah-wah- gaming sort of sound.  And I could brag about it to whoever understood what I was talking about.


So web-searching for "coding horror PHP" yields no shortage of blogs complaining about how bad a language PHP is.

My theory at the moment, is that this is fine.  Really bad code can continue to be generated, and there is no shortage of enthusiastic 14 year old's out there to wade through it all.  For the price of 1 experienced engineer, you can hire 10 teenagers instead.  They won't know why the above example is a bad idea - they'll think it's really cool.

This gives me great pause at considering any work prospects involving PHP coding.  As a good friend of mine once advised: 

"Always read the whole prospectus before making any investment."

Friday, October 12, 2012

Parrot Engineering

Last night I finally got a Maqetta website to run on the App Engine launcher.  For most new development stuff, there are several blogs and youtube tutorials on how to use the stuff.  Not so for Maqetta.  I was beginning to wonder if I could pull it off in the next few days or I'd actually have to RTFM - if there even are such manuals.

Maqetta's website has tutorials.  They go as far as showing how to use the tool, and assume the developer is stuff is something you already know.

App Engine - almost the same story.  I've gone through their tutorials, but still wasn't clear on the how these tools really work with each other.


Luckily one of the Google tutorial videos "Google I/O 2012 - HTML5 and App Engine: The Epic Tag Team Take on Modern Web Apps at Scale" also includes a Github link.

http://www.youtube.com/watch?v=v9TG7OzsZqQ


https://github.com/greenido

Downloading his code, and comparing with my files, eventually yields an app.yaml file that looks like:

application: heyworld
version: 1
runtime: python27
api_version: 1
threadsafe: yes

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: /images
  static_dir: images

- url: /lib
  static_dir: lib

- url: /static
  static_dir: static

- url: /themes
  static_dir: themes

- url: /samples
  static_dir: samples

- url: /stylesheets
  static_dir: stylesheets

- url: /
#  script: main.app
  static_files: file1.html
  upload: file1.html


libraries:
- name: webapp2
  version: "2.5.1"

#- url: .*
#  script: main.app
#


Where all the Maqetta directories that contain Dojo libraries, etc, are specified.  The downside to this, is you can enter directories and it serves up all of their files - not very clean.  I'm not sure there's any workaround for that problem, as app.yaml seems to work like a file system directory for the whole site - if it doesn't show a directory, none of the scripts seem to have a way to get to those directories.  [Yes?  No?  Anyone?  Please leave comments clarifying if you know!  Thanks!]

I call this "parrot engineering".  Not a proud badge - but if it gets the job done, do it.  If I can't find the answer on youtube or google, or by looking at a website's source code, Github seems to be another great source.


Wednesday, October 10, 2012

The Three Motivators


There were 3 warriors who needed to cross a great desert on horseback.  Nobody had ever crossed that desert and lived to tell about it.

Not only was the desert hot and dry, it was on fire.  Clouds of black smoke blocked all view, and obscured the sun overhead.

But there was no other way.

So the first warrior set off.  After 2 days his horse was starting to show fatigue.  But the warrior had seen many battles, he had commanded armies, he knew something about survival.  He dismounted and looked his horse in the face.  "We'll die here if you give up.  You can't get tired now.  Keep going!"

After 2 more days the horse had collapsed.  The warrior found his way, but not without a great loss.


The second warrior went through similar circumstances, but rather than talking about death - he tried feeding his horse treats, and entertaining him by telling a wide variety of "a horse walks into a bar" jokes.

"So, why the long face?"

Same outcome as the first warrior - the horse eventually collapsed.



Now what did the 3rd warrior do?  He and his horse made it through alive.  How?

This warrior first of all had keen control of his senses.  This came with training - he didn't just read a story or a book and learn that control.  It took practice and a transformation of his conditioned mind into an awareness of the most subtle cues.

As a result, the warrior knew when he was acting out of compulsion and fear and when he was acting fluidly.  He made no distinction between himself and the horse, or himself and the desert.  The horse was also aware the warrior had no fear.  Not as a contrivance "no fear", like what you might see on a bumper-sticker.  "No fear" doesn't describe it positively.  "All clarity" would be more accurate.  The warrior was "all clarity" and the horse could see that.

So when the horse was beginning to show fatigue, the warrior also dismounted, and looked his horse in the face.  "I have seen a vision of our arrival - and they are waiting for us with great anticipation!  Today, we will not die!"  The warrior's face was completely radiant!  This was because he really had seen such a vision.


The affect on the horse was an invigoration - a perfect dissolution of fatigue.  He was completely renewed, and continued through the desert refreshed.  Such refreshment, when moments before he had been so tired, how can this be?



The 2 motivators commonly talked about are "fear" and "greed".  But both of them, in whatever form they take, are really forms of harassment, and not based in true Authority.  They are two demons, that drive common people mad chasing this way and that, both tormenting themselves and others.

Don't do that.


The 3rd motivator is like "Soul".  It is much more subtle, and sometimes seems miraculous!  Performance is maximized in such a place.  The body relaxes without fear, and the blood vessels aren't constricted by tension.  Everything flows.  It isn't a question of "how can we motivate you?"

It's a selfless, pure, abiding in love.

And isn't that why we are all here?  Because deep down, we really love what we do?  Why would anyone resort to any smaller Vision than such an abiding?