Categories
Uncategorized

Upgrading Android via CyanogenMod

In the midst of upgrading my G1 Android phone using CyanogenMod.  I found a helpful tutorial video that made the upgrading process much friendlier on Lifehacker at http://lifehacker.com/5339901/get-root-access-in-android-with-one-click .  It is still showing the TMobile G1 splash screen but it hasn’t died yet ..

A little over one year later, I am looking into buying a Nexus One.  Total I’ve only spent $354 in prepaid minutes since I bought this phone, so I am happy going without a contract.

Categories
Uncategorized

You have the mike

I originally attempted to write this as a comment on the New York Observer’s article on 140 Conf but my comment was repeatedly marked as spam as well as my email to the site administrator. Oh well to that.

Picture being at Jeff’s conference at one of the sessions, take Jack Dorsey’s (founder and CEO of Twitter). Jack speaks into the microphone and it expands the reach of his voice from fifteen feet to one hundred feet.

Now take Jack’s microphone and give it the power to record what he says and play it back for anyone to hear for the life of the microphone. Not good enough? Jack, say something to your friend in St. Louis, or to one in Los Angeles or London. Better yet, this microphone is two-way, so Jack’s friend in London can answer him either as a private whisper, or as an equally public broadcast, able to be heard by both friends in LA and St. Louis. How much will Jeff Pulver pay Jack to use that microphone at his conference?

Turns out this microphone is free to use and available to everyone and anyone. What a guy Jack …

When Jeff talks about the State of Now, he’s talking about the movement away from the archives such as the library or the expert and into the age of the device, that broadcasts both ways instantly and globally.

Go ahead. Speak into the mike. Anyone?

Categories
social media writing

140 Conf: or How Twitter is helping me get the most out of a Twitter Conference

I’m attending 140 Characters Conference on July 16-17 where I will learn about the State of Now with 139 other participating characters plus attendees, credentialed media, bloggers, and Jeff Pulver the lead organizer himself.

My strategy to maximize my experience is to do the research ahead of time. Namely, to make excellent use of that ever-so-useful page titled The Characters. But who wants to spend time clicking on all of those icons?

Enter Firefox add-ons. Sneak Peek and Who Is This Person are making my research much more efficient, and accordingly that much more likely to remain in my memory where it might do some good 😉

Sneak Peek creates a hover box over a link with a snippet of the linked page according to three regular expressions defined by the user, as described in this tutorial. I created a “Sneak Peek script” by using the Sneak Peek menu item under Tools after the add-on was installed. My script shows the latest twitter updates of any person on the 140 Characters Conference Page when their icon or twitter url is hovered over.

Here is the Sneak Peek script (all are required fields):
Name: 140 Characters – twitter
Author: Sara Streeter
Author URL: http://www.sarastreeter.com
Site Pattern: ^http://www\.140conf\.com.*
Link Pattern: ^http://twitter.com/\w+
Peek Pattern: < ol class="statuses" id="timeline" >[^]*?< /ol >

(Hint: don’t insert spaces into the peek pattern ol tags like I did above – WordPress was interpreting the html tags as styling for this post)

Screenshot for Sneak Peek for twitter urls
Screenshot for Sneak Peek for twitter urls

Who Is This Person I found to be a nice supplement to the Twitter previews. This add-on requires no tweaking and allows you to highlight any name and right click, which will give you an option of “Who is this person” with an arrow down to several methods of checking up on a person (Google, Wikipedia, and LinkedIn are most useful to me).

Screenshot of Who Is This Person Firefox Add-on
Screenshot of Who Is This Person Firefox Add-on

There is another Firefox extension LinkedIn Companion which seems to be more of a bookmarking tool, not as applicable to this situation but still useful.

So far, looking through the character bios and tweets, I am amazed at the influence and depth of experience reflected in the attendee list. If each person is summed as a single character, I would say that is of the same genre as the oriental calligraphic character, in which a single collection of strokes conveys a concise and poetic concept, complete unto itself.

Categories
geek

Adventures in Slipstreaming

I had the chance to get fairly geeky back in mid February with the purchase of a new copy of Adobe Creative Suite 4. The issue was that this product was not compatible with the operating system on my Dell Vostro 1500 laptop which comes with Vista Home Basic out of the box. My options were either to downgrade to Windows XP or upgrade to Windows Vista Business. I chose the former and that’s when the ‘fun’ began …

I have a student account that lets me download certain software for free, so I used it to grab a copy of Windows XP. I loaded it on my laptop and found that it just booted from Vista rather than install XP. Keep in mind I have tried to backup my computer before with Macrium Reflect but never figured it out successfully. Faced with the dilemma of apparently not being able to install XP with Vista still on there, I went for broke and started installing XP in the C drive, overwriting the current installation.

The first issue I ran into was the SATA Drivers on my laptop – XP predates this type of hard disk driver so it doesn’t install correctly when it runs into them. I found a solution through googling on my functioning XP desktop. If you press F2 quickly as the computer boots up, it puts the computer into BIOS mode, which is a level lower than the operating system and works even when there is no operating system. If you arrow down you’ll see the option for Drivers and SATA. Hit enter and it lets you change the option from ATA to AHCI. This is compatible with XP.

I went along and got the installation page that looks like Windows XP. That’s when I ran into the i386/asms Access Denied error. This was as far as I got. From here on out it was one denial after another.

I tried to slipstream my Windows Installation CD – this means inserting the drivers that XP needs into the installation itself so it can run the computer. I followed a guide I found online – http://unattended.msfn.org/unattended.xp/. No matter how I tried, either Windows wouldn’t recognize the CD as a proper XP boot CD or it would get back to the same asms Access Denied error.

In the end, I accepted defeat and started contacting my geeky friends. It just so happened that one of them has access to Vista Business DVDs for free at his work, so I got out of having to pay the $200 or so for the OS, plus I got back full use of the laptop. Unfortunately, the data on my laptop was lost and I had to reinstall absolutely everything.

Here’s what I learned

  1. Slipstreaming=customizing an installation CD, usually by inserting necessary drivers
  2. $OEM$ is a folder that needs to include the license for Windows XP. The dollar signs mean it will be copied over to the new computer automatically. You can find a more complete guide to these folders at http://unattended.msfn.org/unattended.xp/view/web/18/
  3. There is a folder structure basic to Windows installations that also contains identifiers for the installation. All these components must be included for it to work.
  4. XP folder structure

Here’s what I did wrong

  1. Overwrote my operating system AND my data
    • I should have done something, anything, to back up my data. Luckily for me I have FTP access to both of my live websites so I was able to get a working copy from there, plus I have a repository for one of them. Still.
    • All my music and pictures were erased because they were stored in the Windows My Documents folders.
    • I have since learned that Macrium Reflect allows you to create a Linux boot CD from a restore point, which would have come in really handy had I not been able to obtain a Vista Business DVD, and it might have saved my data. Restore point=good
    • I should not have wiped Vista at the start. If I had not had another computer to google with and find solutions, I wouldn’t have even had the option to troubleshoot the issue. Lesson being NEVER do this to a primary or g*d forbid a work computer. Check out comment #8 on this forum post for an idea of the process the way it should be done.

  2. Took my chances muddling about with the command line and WOULD’VE tried to figure out the registry key if I could have created a restore point for that.
    • This would have been WAY too advanced in the sense that the only thing wrong with my laptop at this point was there was no operating system. If I had messed up the registry keys that would have been bad.
    • There’s only so much you can do to solve a problem the hard way before you should give up and go with the easy way (in my case, giving up on XP and going with the Vista Business DVD). I know I am the type that wants to figure everything out and learn which is good to a point, but when nine hours go by and you still hit the brick wall, that would be time to stop learning and fix the thing.

  3. I should have read ALL the requirements of Adobe CS4.

I realized after the fact that Adobe CS4 also requires a 1.8 gHz processor at least. My laptop has a 1.4 processor. So in the end I still couldn’t install the software on my laptop and it went on my desktop. This would be the part where I go “doh!”

Categories
leadership

Leadership and Doing it Right

Is there a wrong way to be a leader?  I would argue that there is a wrong way to lead that does more damage to a cause then it helps, one that is centered on an individual who might have a charismatic personality but no ideas and instead relies on suggestions to others of how things ought to be.  What I mean by suggestions is a statement of opinion about the way reality should be, as opposed to ideas which are solution oriented and creative. 
 
What you might hear from a suggestion-based leader vs. an idea-based leader:
Suggestion-Based Leader Idea-Based Leader The Difference
“That’s your problem” “How would you work this out?” inspire the person to think for themselves
“I want results” “This is how you’re contributing” fit the work into a larger picture
“You need us, so you’ll help us” “Here’s what we have to offer each other” balance of power in relationships
“I’ll talk him into it” “I’ll see what he thinks” listen and reason with people
“We succeed because we work hard” “We succeed because we add value” purpose matters more than effort
 
Here is how you can become a great(er) leader:
  • Follow through on your idea in your own life first
  • Let your conviction speak through your actions
  • Build your network by seeking out others who inspire you
  • Help somebody
  • Be human like everybody else and let the idea itself take center stage
Great ideas make great leaders, and I am proud to say that in our community of Greater Providence in Rhode Island and nearby Boston there are many people who have taken their inspiration and turned it into action. 
Who do you consider to be a great leader?  Why? 
Categories
social media

100 ReTweets of Wisdom – One Month Later

As an experiment, 100 RTs was not the most rigorous.  I started at 900 Tweets and I am now at 977, having only actually done 21 ReTweets.  So what did that accomplish?

First of all, I learned how hard it is to give up any tweets at all, for the sake of experiment or other.  I got some follow backs, which was fine.  I found out how difficult it is to find tweets of any substance by using search.twitter.com.

Did I discover cool new people to follow?  Resoundingly, yes.

More importantly, this exercise made me reach out of my twitter comfort zone and find people with no prior connection to me.  This underscores a feature of twitter unique among social media networks – you get to know people based on what they think, not what friends they have.

BTW –

technogoddess
technogoddess Today, I came out to play when I would have hidden. And it felt liberating. It wasn’t for her, but for me and the next woman who deserves me
Brian McLeod
LoudMac Today is one of those days to just pick one off the list of “everything that cannot be completed today” and knock it out.
mikhelk
mikhelk Sometimes I need to be reminded that I always have choices. Often many more than are 1st apparent. No matter where I am or what’s before me.
Rob Knight
robknight Never underestimate the power of a simple message to the client explaining honestly where a project stands. That’s all they need.
Dave Whelan
djwhelan My uncle just joined Facebook. Worlds collide. It can’t be very long before my father and future in-laws join. Maybe the world is too small.
Sarah Dopp
sarahdopp Low tide with storm winds. The water has a huge space to dance with. The ground is covered, then big and empty.
Evan
montythestrange Tech section of the office is getting the hax0r vibe; dark skies outside, no lights on by us. PHP Ninjas coding by the light of the LCD.
Maggie Mason
Maggie I want to achieve maximum efficiency without getting all worked up about it. I’m aiming at peacefully frantic. Serene rampage.
patobryan
patobryan everybody needs someone to look up to and someone to look down on… and apparently, something to fear.
ryan
secretsquirrel Spent most of my weekend playing an evil bisexual hooker-warrior in a game. I am worried what would happen if I did not have these outputs.
Noah
heyitsnoah Just failed six CAPTCHAs in a row. Does that mean I’m a robot?
Cat
CatBailey Why do I get told it’s ironic when I suggest someone ELSE see a shrink? It’s not like I’m hogging the crazy over here. *pissed*
Pedro Valle
petevalle Stealing some WiFi over at Dunkin Donuts. This is the sort of hijinks only a nerd gets excited about.
Nicole Reising
colereising Ran in the rain tonight-decided insurance on my blackberry might actually be a good idea afterall. 🙂
Shannon Thompson
TheBathProject made some Chai Tea with local honey, watching the sun come up over the mountains out back, a beautiful pale pink with orange tinge aaaahhhh
Warlach
Warlach Oi, seriously people, the internet is not rocket science. “Notepad” is not an appropriate response to how your site publishes content.
matthewktabor
matthewktabor bittersweet blog moment: trying to research a topic and finding only your own posts addressing the subject
burstein
burstein Met the ex. While it is a bad idea to bring a stick to a gun fight, sometimes a olive branch works out ok.
Rowan Price
roprice there’s a whole new generation of web developers who’ve never had to write actual Javascript, cuz they’re using JQuery. Green with envy 🙂
Karen Cardoza
mrsb Ok.. time to just pick a task and jump right in. There will be no fairies coming in the night to do everything for me.
Annalie Killian
maverickwoman NY times cover story: Obama vs McCain approach 2 maintain US relevance thru technological innovation. Obama strategy better but execution?
Categories
social media

Listening and 100 Tweets of Wisdom

I have always been the person with something to say.  Not that I am always producing content, but when it comes to social media it is typically because I want everyone to listen to me.  It’s weird how things kind of come together but I also had my 900th tweet coming up, and wondered if there might be some way I could use those 100 tweets before 1000 to do something more interesting than the usual day to day “what are you doing?”

My last blog post was on copyright and file sharing, and Chris Bloom took it upon himself to comment on it – a great and detailed comment that reminded me of Chris Brogan’s post “Finding Treasure in the Comments” – and inspired me to start reading more of the blog posts of those people I know and follow on twitter.  For the last few months I’ve been an eager audience of Mashable and TechCrunch, but I asked myself, do I know what my friends are working on?

I’ve created a folder in my Google Reader to keep track of rss feeds of friends.  I’m committing myself to comment frequently on their blogs and stay up to date on their projects.  And now I’m dedicating one hundred tweets from 900 to 1000 to retweeting people that I find inspiring, informative, funny, and original.

Now if anyone has any more ways that they like to keep track of what their friends are posting, tweeting, or working on, I’ll be glad to listen.

Categories
tech-talk

My take on Copyright and File Sharing

Creativity depends on a content producer being able to build on what has come before, but it also relies on the producer being protected and entitled to the benefits of his/her efforts.  If I study hard and work tirelessly to become a master musician or a programmer or an athlete, I should gain the rewards for it as well.  Someone who didn’t work to earn it shouldn’t feel entitled to the value of what I produce, and certainly should not be reaping the benefits of what I produce.

So what is free to take without permission and what requires the permission of the producer?  Copyright law makes the distinction between an idea and the form of an idea.  An idea is free to use and is exempt from ownership.  The way an idea is expressed, however, is owned by the person who originates that form of expression.  In my case as a programmer, I can rely on the principles of mathematics – I don’t have to attribute 1 + 2 = 3 to anyone else.  However, I can safely claim my method of applying that math to a specific problem and charge money for it or not.

Speaking of money, what does a purchase mean anyways?  It is a contract between a content producer and a content consumer, the consumer compensating the producer for the value they get out of the content.  Like any contract, it is subject to the intentions and interpretations of both parties.  If the value a consumer gets from the content is outside of the intention of the producer, does the consumer infringe on the producer’s right to the content?

I would argue that yes, the contract should be adhered to by both the consumer and the producer.  So in that case, who should enforce the contract?  Besides that consumer having an ethical obligation to the contract, the producer should be able to protect his/her legal right to the content. 

The government and industries representing the content producers have tried to make it easier for producers to safeguard their rights to their content.  Their efforts were unpopular, but have made it general knowledge that certain forms of file sharing are illegal and may be prosecuted.  If there is a complaint to be made about these efforts, it has to be that consumer behavior is intelligent and requires finesse.  The online community appreciates respect and disdains force, and lawsuits and subpoenas and file encryption are the exact opposite way to achieve compliance. 

The success of Radiohead in asking for as much as the fans were willing to pay for their album rather than loading their songs with DRM represents a contract in which both the consumers and the producers win.  In this model, the producers make their money, the consumers are respected and, most importantly, the contract is honored – no enforcement necessary.

Do I have it right?  wrong?  What do you think about copyright and file sharing?

 

Radiohead article:

http://musically.com/blog/2008/10/15/exclusive-warner-chappell-reveals-radioheads-in-rainbows-pot-of-gold/

Categories
geek

URLs, Models, Views, Templates, and Shell – Useful Snippets for Each

There have been quite a few times when I have resorted to my coding friends and mentors and good ole Prof. Google to teach me how to write the code I needed to get the job done.

In particular, Adam (@adamjt) and Andy (@ashearer) have been right there alongside me helping me out.

Learning Django has been particularly involved because there are so many “in” things to know.  My understanding of Django has come down to the fact that there are 5 things to master in order to code Django and python successfully – the urls, the models, the views, the templates, and the python shell (command line interface).  I’ll touch on each one and list something I didn’t get at first until my friends explained it to me or I found it on google.  It is written in the spirit of writing it down so I don’t forget it …

URLS:   All about the media … explained to me by Andy (@ashearer on twitter)

In order to link my templates to the site media such as images and javascript and all that fun stuff I had to follow some specific steps in a very un-PHP manner:

  1. put a special global variable in the settings file of my project:
    MEDIA_URL = ‘/site_media/’
  2. add an extra expression in my urls file:
    (r’^site_media/(?P<path>.*)$’, ‘django.views.static.serve’, {‘document_root’: os.path.join(os.path.dirname(__file__), ‘site_media’)}),
  3. make a directory on the same level as my urls and settings files called “site_media” that holds all my files (which can then contain subdirectories for css, images, javascript that I can include in my links in the template)
  4. link to the MEDIA_URL in the template itself, like so:
    <link href=”{{ MEDIA_URL }}your_stylesheet_name.css” type=”text/css” rel=”stylesheet” />Notice that in the template itself, the {{MEDIA_URL}} is a reverse look-up.  There’s no need to write out the exact relative path to the site_media folder.

MODELS: Optional ForeignKey attribute … explained to me by Adam (@adamjt on twitter)

When I specify a one to many relationship in my models file using an ForeignKey, sometimes I want that relationship to be optional.  Just blank=true or null=true doesn’t work though, you have to use both:

mynamedattribute = models.ForeignKey(MyModel, blank=True, null=True)

This is an optional field, not required, as ForeignKey fields usually are.

VIEWS: Authenticate me … Adam and Django Docs (@adamjt)

Logging users in and out is quite the hassle, but there are some built-in methods that take care of the work for me.  In order to get a user logged in and out, there needs to be a url side of it, a view side, and a template side.  There are more advanced registration and authentication modules out there ( Google code has one I recommend http://code.google.com/p/django-registration/ ) but there are also some short-cuts that come with Django that work very well.

  1. On the urls side, these are the urls that link to the views that are built into django to log users in and out:
    (r’^login/$’, ‘django.contrib.auth.views.login’),
    (r’^logout/$’, ‘django.contrib.auth.views.logout’),
    Teeny sidenote here:  there was a release of django that had the login template moved from registration to admin but referenced the old location in the view, so to fix it I took the non-coding way out and copied the template over to the proper directory
  2. For views that need authentication, “login_required” is an easy way to check for logged in users.  The view file first imports the necessary decorators:
    from django.contrib.auth.decorators import login_required
    from django.contrib.auth import logout
  3. Then the view can either start with login_required:@login_required
    def view(request):
    variable_name=processed_variable
    return render_to_response(
    ‘index.html’,
    {“ElementName”: variable_name}, context_instance=RequestContext(request))
  4. or it can use “if request.user.is_authenticated” within the view (if it came from a login form it will look like the code below):
    def otherview(request):
    if request.method == ‘POST’:
    if request.user.is_authenticated():
    variable_name=request.user.username

    else:
    variable_name=”Not logged in so no name”
    return render_to_response(
    ‘index.html’,
    {“LoggedInName”: variable_name}, context_instance=RequestContext(request))
  5. Then in the template there is the same operator for segments of code that should be displayed for logged in users:
  6. {% if user.is_authenticated %}
    <a href=”/account/”>My Account ({{ user }})</a>
    {% else %}
    <a href=”/login/” >Login or Register</a>
    {% endif %}

TEMPLATES:  Ordering output and Grouping … explained to me by Adam (@adamjt)

For an article-based engine, I needed to group a list of articles in order to show them according to category and then by date within the category.  First I had to order them in the view and then regroup them in the template:

  1. The view is simple enough, generate a variable that stands for all objects in class MyArticle in order by category:
    variable_articles = MyArticle.objects.order_by(“category”)
  2. Pass the variable to the template in the dictionary:
    return render_to_response(‘articles.html’, {‘articles’: variable_articles}, context_instance=RequestContext(request))
  3. Then in the template, I make use of the “regroup” template tag to take the already ordered-by-category articles to order them further by date:
  4. {% regroup articles by category as article_list %}
    {% for article in article_list %}
    <h3>Category: {{article.grouper}}</h3><ul>
    {% regroup article.list by date as datedarticle_list %}
    {% for datedarticle in datedarticle_list %}
    {% ifchanged %}<li>{{datedarticle.grouper.date|date:”F j, Y”}}{% endifchanged %}
    <ul>{% for item in datedarticle.list %}
    <li><a href = “/article/{{item.id}}/”>{{item.title}}</a>, {{item.author}}</li>{% endfor %}
    </ul>

    {% endfor %}</ul><br />{% endfor %}</ul>
    Notice that we had to regroup by category aside from using “order_by” in the view, but that was for the purpose of printing out the attribute by which the variable was grouped.

Finally the

SHELL:  Python shell scripts … figured out through pieces on Google

Using the administration interface is nice since you can see everything neatly represented by menus and drop down fields in a GUI, but there are tasks that are more efficiently accomplished using the command line.  Even that has its limit, in the sense that I could only ever figure out how to give it one command at a time.  A shell script on the other hand will give me the efficiency of the command line with the advantage of being able to write out an automated, saveable, multi-command executable.  You do need to have access to a Linux-type terminal in order to do this (the script starts off with the bash shebang).

  1. Create a file called myscript.sh and chmod it to have execute privileges:
    chmod +x myscript.sh
  2. Create the python environment with the python path and the django environmental setting:
    #!/usr/bin/env python
    import sys, os
    # Add a custom Python path.
    sys.path.insert(0, “/usr/bin/python”)

    # replace myname with your username
    sys.path = [‘/home/myname’] + sys.path

    # Set the DJANGO_SETTINGS_MODULE environment variable.
    os.environ[‘DJANGO_SETTINGS_MODULE’] = “myproject.settings”

    from django.contrib.auth.models import User #for example, this can be any django code

  3. Write in any commands you normally would type into the command line, for example making repetitious code into for loops like so:
    for i in range(1,51,5): # where i is the iterator and range(start,stop,step) – stop is non-inclusive
    article=MyArticle.objects.get(pk=i) #to select all objects with indices 1,6,11 and so forth up to 50
  4. Execute the script from your normal command line:
    ./myscript.sh

And there you have it!

Categories
web development

Teaching Mom PHP

“Strings?? Words are called strings in computer lingo? That’s too jargony for me …”  My mom is a newbie, classic right brainer and kinesthetic learner.  She fidgets when she’s in the chair for too long.  She jumps up and down when something works.  And I’m teaching her to code.

She has listened to me talk about all these technologies for the last two years.  Mom attended the NewBCamp I organized in February, playing a vital role in the event by manning the registration desk.  She knew about these terms like PHP, HTML, CSS, and Javascript, but she referred to them without knowing what they meant.  That is, until a few days ago when she decided she would be thrilled to learn how to do some of what I do.

First I introduced her to the tools she would be using and some of the basic terms she would have to know.  “Browser” she knew already, as well as the fact that there are more browsers than the one Internet Explorer that most people seem to use.  I showed her the text editor Notepad++ and showed her how the regular Windows Notepad doesn’t have all the features that this text editor does (although there are better ones out there, it’s good enough for my purposes and light weight and free).  I then explained how the server (we were using Apache) finds the pages written in text and stored in the “document root” and then sends (serves) them to be interpreted by the browser.  We opened up the browser and typed in http://localhost/ and it showed the index page stored in the file folder.  

Mom started her first HTML document with a strict DTD from W3C and titled it “Opus4Jerri”.  I directed her to close all the html tags she started – an html tag goes first, then head next, then within that the title and the link to the css file.  Writing out the css link was a good place to pause and talk about file locations and directories.  The server can’t find a file unless it’s given the correct “path”, which is like opening one of those Russian nested dolls until you find the last file you were looking for.  The path starts with the drive you are in – in our case the C drive, and then each folder from then on is separated by slashes until you get to the file itself, which has a dot and a “file extension” indicating the type of file.  This is the sort of nuts and bolts information that I take for granted now, but it’s a major barrier to someone who is totally new to how web development works.

None of this was intuitive for Mom.  She worked hard to construct that first html document and was thrilled to see it when it first appeared interpreted by the browser.  We moved on to styling from there, and she played around with the background colors in the css file until she was satisfied she knew how it worked.  Then it was time to add in some dynamic parts with PHP.  The first thing we did was even simpler than a Hello World – she opened with a <?php tag and wrote echo 3-1;  closing with a ?> tag .  This was to illustrate the difference between php and HTML.  When she saw that it rendered as 2, she was surprised but then understood that HTML would have just printed 3-1, while PHP can do the math and to some degree “think” about what we type in. 

I explained that PHP does not show up in the View Source tab in the browser, which disappointed her a little because she had been thinking she could put secret messages in the PHP that only coders would be able to see when they looked at the source.  Only HTML, CSS, and Javascript show up in the browser because they are “client-side”, while PHP (and Python) are “server-side” so they never make it to the browser, whether in the text or in the interpreted (rendered) page.

Mom finally had her Eureka moment when I showed her variables.  In PHP a dollar sign before a word means a variable, which is like a name for a box that you can put a value into and then use the name whenever you need that value.  She said, so that means you can change a value once in that first equals (assignment) statement and it changes all the places where you used that variable.  I agreed that it is a good coding practice to avoid “hard coding”, where instead of using the value itself, you use the variable and then you only have to change what the variable means instead of all the places where the value was used.  Where variables shine, I continued, is in the if – else logic statements that test a variable for how they compare to a value and then do an action based on the outcome of that test. 

We did a simple example that took the current hour using the “date” function in PHP and tested the variable with that hour value against whether it was between 6am and 6pm (or between 6 and 18, as we made it easy and used military time).  According to whether the variable was between the values, it changed an inline style statement to make the background yellow during the day and black at night.  The code looked like this:

<style text=”text/css”>
body {background-color: <?php
$date = date(“H”); // this is the date function that formats the current time by hour in military time
if ($date>=6 && $date<=18) {
echo “yellow;”;
}
else {
echo “black;”;
}
?>
}
</style>

Since it was a little before 8pm when we did this, the background showed up black.  I told her to go back tomorrow and check it and it should be yellow. 

My mom’s response to all this was to decide that she needs to work on it on her own in order to really learn it, which is a great approach.  However she benefited from having someone to help her – for instance at one point she told me she had taken an hour to try to figure out why she couldn’t open a file in Notepad++, and it was because the default text editor was still regular Notepad.  I’ve been through all this, so I can save her time in learning the hard way.  It’s my pleasure, because it helps me rediscover all the nifty little things that make web development so much fun.