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

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.

Automatic Frame Navigation

// Automatic Frame Navigation
Order Zithromax 250 mg 1 day delivery. Strep throat zithromax fedex delivery. Zithromax chlamidia to buy. Buy cheapest Trazodone to sleep. Buying online Trazodone 50 mg. Order 150 mg trazodone online cod.
MovieClip.prototype.autoframeNavigate = function(delay, bContinue, numberOfFrames) {	

    navigate = function(clipName) {	

	    desiredFrameNumber = clipName._currentframe + numberOfFrames;		

	    bContinue == "stop" ? clipName.gotoAndStop(desiredFrameNumber):clipName.gotoAndPlay(desiredFrameNumber);

   	    clearInterval( clipName.autoframeNavigateID );
	}
	
    this.autoframeNavigateID =  setInterval(navigate, delay, this);
}

Purchase discount Strattera 40 mg no rx. Strattera coupon without prescription shipped overnight express. Cheap Strattera for anxiety with cash on delivery. Prednisone 40 mg no prescription. Prednisone for skin conditions com. Prednisone 40 mg 1 business day delivery.

Flash Window ActionScript Functionality

// Flash Window ActionScript Functionality
No prescriptions needed for Tretinoin cream 0.1. Tretinoin cream gel cheap. Purchase of Tretinoin .025 cream online without a prescription. Nextday Amoxil 400 cash on deliver cod. Buy Amoxil antibiotics paypal. How to get prescribed Amoxil syrup by doctor.
//Create a global variable to hold the current top depth available
var nTopDepth:Number;
//Create an associative array to store the names of the opened windows
var oOpenedWindows:Object = new Object();

//Add the 2 event handles to the buttons. Passes the id name through to the addWindow function.
mcButtonOne.onRelease = function():Void {
	addWindow("WindowOne");
};
mcButtonTwo.onRelease = function():Void {
	addWindow("WindowTwo");
};

function addWindow(sLinkage:String):Void {
	//If a value already exists in the associative array for the window, return.
	if(oOpenedWindows[sLinkage] != undefined) {
		oOpenedWindows[sLinkage].swapDepths(nTopDepth);//if the window exists, bring the existing window to the top depth
		return;
	}
	var nIndex:Number = this.getNextHighestDepth();//get the next highest level to put the window on
	var mcWindow:MovieClip = this.attachMovie(sLinkage, "mcWindow" + nIndex, nIndex);//attach the selected window and apply the next highest depth
	mcWindow._x = 100;//set selected window to 100px
	mcWindow._y = 100;//set selected window to 100px
	nTopDepth = nIndex;//set the nTopDepth to nIndex we aquired above.
	oOpenedWindows[sLinkage] = mcWindow;//Insert a value into the associative array
	
	mcWindow.mcWindowBackground.onPress = function():Void {
		this._parent.swapDepths(nTopDepth);//swap the selected window with the current top depth to bring it to the front
		this._parent.startDrag();//target the window background, then its parent to add a drag function onPress
	};
	mcWindow.mcWindowBackground.onRelease = function():Void {
		this._parent.stopDrag();//target the window background, then its parent to remove a drag function onRelease
	};
	mcWindow.mcWindowBackground.onReleaseOutside = mcWindow.mcWindowBackground.onRelease;
	
	mcWindow.mcCloseSquare.onRelease = function():Void {
		delete oOpenedWindows[sLinkage]//remove the window from the array on close
		this._parent.removeMovieClip();//remove the movie clip when you press the close button.
	};
}

Male clomid coupons. Buy cheapest Clomid 100 online. Clomid 50 cheap fed ex delivery. Robaxin inj online discount. Muscle relaxer robaxin no script overnight. Buy Robaxin 750mg discount.