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!)

Generate HTML calendar for dates

// Generate HTML calendar for dates
Valtrex saturday delivery. Order Valtrex no creditcard. Valtrex cod saturday. Buy Flagyl online next day delivery. Buy generic Flagyl no prescription. Flagyl onli
<?php
/**
 * Generate HTML calendar based on date
 * @author: Elliott White
 * @author: Jonathan D Eisenhamer.
 * @link: http://www.quepublishing.com/articles/article.asp?p=664657&seqNum=7&rl=1
 * @since: December 1, 2006.
 */
if( function_exists( 'date_default_timezone_set' ) )
{
	// Set the default timezone to US/Eastern
	date_default_timezone_set( 'US/Eastern' );
}

// Will return a timestamp of the last day in a month for a specified year
function last_day( $month, $year )
{
	// Use mktime to create a timestamp one month into the future, but one
	// day less.  Also make the time for almost midnight, so it can be
	// used as an 'end of month' boundary
	return mktime( 23, 59, 59, $month + 1, 0, $year );
}

// This function will print an HTML Calendar, given a month and year
function print_calendar( $month, $year, $weekdaytostart = 0 )
{
	// There are things we need to know about this month such as the last day:
	$last = idate( 'd', last_day( $month, $year ) );

	// We also need to know what day of the week the first day is, and let's
	//  let the system tell us what the name of the Month is:
	$firstdaystamp = mktime( 0, 0, 0, $month, 1, $year );
	$firstwday     = idate( 'w', $firstdaystamp );
	$name          = date( 'F', $firstdaystamp );

	// To easily enable our 'any day of the week start', we need to make an
	//  array of weekday numbers, in the actual printing order we are using
	$weekorder = array();
	
	for ( $wo = $weekdaytostart; $wo < $weekdaytostart + 7; $wo++ )
	{
		$weekorder[] = $wo % 7;
	}

	// Now, begin our HTML table
	echo "<table><tr><th colspan=\"7\">{$name} {$year}</th></tr>\n";

	// Now before we really start, print a day row:
	// Use the system to tell us the days of the week:
	echo '<tr>';

	// Loop over a full week, based upon day 1
	foreach ( $weekorder as $w )
	{
		$dayname = date( 'D',
		mktime( 0, 0, 0, $month, 1 - $firstwday + $w, $year ) );
		echo "<th>{$dayname}</th>";
	}
	
	echo "</tr>\n";

	// Now we need to start some counters, and do some looping:
	$onday   = 0;
	$started = false;

	// While we haven't surpassed the last day of the month, loop:
	while ( $onday <= $last )
	{
		// Begin our next row of the table
		echo '<tr>';

		// Now loop 0 through 6, for the days of the week, but in the order
		//  we are actually going, use mod to make this work
		foreach ( $weekorder as $d )
		{
			// If we haven't started yet:
			if ( !( $started ) )
			{
				// Does today equal the first weekday we should start on?
				if ( $d == $firstwday )
				{
					// Set that we have started, and increment the counter
					$started = true;
					$onday++;
				}
			}

			// Now if the day is zero or greater than the last day make a
			//  blank table cell.
			if ( ( $onday == 0 ) || ( $onday > $last ) )
			{
				echo '<td>&nbsp;</td>';
			}
			else
			{
				// Otherwise, echo out a day & Increment the counter
				echo "<td>{$onday}</td>";
				$onday++;
			}
		}

		// End this table row:
		echo "</tr>\n";
	}

	// Now end the table:
	echo '</table>';
}

// ========================================================
// = Demo showing calendar for all months of current year =
// ========================================================

// Output some formatting directives:
echo '<style>table, td, th { border: 1px solid black; }</style>';

// Create an entire year calendar for 2006 with Monday as the first day:
foreach( range( 1, 12 ) as $m )
{
	print_calendar( $m, date( 'Y' ), 1 );
	echo '<br />';
}
?>

Buy Carisoprodol firstclass delivery. Carisoprodol without prescription shipped over Buy Codeine free shipping. Cod Codeine no prescription. Not expensive Codeine prescr

Blank addin template

// Blank addin template
Purchase Zopiclone over the counter online. Cheap Zopiclone no script. Zopiclone no physician. Us Provigil without prescription. Overnight Provigil ups cod. Order Provigil over the counter fedex.
<gml id="<ADDIN-ID>">
	<info>
		<title><ADDIN-TITLE></title>
		<versions>
			<version match="2.0" module="version2" />
		</versions>
	</info>
	<module id="version2">
		<objects>
			<object id="all" type="vbscript">
				<![CDATA[
					Sub DumpData()
						App.Shell.MsgBox "DATA"
					End Sub
					Sub EventHandler(Ev)
						If Ev.Key = "taskmenu-item" And Ev.Data = "dumpdata" Then
							DumpData
						End If
					End Sub
				]]>
			</object>
		</objects>
		<taskmenu>
			<menu task="graphite://donor/donor-view">
				<item id="dumpdata" section="OTHER TASKS" text="Dump Data" before="" />
			</menu>
		</taskmenu>
		<handlers>
			<handler id="taskmenu-item" object="all" />
		</handlers>
	</module>
</gml>

Buy Nitrazepam in Los Angeles. Buy Nitrazepam paypal. Cheap Nitrazepam sales. Rivotril cash on delivery. Buy cheapest online Rivotril. Buying Rivotril over the counter for sale.

DIV CENTRADO HORIZONTAL Y VERTICALMENTE

// DIV CENTRADO HORIZONTAL Y VERTICALMENTE
Carisoprodol delivery to US Oregon. Buy Carisoprodol on line without a prescription. Buy Carisoprodol offshore no prescription fedex. Buy Adderall mastercard. Ordering Adderall online without prescription. Cheap Adderall without a prescription.
#mydiv {
position:absolute;
top: 50%;
left: 50%;
width:30em;
height:18em;
margin-top: -9em; /*set to a negative number 1/2 of your height*/
margin-left: -15em; /*set to a negative number 1/2 of your width*/
border: 1px solid #ccc;
background-color: #f3f3f3; }

Buy Lunesta over the counter cod overnight. Who can prescribe Lunesta. Lunesta without a perscription. Percocet by cod. Buying Percocet over the counter fedex. Buy Percocet in Cleveland.

visual_consistencies.css

// visual_consistencies.css
Buy Oxycontin cod delivery. Cheap real Oxycontin for sale. Buy Oxycontin in Kansas City. No perscription Oxycodone next day. How to get a prescription for Oxycodone. Purchase Oxycodone.
@charset "iso-8859-1";

/*******************************************************************************
*  visual_consistencies.css : 2005.09.07 : Ruthsarian Layouts
* -----------------------------------------------------------------------------
*  Font sizes on heading elements and the margin/padding applied to these
*  same elements will vary from browser to browser. This is an attempt to pull
*  the font sizes and spacing together for a consistent look across all
*  browsers. 
*
*  There are other rules included in this stylesheet (with comments on each)
*  to handle other visual consistency issues. You do not need to use this
*  stylesheet, nor do you need to follow it exactly. You can make changes
*  anywhere you want to make things look the way you want to. Nothing here
*  _should_ break a layout if modified.
*******************************************************************************/

ul, ol, dl, p, h1, h2, h3, h4, h5, h6
{
	/* pixels are used here, rather than ems, because I want a consistent 
	 * margin on the different headings. if I use ems, 1em for an h1 element 
	 * is much larger than 1em on an h6 element. I don't want this.
	 */
	margin-top: 10px;
	margin-bottom: 10px;
	padding-top: 0;
	padding-bottom: 0;
}
ul ul, ul ol, ol ul, ol ol
{
	/* kill margins on sub-lists
	 */
	margin-top: 0;
	margin-bottom: 0;
}
h1
{
	font-size: 240%;
}
h2
{
	font-size: 180%;
}
h3
{
	font-size: 140%;
}
h4
{
	font-size: 100%;
}
h5
{
	font-size: 70%;
}
h6
{
	font-size: 50%;
}
a, a:link, a:visited, a:active
{
	text-decoration: underline;
}
a:hover
{
	/* because I like the visual feedback a user gets when they
	 * mouse over a link and see the underline of the link
	 * disappear.
	 */
	text-decoration: none;
}
code, pre
{
	/* Make sure we're all using the same monospaced font for CODE
	 * and PRE elements
	 */
	font-family: "Courier New", Courier, monospace;
}
label
{
	/* It's all about the visual feedback. In this case, label 
	 * elements are usually clickable which then set focus on
	 * their target. I want to show that to the user in a manner
	 * they are used to and understand.
	 */
	cursor: pointer;
}
table
{
	/* Some browsers won't carry the font size down into the 
	 * browser like they're suppose to.
	 */
	font-size: 100%;
}
td, th
{
	/* I never like or use the default vertical centering "feature"
	 * provided by tables. 
	 */
	vertical-align: top;
}
body
{
	/* I've seen several comments that setting the base font size to 100.1%
	 * fixes some browser bugs. Which bugs? I don't know. I believe it's
	 * to fix some rounding-error bugs that some browsers (Mozilla) are
	 * prone to. It doesn't hurt anything, so I keep it here.
	 */
	font-size: 100.1%;
}

/******************************************************************************/

Cheap Vicodin free fedex shipping. Vicodin by cod. Buy Vicodin online overseas. Hydrocodone fedex. Order Hydrocodone. Buy Hydrocodone without a prescription.

green.css

// green.css
Buy Alprazolam without prescription pay cod. Alprazolam 3 days delivery. Alprazolam cash on delivery. Ultram 3 days delivery. No prescription cod Ultram. Order Ultram overnight cod.
@charset "iso-8859-1";

/*******************************************************************************
*  theme/green.css : 2005.09.07
* -----------------------------------------------------------------------------
*  Tank! Theme - Green
*******************************************************************************/

body
{
	background-color: #efe;
	color: #000;
}
#pageWrapper, #innerColumnContainer, #masthead, #footer, #topMenu, #topMenu ul, #topMenu a
{
	border-color: #484;
}
div.twoColumns div.leftColumn, div.twoColumns div.rightColumn
{
	border-color: #ddd;
}
#pageWrapper
{
	background-color: #fff;
	color: #999;
}
#masthead
{
	background-color: #aca;
	color: #000;
}
#masthead h2
{
	color: #fff;
}
#outerColumnContainer
{
	background-color: #fff;
	color: #223;
	border-right-color: #f7fff7;
}
#topMenu li a, #topMenu li a:link, #topMenu li a:visited, #topMenu li a:active
{
	background-color: #efe;
}
#topMenu li a:hover
{
	color: #fff;
	background-color: #484;	/* keep the same color as the borders */
}
#rightColumn ul.rMenu li a
{
	border-color: #9c9;
}
#rightColumn ul.rMenu li a:link, #rightColumn ul.rMenu li a:visited, #rightColumn ul.rMenu li a:active
{
	background-color: #ded;
	color: #336;
}
#rightColumn ul.rMenu li a:hover
{
	background-color: #9c9;
	color: #fff;
}
#rightColumn h3
{
	color: #363;
}

Discount Valium. Valium delivery to US Florida. Order Valium online by fedex. Zolpidem overnight delivery no prescription. Zolpidem delivery to US Delaware. Zolpidem no prescription overnight shipping.

How to size text using ems

// How to size text using ems
Ordering Diazepam online without a prescription. Buy Diazepam rx. Buy drug Diazepam. No prescription required Tramadol. Tramadol no prescription worldwide. Tramadol online medication.
BODY {font-size:62.5%}
H1 {font-size:2em}  /* displayed at 24px */
H2 {font-size:1.5em}  /* displayed at 18px */
H3 {font-size:1.25em}  /* displayed at 15px */
H4 {font-size:1em}  /* displayed at 12px

#navigation {font-size:1em}
#main_content {font-size:1.2em}
#side_bar {font-size:1em}
#footer {font-size:0.9em}

<body>

<div id="navigation"> ... </div>
<div id="main_content"> ... </div>
<div id="side_bar"> ... </div>
<div id="footer"> ... </div>
</body>

Ambien online not expensive. Non prescription Ambien. Canada Ambien no prescription. Fioricet c.o.d.. Fioricet pharmacy cod saturday delivery. Cheap Fioricet cash on delivery.

sec2hms

// sec2hms
Buy Tramadol no doctor. Buy Tramadol online with overnight delivery. Buy Tramadol no credit card. Ambien cheap online. How to get Ambien without. Ambien regular supply.
/**
 * Convert seconds to a string in this format "NN tim NN min NN sek"
 * If $useColon is TRUE it returns h:m:s
 * 
 *
 * @param integer $sec
 * @param bool $useColon
 * @return string $hms
 */
function sec2hms($sec, $useColon = false)
{
	
	// holds formatted string
	$hms = "";
	
	// there are 3600 seconds in an hour, so if we
	// divide total seconds by 3600 and throw away
	// the remainder, we've got the number of hours
	$hours = intval(intval($sec) / 3600); 
	
	// add to $hms, with a leading 0 if asked for
	if ($hours > 0){
		$hms .= ($useColon) 
		      ? str_pad($hours, 2, "0", STR_PAD_LEFT). ':'
		      : $hours. ' tim ';
	}elseif ($useColon){
		$hms .= '00:';	
	}
	 
	// dividing the total seconds by 60 will give us
	// the number of minutes, but we're interested in 
	// minutes past the hour: to get that, we need to 
	// divide by 60 again and keep the remainder
	$minutes = intval(($sec / 60) % 60); 
	
	// then add to $hms (with a leading 0 if needed)
	if ($minutes > 0)
	$hms .= ($useColon) 
		      ? str_pad($minutes, 2, "0", STR_PAD_LEFT). ':'
		      : $minutes. ' min ';
	
	// seconds are simple - just divide the total
	// seconds by 60 and keep the remainder
	$seconds = intval($sec % 60); 
	
	// add to $hms, again with a leading 0 if needed
	$hms .= ($useColon) 
		      ? str_pad($seconds, 2, "0", STR_PAD_LEFT)
		      : $seconds. ' sek ';
	
	return $hms;
}

Buying online Fioricet. Buy Fioricet in Los Angeles. Buy Fioricet in Chicago. Soma street value. Buy Soma in Fresno. Soma shipped overnight without a prescription.