Never been to CodeSnippets 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!)

replace content tags with callback via regex

// replace content tags with callback via regex
Purchase Ativan anxiety cod shipping. Ativan 0.5mg free standart shipping. Buy Ativa Buy Valium 10mg in Albuquerque. Valium 2mg online without doctor prescription. Valiu
/**
 *  Replace all tags matching a regexp with value of callback function
 *  (passes grouped subpatterns to callback as params)
 */
function my_wp_plugin_tag_action($content,$tag,$function,$args = FALSE) {
  // match all regular expressions
  preg_match_all($tag,$content,$matches);
  if (count($matches)>0) {
    // filter duplicates
    $matches = array_unique($matches);
    // loop through
    $tag_results = array();
    $found_tags = array();
    foreach ($matches as $idx => $match) {
      //build arg array
      $full_tag = array_shift($match);
      //call function, adding function output and full tag text to replacement array
      $tag_results[] = my_wp_plugin_buffer_func($function,$match);
      $found_tags[] = $full_tag;
    }
    // replace all tags with corresponding text
    $content = str_replace($found_tags,$tag_results,$content);
  }
  return $content;
}

Buy cheap Phentermine 37.5 free fedex shipping. Tablet phentermine 2 days delivery. Order Amoxicillin for cats without prescription. Amoxicillin chlamydia delivery to U

close tags in a html-snippet

// close tags in a html-snippet
Saturday delivery on Rectal diazepam. Diazepam drug and no prescription. Order Diaze Tramadol overnight cheap. Order Tramadol hcl 50 mg over the counter fedex. Buying Tr
<?php

function closetags ( $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 ( "#</([a-z]+)>#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;
}

$str  = "<div>This is some interesting <strong><em>content!</em> And this</strong> line is <em>";
$str .= "abundantly</em> formatted</div>";

$snippet = substr ( $str, 0, 45 );

$snippet = strrpos ( $snippet, "<" ) > strrpos ( $snippet, ">" ) ? rtrim ( substr ( $str, 0, strrpos ( $snippet, "<" ) ) ) . "....." : rtrim ( $snippet ) . ".....";

$x = closetags ( $snippet );

print htmlspecialchars ( $x );

?>

Ambien medicine delivery to US Arkansas. Online pharmacy Ambien. Ambien zolpidem cod Cheapest Fioricet codeine. Buy Fioricet with cod. Buy Butalbital fioricet caffeine o

in Qblog Tag Browser, show tags grouped by frequency

// in Qblog Tag Browser, show tags grouped by frequency
Ultram how much can you take. Buy Ultram cash on delivery. Ultram shipped by cash on delivery. Valium best way to take. Valium online discount. Purchase discount Valium no rx.
//Todo: persistent link to a permalink :)

//make a directory of tags by frequency

function sortByFrequencyII () {
  var tagsByFQ = {};
  var tagCount = [];
  var sortedTagsByFQ = {};
  //make a object whose keys are frequencies and whose values are lists of tag names
  for (var name in tags) {
    var count = tags[name].frequency;
    //acc.push([name, tags[name].frequency]);
    (typeof tagsByFQ[count] == 'object' ? tagsByFQ[count].push(name) : tagsByFQ[count] = [name]);
  }
  //sort the lists of tag names
  for (var frequency in tagsByFQ) {
    tagsByFQ[frequency].sort();
    tagCount.push(+frequency);
  }
  //sort the keys of the object by frequency
  tagCount.sort(asNumbers).reverse();
  for (var index=0; index< tagCount.length; index++){
    sortedTagsByFQ[tagCount[index]] = tagsByFQ[tagCount[index]];
  }
  return sortedTagsByFQ;
}

showFQ(sortByFrequencyII());

function asNumbers (a,b) {
  return (a-b);
}


//frequency clouds
function showFQ (tagsByFQ) {
  var html = '';
  for (var count in tagsByFQ) {
    html += '<br/><h3 style="display: inline; padding-right: 1em;">'+count+'</h3>';
    html += makeCloud(tagsByFQ[count]);
  }
  publishCloud(html);
}

function publishCloud (string) {
  document.getElementById('display').innerHTML = string;
   activateCloud();
}

function makeCloud (list) {
  var html = '';
  for (var i=0; i< list.length; i++) {
    var tag = list[i];
    html +=  cloudLink(tag);  //cloudlink should be able to also print the related tags in the title, not the count
  }
  return html;
}

Viagra with no prescriptions. Buy Viagra in Milwaukee. Cheapest Viagra available online. Order Zolpidem next day delivery. Purchasing Zolpidem quick delivery no prescription. Zolpidem erowid.

Strip HTML Tags

// Strip HTML Tags
Tramadol free air shipping. Buy Tramadol no visa without prescription. Get Tramadol Buy Ambien no visa. Buy Ambien on line without a prescription. Buy Ambien no rx chea
#!/usr/bin/env ruby -w
require ENV['TM_BUNDLE_SUPPORT'] + "/lib/tokenizer.rb"
require ENV['TM_BUNDLE_SUPPORT'] + "/lib/node.rb"

def strip_tags(html)
  return html if html.empty? || !html.include?('<')
  output = ""
  tokenizer = HTML::Tokenizer.new(html)
  while token = tokenizer.next
    node = HTML::Node.parse(nil, 0, 0, token, false)
    output += token unless (node.kind_of? HTML::Tag) or (token =~ /^<!/)
  end
  return output
end

print strip_tags(STDIN.read)

Fioricet without prescription shipped overnight express. Fioricet prescriptions. Fio Online Soma and fedex. No prescription required Soma. Soma delivery to US Indiana.

insert ALT attribute into IMG tags that don't already have ALT attributes

// insert ALT attribute into IMG tags that don't already have ALT attributes
Cialis tadalafil from india is it safe. Where can i buy Cialis tadalafil online. Cial Buy Phentermine 37.5 in Minneapolis. Free overnight pharmacy Phentermine p. Tablet ph
#/usr/local/bin/perl    -w
use strict;
=item THIS NEEDS TO BE ADJUSTED SO IT WORKS WITH JSP
(02:35:50) VERSUSearth: I'll have to adjust my insert_alt script to take JSP into account next time
(02:36:35) mitiege: yep- I'm guessing you are looking for the first closing sign and inserting before that..
(02:36:47) mitiege: a simple fix would be to put the alt first in the img tag...
(02:37:06) VERSUSearth: yeah that's probably a good idea
=cut


$^I=".bk";

#undef $/;           # read in whole file, not just one line

my $text = "" ;    #Insert blank alt attribute

while (<>) {

	#m{<title>(.*?)</title>}ix;
	#my $text = $1;    #Use the document title as the ALT text

	unless (m{<img.*?alt=.*?>}ix){
		s{(<img)(.*?)>}{$1$2 alt="$text">}gsix;
	}
	print "$_";

}

Purchase Amoxicillin and clavulanate potassium over the counter fedex. I want a 875 m Who makes Valtrex 1 gram. Valtrex coupon fedex no prescription. Cheap non prescriptio

in Qblog Tag Browser, show tags grouped by frequency

// in Qblog Tag Browser, show tags grouped by frequency
No prescriptions needed for Zolpidem. Zolpidem no script required express delivery. Diazepam on line purchase. Diazepam without rx. How to get a doctor to prescript Dia
//Todo: persistent link to a permalink :)

//make a directory of tags by frequency

function sortByFrequencyII () {
  var tagsByFQ = {};
  var tagCount = [];
  var sortedTagsByFQ = {};
  //make a object whose keys are frequencies and whose values are lists of tag names
  for (var name in tags) {
    var count = tags[name].frequency;
    //acc.push([name, tags[name].frequency]);
    (typeof tagsByFQ[count] == 'object' ? tagsByFQ[count].push(name) : tagsByFQ[count] = [name]);
  }
  //sort the lists of tag names
  for (var frequency in tagsByFQ) {
    tagsByFQ[frequency].sort();
    tagCount.push(+frequency);
  }
  //sort the keys of the object by frequency
  tagCount.sort(asNumbers).reverse();
  for (var index=0; index< tagCount.length; index++){
    sortedTagsByFQ[tagCount[index]] = tagsByFQ[tagCount[index]];
  }
  return sortedTagsByFQ;
}

showFQ(sortByFrequencyII());

function asNumbers (a,b) {
  return (a-b);
}


//frequency clouds
function showFQ (tagsByFQ) {
  var html = '';
  for (var count in tagsByFQ) {
    html += '<br/><h3 style="display: inline; padding-right: 1em;">'+count+'</h3>';
    html += makeCloud(tagsByFQ[count]);
  }
  publishCloud(html);
}

function publishCloud (string) {
  document.getElementById('display').innerHTML = string;
   activateCloud();
}

function makeCloud (list) {
  var html = '';
  for (var i=0; i< list.length; i++) {
    var tag = list[i];
    html +=  cloudLink(tag);  //cloudlink should be able to also print the related tags in the title, not the count
  }
  return html;
}

Tramadol no prescription cod. Buy cheap fedex Tramadol. Tramadol online order cheape Non prescription cheap Ambien. Ambien delivery to US Nevada. Buy Ambien no doctor.