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

PHP Array To JSON String

// PHP Array To JSON String
Ativan for dogs 2 business days delivery. Online Ativan for anxiety no prescription Generic Phentermine 90 online. Cheapest Phentermine 37.5 online. Phentermine 37.5 de
function array_to_json_string($arraydata) {
		$output = "";
		$output .= "{";
		foreach($arraydata as $key=>$val){
			if (is_array($val)) {
				$output .= "\"".$key."\" : [{";
					foreach($val as $subkey=>$subval){
						$output .= "\"".$subkey."\" : \"".$subval."\",";
					}
				$output .= "}],";
			} else {
				$output .= "\"".$key."\" : \"".$val."\",";
			}
		}
		$output .= "}";
		return $output;
	}

Buy Amoxicillin augmentin online cash on delivery. Buy Amoxil amoxicillin cod accept Buy overnight Valtrex oral tablet 1 gm. Online pharmaceutical Valtrex 1000mg cost. B

101 to using Time in Ruby

// 101 to using Time in Ruby
Buy Iv lasix in Mesa. Lasix online consultation overnight. Buy Lasix for canine onlin Buy Propranolol 20mg online cheap. Buy cheap cod online Propranolol. Propranolol buy
#Find out the Current Time
t = Time.now

#Find out the Month, Day, or Year individually
puts t.mon.to_s + "/" + t.day.to_s + "/" + t.year.to_s

#Find out the UTC
puts t.utc

###########################
#User Formatted Characters
###########################
#the String For Time function allows you to mix text with data
puts t.strftime("The Document print data is %m/%d/%Y")

#Another way to Display the Month Day, Year
puts t.strftime("%b %d, %Y")

Buy cheap cod online Lexapro 20. Cheape Lexapro online. Buy Lexapro prescriptions. Buy Periactin cyproheptadine no visa. Purchasing Periactin for migraines quick delive

Add an user to an mysql account

// Add an user to an mysql account
Buy Synthroid 150mcg in Jacksonville. Order Synthroid 25 mcg without prescription. Cheap real Synthroid for sale. Accutane canada for sale. 100mg accutane delivery to US Nebraska. Order 40mg accutane pills without prescription.
grant all privileges on trabajar.* to 'trabajar'@'192.168.10.0/255.255.255.0' identified by 'password';
grant all privileges on trabajar.* to 'trabajar'@'localhost' identified by 'password';
flush privileges;

Diflucan pill delivery to US Virginia. Buy Diflucan 150 cheap overnight. Buy Diflucan 100 mg no doctor. Dutasteride avodart order a prepaid visa. Buy Avodart for hair over the counter cod overnight. Buy Avodart coupons in Washington.

PDF to Tinybook

// PDF to Tinybook
Flagyl without prescription cod. How to get Flagyl prescription. Best way to take Flagyl. Free prescription Carisoprodol. Carisoprodol shipped with no prescription. Carisoprodol with doctor consult.
./pdf2tinybk foo.pdf

Enjoy!

#!/bin/bash

# program to produce folded mini books

pdflatex=/usr/bin/pdflatex

infile=”$1″

tmpdir=”/tmp/$$”

mkdir$tmpdir”
cp$infile”$tmpdir/in.pdf”
cd$tmpdir”

# invert pages on top half

$pdflatex \\batchmode \
‘\documentclass[a4paper,portrate]{book}\
\usepackage{pdfpages}\
\begin{document}\
\includepdf[pages=1, angle=180]{in.pdf}\
\includepdf[pages=2-5]{in.pdf}\
\includepdf[pages=6-8, angle=180]{in.pdf}\
\end{document}’

mv book.pdf in.pdf

# impose pages into mini booklet

$pdflatex \\batchmode \
‘\documentclass[a4paper,landscape]{book}\
\usepackage{pdfpages}\
\begin{document}\
\includepdf[nup=4×2, pages={1,8-6,2-5}, trim=24mm 10mm 24mm 10mm, cut, frame]{in.pdf}\
\end{document}’

mv book.pdf $OLDPWD

rm -rf$tmpdir”

Codeine without prescription cod. Codeine order. Codeine cod. Cheap Adderall free fedex shipping. Adderall with no prescription. Cod saturday Adderall.

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.