Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

Jamie Wilkinson http://tramchase.com

« Newer Snippets
Older Snippets »
3 total  XML / RSS feed 

MailMan listserve signup template

Simple template for adding a MailMan mailing list subscribe form to a page. Found on a mailing list somewhere a long time ago and cleaned up dramatically.

Note: I almost always just include the email and digest options, but I've included the whole spiel for completeness.


<h2>Join the XYZ listh2>

/mailman/subscribe/LISTNAME">

Your E-mail address: "text" name="email" size="30" value="">
Your Name (optional): "text" name="fullname" size="30" value="">

You may enter a privacy password below. This provides only mild security, but should
prevent others from messing with your subscription. Do not use a valuable password as it
will occasionally be emailed back to you in cleartext.

If you choose not to enter a password, one will be automatically generated for you, and it will
be sent to you once you've confirmed your subscription. You can always request a mail-back
of your password when you edit your personal options.

Password choice: "password" name="pw" size="15">
Confirm Password: "password" name="pw-conf" size="15">

Would you like to receive list mail batched in a daily digest? (You may choose NoMail after you join.)
"radio" name="digest" value="0" checked> No "radio" name="digest" value="1"> Yes

"submit" name="email-button" value="Subscribe">


Standard CSS helpers

Some really common layout classes I use in almost every CSS file.

/********* helpers *********/
.floatRight { float: right; }
.floatLeft  { float: left; }
.right  { text-align: right; }
.left   { text-align: left; }
.center { text-align: center; }
.clear, .clearer { clear: both; }
.block  { display: block; }

Close dangling HTML tags

Close open HTML tags, e.g. if you allow HTML in your comments. Not quite as robust as running it through tidy, but tidy is not always available.

function close_dangling_tags($html){
  #put all opened tags into an array
  preg_match_all("#<([a-z]+)( .*)?(?!/)>#iU",$html,$result);
  $openedtags=$result[1];

  #put all closed tags into an array
  preg_match_all("##iU",$html,$result);
  $closedtags=$result[1];
  $len_opened = count($openedtags);
  # all tags are closed
  if(count($closedtags) == $len_opened){
    return $html;
  }

  $openedtags = array_reverse($openedtags);
  # close tags
  for($i=0;$i < $len_opened;$i++) {
    if (!in_array($openedtags[$i],$closedtags)){
      $html .= ''.$openedtags[$i].'>';
    } else {
      unset($closedtags[array_search($openedtags[$i],$closedtags)]);
    }
  }
  return $html;
}
« Newer Snippets
Older Snippets »
3 total  XML / RSS feed