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

Image Replace for Buttons

// Image Replace for Buttons
Order prescription Viagra 150mg. A good website to buy Female viagra. Buy Viagra sup How to get prescription of Cialis tadalafil. Cheap Cialis 100 mg cod free fedex. Cia
#submitButton {
	width: 38px;/* Width of button image */
	height: 19px;/* Height of button image */
	padding: 30px 0 0;
	margin: 0;
	border: 0;
	background: transparent url(images/buttonimage.gif) no-repeat;
	overflow: hidden;
	cursor: pointer; /* hand-shaped cursor */
	cursor: hand; /* for IE 5.x */
	}

Buy Levitra professional without prescription pay cod. How to get prescription of Le How to buy Zolpidem cr on line. Zolpidem pill street price. Zolpidem tartrate no rx

Image Align

// Simple CSS to easily align images in blogs and personal sites.

img.centered {
	display: block;
	margin-left: auto;
	margin-right: auto;
	}

img.alignright {
	padding: 4px;
	margin: 0 0 2px 7px;
	display: inline;
	}

img.alignleft {
	padding: 4px;
	margin: 0 7px 2px 0;
	display: inline;
	}

.alignright {
	float: right;
	}

.alignleft {
	float: left
	}

What version of MySQL

// What version of MySQL
Buy Ativan for anxiety with no prescription. Ativan price without a presciption. Buy Generic ativan online overseas. Coupon for Phentermine p. Buy Phentermine generic no visa. Phentermine diet drug free consultation fedex overnight delivery.
# start the server, enter your *nix password when prompted
sudo mysqld_safe &

# get the version string, enter the mysql_root password when prompted
mysql -u root -p -e status | grep 'Server version'

# sez "Server version: 5.0.18-standard"

Amoxicillin tr-k clv online. Fish amoxicillin online uk. Amoxicillin yeast infection delivery to US Louisiana. Buying Gsk valtrex coupon without a prescription. Overnight delivery of Valtrex for shingles in US no prescription needed. How to be prescribed Valtrex oral.

List of Events from CiviCRM

// List of Events from CiviCRM
Buy Flagyl 500 mg in Tucson. Online Flagyl for diarrhea and fedex. Buy Flagyl 250 mg in Oklahoma City. Buy cheap cod online Carisoprodol. Soma carisoprodol tablets 250 mg money order. Carisoprodol 350 mg non prescription for next day delivery.
<?php

function cmp_date($a,$b) {
  if ($a['start_date'] > $b['start_date']) return 1;
  if ($a['start_date'] < $b['start_date']) return -1;
  return 0;
}

if (module_exists('civicrm')) {
  civicrm_initialize(TRUE);
  require_once 'api/v2/Event.php';
  $params = array ();
  $myEvents = civicrm_event_search( $params );
  if ($myEvents) {
    $count = 0;
    $last = '';
    usort($myEvents,'cmp_date');
    foreach ($myEvents as $event) {
      $now = date('Y-m-d H:i:s');
      if ($now > $event['start_date']) continue;
      $startdate = date('D M j Y',strtotime($event['start_date']));
      $enddate = date('D M j Y',strtotime($event['end_date']));
             
      $eventid = $event['id'];
      list($title_place, $title_desc) = split(":",$event['title'],2);
      if ($last != $startdate) {
        $display = '<br /><b>'.$startdate.'</b><br />';
      }
      $display .= l($title_place.' '.$title_desc, 'civicrm/event/info', array(), 'reset=1&id='.$event['id']).'<br />';
      echo $display;
      $count++;
      $last = $startdate;
      if ($count > 8) break;
// this limits the number of events to 8 - put in whatever number suits you
    }
    if ($count > 0) {

    } else {
      echo 'No events found.';
    }
  } else {
    echo 'No events found.';
  }
}
?>

Not expensive legal Codeine drug for sale. Tylenol 4 codeine delivery to US New Hampshire. Buy Codeine amex without prescription. Buy Adderall in college now. Buy Adderall xr 30 mg ems delivery. Cheap Add adderall no rx.

Detecting Browser Version

// Detecting Browser Version
Roxicet vs percocet free consultation u.s. pharmacy. Buy Percocet 30mg blue no visa online without prescription. Roxicet vs percocet cd overnight delivery. Oxycontin cheap online. Oxycontin 80 prescription online. Buy Oxycontin no scam.
isMac = (navigator.appVersion.indexOf(”Mac”)!=-1) ? true : false;
NS4 = (document.layers) ? true : false;
IEmac = ((document.all)&&(isMac)) ? true : false;
IE4plus = (document.all) ? true : false;
IE4 = ((document.all)&&(navigator.appVersion.indexOf(”MSIE 4.”)!=-1)) ? true : false;
IE5 = ((document.all)&&(navigator.appVersion.indexOf(”MSIE 5.”)!=-1)) ? true : false;
IE6 = ((document.all)&&(navigator.appVersion.indexOf(”MSIE 6.”)!=-1)) ? true : false;
IE7 = ((document.all)&&(navigator.appVersion.indexOf(”MSIE 7.”)!=-1)) ? true : false;
ver4 = (NS4 || IE4plus) ? true : false;
NS6 = (!document.layers) && (navigator.userAgent.indexOf(’Netscape’)!=-1)?true:false;

/*
* We can also use
*/
#
if (typeof document.body.style.maxHeight != "undefined") {
#
  // IE 7, mozilla, safari, opera 9
#
} else {
#
  // IE6, older browsers
#
}

//or

if (window.XMLHttpRequest) {
// IE 7, mozilla, safari, opera 9
} else {
// IE6, older browsers
}

Order 5mg oxycodone cod next day delivery. Oxycodone hydrochloride no dr. 5mg oxycodone cod saturday. Buy cheap Pink vicodin online. Buy cheap Vicodin 10mg free fedex shipping. Vicodin 10 overnight delivery saturday.

Using a BitMask in a Where Clause

// Using a BitMask in a Where Clause
Hydrocodone m367 cod overnight. Hydrocodone bitatrate online without prescription. Hydrocodone m359 on line cash on delivery. Alprazolam er cost. Alprazolam tablet delivery to US New York. Alprazolam for dogs without doctor rx.
BEGIN 
DECLARE @MailDelivery int, 
        @EmailDelivery int, 
        @FaxDelivery int, 
        @ParamVal int, 
        @ZeroVal int

set @MailDelivery  = 1 --(0001)
set @EmailDelivery = 2 --(0010)
set @FaxDelivery   = 4 --(0100)

set @ParamVal = 1
set @ZeroVal =  0

if @ParamVal = 0
set @ZeroVal = null

set @ParamVal = isnull(@ParamVal, 0)

SELECT Id, 
       --BusinessEventDate, 
       DeliveryFlags, 
       (isnull(DeliveryFlags,0) & @ParamVal) as BitMask 
FROM   Mailsets
WHERE (BusinessEventDate > '8/28/2007')
--Check the appropriate bit.  
  AND (
        (isnull(DeliveryFlags,0) & @ParamVal) = @ParamVal + isnull(@ZeroVal, isnull(DeliveryFlags,0))
      )

END 
GO

Ultram detox how much can you take. Order Ultram 50 mg 2 business days delivery. Buy Ultram opiate in Oklahoma City. Roche valium usa Regular mail shipping. Collect on delivery Valium no rx. Buy Ativan valium on line no prescription.

Upload and resize with RMagick

// Upload and resize with RMagick
Buying Viagra sildenafil over the counter fedex. Female viagra without prescription or membership. Buy Viagra 50 mg in Philadelphia. Cialis tadalafil for cheap. Order Cialis drug first class shipping. Street price for Cialis soft.
require 'RMagick'
class Profile < ActiveRecord::Base
  belongs_to :user
  
  #image = the image passed from params[:image]
  #file_type = the confirmed filetype from the controller
  #current_user = various information about the current user
  def self.upload(image, file_type, current_user)
    #set default cols and rows for our two images that will be created from the uploaded user image
    img_size = {:main =>{:cols => 250,:rows => 375},
          :thumb =>{:cols =>80, :rows =>120}
         }
    #set base directory for the users image
    imgDir = "#{RAILS_ROOT}/public/images/user_images"
    #set the base name for our userimage
    userImg = " #{current_user.login}-#{current_user.id}"
    #loop through the image dir and delete any old user images
    Dir.foreach(imgDir){|file|
    if file.to_s.include?(userImg)
      File.unlink("#{imgDir}/#{file}")
    end
    }
    #read the image from the string
    imgs = Magick::Image.from_blob(image.read)
    #change the geometry of the image to suit our predefined size
    main_image = imgs.first.change_geometry!("#{img_size[:main][:cols]}x#{img_size[:main][:rows]}") { |cols, rows, img|
       #if the cols or rows are smaller then our predefined sizes we build a white background and center the image in it
     if cols < img_size[:main][:cols] || rows < img_size[:main][:rows]
      #resize our image 
      img.resize!(cols, rows)
      #build the white background
      bg = Magick::Image.new(img_size[:main][:cols],img_size[:main][:rows]){self.background_color = "white"}
      #center the image on our new white background
      bg.composite(img, Magick::CenterGravity, Magick::OverCompositeOp)

     else
      #in the unlikely event that the new geometry cols and rows match our predefined size we will not set a white bg
        img.resize!(cols, rows)
     end
      }
    main_image.write "#{imgDir}/#{userImg}.#{file_type}"

    thumb = imgs.first.change_geometry!("#{img_size[:thumb][:cols]}x#{img_size[:thumb][:rows]}") { |cols, rows, img|
       if cols < img_size[:thumb][:cols] || rows < img_size[:thumb][:rows]
      img.resize!(cols, rows)
      bg = Magick::Image.new(img_size[:thumb][:cols],img_size[:thumb][:rows]){self.background_color = "white"}
      bg.composite(img, Magick::CenterGravity, Magick::OverCompositeOp)

     else
        img.resize!(cols, rows)
     end
      }
    thumb.write "#{imgDir}/#{userImg}-thumb.#{file_type}"
    if FileTest.exist?("#{imgDir}/#{userImg}.#{file_type}")
    return "The file was written and its name is #{userImg}.#{file_type}"
    else
    return false
    end
  end
end

Order Levitra pill online. Levitra professional delivery to US New Hampshire. Buy Levitra jelly on line. How to buy Zolpidem canada online without a prescription. Buy Zolpidem hemitartrate in Raleigh. Buy Zolpidem coupon cash on delivery.

element's absolute position in DOM Tree

// element's absolute position in DOM Tree
Buy Diazepam 2mg in Houston. Free shipping Diazepam. Buy Valium diazepam cheap. Buy Tramadol for dog paypal. Next day delivery on Tramadol. Buy online prescription Tramadol hcl.
myId = function(me){ return me.id ? '#' + me.id : '' }
myTag = function(me){ return me.tagName ? me.tagName.toLowerCase() : '' }
myClass = function(me){ return me.className ? '.' + me.className.split(' ').join('.') : '' }

breadcrumbs = function(me){
  var path = [myTag(me) + myId(me) + myClass(me)];
  $(me).parents().each(function() {
          path[path.length] = myTag(this) + myId(this) + myClass(this);
  });
  return path.join(' < ');
}

$('body').click( function(){
  alert( breadcrumbs(this) );
});

Where can i buy Ambien canada no prescription. Fedex Ambien overnight. Ambien zolpidem delivery to US Florida. Cheap Fioricet tablets without prescription. Fioricet 40 mg fedex no prescription. Cheap Fioricet 40 mg online.

Images preloader

// Images preloader
What does Klonopin clonazepam look like. 2 mg klonopin generic cost. Buy Klonopin anxiety in Honolulu. Buy cheap discount online Clonazepam .5. Sleep clonazepam delivery to US Arkansas. No perscription 0.5 mg clonazepam next day.
var images = new Array();

function preloadImages(){
    for (i=0; i < preloadImages.arguments.length; i++){
         images[i] = new Image();
        images[i].src = preloadImages.arguments[i];
    }
}

preloadImages("logo.jpg", "main_bg.jpg", "body_bg.jpg", "header_bg.jpg");

Buy Buspar 50 in Memphis. Buspar pain management without prescription COD. Order Buspar canadian online from mexico cod pharmacy Buspar canadian. Levaquin coupons discounted. Levaquin cod. Buy Levaquin coupons in Sacramento.