Inventing passwords

November 24th, 2009

Making up passwords is tough. There are so many rules you have to follow:

- They have to be more than N characters long.
- They shouldn’t be proper names.
- They shouldn’t be important dates like your birthday or wedding anniversary.
- They shouldn’t be words in the dictionary.
- They should be a mix of letters and numbers.
- They should be a mix of upper and lower case letters.
- They should include punctuation symbols, if possible.

So how can you make a password that looks like gibberish and still remember it? I recommend what I like to call the shopping list method.

- Write out your shopping/todo list.
- Take the first letter or number from every item in the list, in order. That’s your password.

You can leave a grocery list in your desk and nobody will think twice about it. …at least until I’m a huge success and everyone knows this method. :)

Share on Facebook

Header Redirection vs echo/print

October 16th, 2009

Consider the following code:

<?php  // file1.php
if(isset($_POST['submit'])) {
  echo "You can see this important message but the header() won't work.";
  header('Location: somewhere_else.php');
}
?>
<form action='' method='post'><input type='submit'></form>

Ok, let’s try to buffer our output to solve the problem.

<?php  // file2.php
ob_start();
if(isset($_POST['submit'])) {
  echo "header() will work but you won't see this important message.";
  header('Location: somewhere_else.php');
}
?>
<form action='' method='post'><input type='submit'></form>
<?php
ob_get_flush();
?>

These greatly simplified examples shows a common problem that happens with posting, forms, and header redirection: What do you do if you need (or accidentally) print some text before the redirect? The answer is: Sessions.

<?php  // session_messages.php
start_session();

// add_message() - queues a message for display later
// msg - the contents of the message
// type - the type of message
function add_message($msg,$type='notice') {
  if(!isset($_SESSION['messages'])) {
    $_SESSION['messages']=array();
  }
  $_SESSION['messages'][]=array('type'=>$type,'msg'=>$msg);
}

function add_notice($msg) {
  add_message($msg,'notice');
}

function add_error($msg) {
  add_message($msg,'error');
}

function add_warning($msg) {
  add_message($msg,'warning');
}

function debug_item($a) {
  add_message('<pre>'.print_r($a).'</pre>','debug');
}

// display_messages() - show the queued messages
function display_messages() {
  if(count($_SESSION['messages'])) {
    echo "<div class='messages'>";
    foreach($_SESSION['messages'] as $v) {
      echo "<div class='".$v['type'].">".$v['msg']."</div>\n";
    }
    $_SESSION['messages']=array();
    echo "</div>";
  }
}
?>

Now imagine what happens when all your error messages pass through add_error. The file1.php example would become

<?php  // file3.php
require_once "session_messages.php";

if(isset($_POST['submit'])) {
  add_notice("You can see this message no matter what happens*");
  add_warning("* as long as somewhere_else.php calls display_messages().");
  header('Location: somewhere_else.php');
}
// you can also display them on the same page if you don't redirect.
display_messages();
?>
<form action='' method='post'><input type='submit'></form>

From here the sky is the limit – you could sort messages by type, you could hide errors so that only the administrators can see them. Debugging becomes easier, too.

Share on Facebook

Nettrack refers us to Zajon; we say ‘Thank you!’

October 15th, 2009

Nettrack Marketing referred Marginally Clever Software to Zajon, Inc., of Cleveland, Ohio.  In less than a week we’ve partnered on two sites!  Marginally Clever Software has added a number of features to www.performance-health-dealers.us and fixed contact form spam issues by adding Simon Jarvis’ CAPTCHA system at www.thera-band.com.  On behalf of everyone at Marginally Clever Software, Thank you both!

Share on Facebook

Forms, simplified, v3

October 1st, 2009
  • + Added form_date(), using Kevin Luck’s jQuery DatePicker.
  • ! Fixed form_static() error message.
  • ! Fixed form_select() to use set selected value.
  • ~ Changed includes to requires to force errors.
  • ! Fixed form_select() javascript died when required select had no options.

You can find it all here.

Share on Facebook

Forms, simplified, v2

September 29th, 2009
  • + Added ‘changed’ class to input_blocks
  • + Added ‘confirm_unload’ class to make per-form abandonment warnings
  • + Added __form_cancel_warning to forms.js
  • + Added __form_abandon_change_warning to forms.js
  • + Added a diskette icon to changed elements for better feedback response.
  • ~ Clarified some comments

You can find it all here.

Share on Facebook

Forms, simplified

September 28th, 2009

http://www.marginallyclever.com/forms/

A short while ago I posted about my PHP form system. People wrote in with many questions, leading me to the conclusion that the old system with it’s klunky javascript, lack of commenting, and general disarray …was not very friendly. So I’ve written a whole new library with examples, templates, better CSS, better email validation, and better url validation, not to mention code you can really use right off the shelf with a Creative Commons license. Try version 1.0 today and let me know what you think!

Share on Facebook

Little things

September 27th, 2009
before & after.

before & after.

So Friday I went down to take out the garbage while Colleen watched dinner. To get to the side door next to the trash you have to walk through the lobby, past the mailboxes and the potted plants, round the jog in the hall and out past the laundry.  If you live in a the building, you’ve walked a similar path a thousand times.  You’d have to be blind not to notice the smallest change, which is why I was surprised that on the way back something had changed.

On the wall above the mailboxes a sign had appeared:

LOST CAT

Under it was the lamp in the photo with a sticker:

FREE TO A GOOD HOME

Now, in our house we pick one thing a week to work on that’s house-related.  One week got rid of a lot of crap.  Another we labelled all the breakers and changed the sockets to be 3-prong instead of 2.

- Sometimes we fail miserably at the thing of the week.  One time we had a garage sale, got rid of some stuff, put it all back in storage and somehow we didn’t have one extra inch of room in there.  It defies mathematics.  How do you subtract one thing from another and still have the original amount?

- Anyways, where was I?  Oh right, the lamp.  So:

When I saw this I thought it might be the thing this week.

First, we tried it on the entertainment center.  It was… OK.

Then, we tried on the dresser in the bedroom.  It was… OK.

Then today I was leaning back in my chair and suddenly fell upon the wierd hook above my desk. It’s been there since I moved in. Doesn’t hold much weight. Never gets any light for a plant.  But I knew in that moment the lamp and hook were meant to be.

And I wonder at how the world put these two totally random events together for me. I wonder now this teeny random hook and that chance find in the hall have totally changed the mood in the room at night. I wonder why I was able to photograph something so dark so easily. I thought it was worth sharing to remind people to never stop trying new things.

PS: I wonder if the sign worked and the cat was found.

Share on Facebook

Gone, baby, gone.

August 26th, 2009

I will be out of communication until the 10th as I am vacationing somewhere the internet has yet to spread its ichor-dripping tentacles.

Catch y’all on the flipside!

Share on Facebook

Science ponders ‘zombie attack’

August 18th, 2009

http://news.bbc.co.uk/2/hi/science/nature/8206280.stm

“If zombies actually existed, an attack by them would lead to the collapse of civilisation unless dealt with quickly and aggressively.

That is the conclusion of a mathematical exercise carried out by researchers in Canada. “

Share on Facebook

Zombie Alert Level

August 13th, 2009

Stay alert with the National Zombie Readiness Program – Protecting the minds of tomorrow.

Share on Facebook