SQL 情况......那么

CASE 
      WHEN @RoleTypeId = 0 THEN @RoleTypeName
      WHEN @RoleTypeId = 1 THEN 'Public Anonymous User'
      WHEN @RoleTypeId = 2 THEN 'System Administrator'
 END

PHP 打开网址

function openURL($url,$cookie='') {
              $ch = curl_init();
                curl_setopt($ch, CURLOPT_URL, $url);
                if($cookie!='') {
                        // set the cookie file
                        curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
                }
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); 
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
                // Acessar a URL e retornar a saída
                $output = curl_exec($ch);
                // liberar
                curl_close($ch);
                
                return $output;
        }

PHP 调试变量

if ( ! function_exists('debug'))
{
  function debug($var, $fn='print_r')
  {
    if (function_exists($fn))
    {
      echo '<pre>', $fn($var), '</pre>';
    }
    else
    {
      echo '<pre>The function ', $fn, '() does not exist. Falling back to',
      ' print_r().<br /><br />', print_r($var), '</pre>';
    }
  }
}
 
// Example
 
debug(array('test1',123));
 
/*
<pre>Array
(
    [0] => test1
    [1] => 123
)
1</pre>
*/

Other 将多个域指向同一备用域文件夹

cd domains
rm -rf alt-example.com
ln -s mt-example.com alt-example.com

HTML 图像预加载器

div.loader{
	background:url(images/hover.gif) no-repeat;
	background:url(images/hover2.gif) no-repeat;
	background:url(images/hover3.gif) no-repeat;
	margin-left:-10000px;
}

CSS Href图标

/* external links */
a[href^="http://"]{
	padding-right: 20px;
	background: url(external.gif) no-repeat center right;
}

/* emails */
a[href^="mailto:"]{
	padding-right: 20px;
	background: url(email.png) no-repeat center right;
}

/* pdfs */
a[href$=".pdf"]{
	padding-right: 20px;
	background: url(pdf.png) no-repeat center right;
}

PHP 数字格式

$val = number_format($val, 2, ',', '.'); // Fromattazione Numero 1.234,56

HTML 分层YUI菜单的标记

<div id="productsandservices" class="yuimenu">
    <div class="bd">
        <ul class="first-of-type">
            <li class="yuimenuitem">            
                <a class="yuimenuitemlabel" href="#communication">
                    Communication
                </a>
                <!-- A submenu -->
                <div id="communication" class="yuimenu">
                    <div class="bd">
                        <ul>
                        <!-- Items for the submenu go here -->
                        </ul>
                    </div>
                </div>                    
            </li>
            <li class="yuimenuitem">
                <a class="yuimenuitemlabel" href="http://shopping.yahoo.com">
                    Shopping
                </a>
                <!-- A submenu -->
                <div id="shopping" class="yuimenu">
                    <div class="bd">                    
                        <ul>
                        <!-- Items for the submenu go here -->
                        </ul>
                    </div>
                </div>                    
            </li>
            <li class="yuimenuitem">
                <a class="yuimenuitemlabel" href="http://entertainment.yahoo.com">
                    Entertainment
                </a>
                <!-- A submenu -->
                <div id="entertainment" class="yuimenu">
                    <div class="bd">                    
                        <ul>
                        <!-- Items for the submenu go here -->
                        </ul>                    
                    </div>
                </div>                                        
            </li>
            <li class="yuimenuitem">
                <a class="yuimenuitemlabel" href="#information">
                    Information
                </a>
                <!-- A submenu -->
                <div id="information" class="yuimenu">
                    <div class="bd">                                        
                        <ul>
                        <!-- Items for the submenu go here -->
                        </ul>                    
                    </div>
                </div>                                        
            </li>
        </ul>            
    </div>
</div>

PHP RecentStumbles

<?php 

// FILE RecentStumbles.php

class RecentStumbles {
	
	private $username;
	private $xml;
	private $debug = false;
	private $feed_url = 'http://rss.stumbleupon.com/user/';
	private $type_array = array('blog','comments','favorites','reviews');

	function __construct($username=null, $debug = false) {
		$this->debug = (bool) $debug;
		if (!is_null($username)) $this->set_username($username);
	}//end function

	/* Sets the username and resets $this->xml */
	public function set_username($username) {
		$this->username = urlencode($username);
		$this->xml = null;
	}//end function

	/* Fetches array of recent stumbles */
	public function fetch($type=null, $limit=0) {
		
		if (!isset($this->username)) return array();

		$limit = (int) $limit;

		$xml = $this->loadXML($type);
	
		$items_count= count($this->xml->channel->item);

		if ($items_count < $limit || $limit==0) $limit = $items_count;

		$return = array();

		for ($i=0; $i<$limit; $i++) {
			
			preg_match_all('/src=[\'"]?([^\'" >]+)[\'" >]/', $xml->channel->item[$i]->description, $img); 

			$return[$i] = array(
				'title' => $xml->channel->item[$i]->title,
				'link' => $xml->channel->item[$i]->link,
				'img' => $img[1][0],
				'date' => $xml->channel->item[$i]->pubDate
			);

		}//end for

		return $return;

	}//end function

	private function loadXML($type) {

		if (!in_array($type,$this->type_array)) $type = '';

		if (!isset($this->xml)) {
			$url = $this->feed_url.$this->username.'/'.$type;
			if ($this->debug) die(file_get_contents($this->feed_url.$this->username.'/'.$type));
			$this->xml = simplexml_load_file($url, 'SimpleXMLElement', LIBXML_NOCDATA);
		}//end if

		return $this->xml;

	}//end function
	
}//end class

?>


<?php

// View File


// Uncomment below if file may not have been required yet
// require_once('./path/to/RecentStumbles.php');

$rs = new RecentStumbles('jamesorion');
	
?>

<ul>
	<?php foreach ($rs->fetch('favorites',10) as $s): ?>
	<li title="<?=$s['title']?>"><!-- <?=$s['date']?> -->
		<a href="<?=$s['link']?>" title="<?=$s['title']?>">
			<img src="<?=$s['img']?>" alt="<?=$s['title']?>" border="0" /> <?=$s['title']?>
		</a>
	</li>
	<?php endforeach; ?>
</ul>

C# CheckBox按钮

public class ToggleButton : System.Windows.Forms.CheckBox
{
   // This class subclasses a CheckBox to combine the benefits of a Checkbox and 
   // Checkbox-with-Button-Appearance by combining a checkbox and button into one control.
   // 
   // Requirements: 
   // [1] Two states (like a checkbox).
   // [2] Visually imply action/control (like a button). 
   //     I think a Checkbox fails this requirement.
   // [3] It should be intuitively obvious what the state is and what the button will do when clicked.
   //     A checkbox meets the state requirement but fails the Action requirement because
   //     checkboxes are typically used for configuration rather than action.
   //     I think a Checkbox-with-button-appearance fails because it's not obvious if the button is depressed or not.
   //     I think a button-with-changing-text fails. Does the text show state or the on-click (oposite) action?
   //     Designers use button-with-changing-text inconsistently.
   // [4] Explicity show State even with poor dispplay visibility. 
   //     I think a Checkbox-with-button-appearance fails this requirement.
   // [5] Works on all resolutions and themes, doesn't look to 'flashy' and must 'fit-in'
   //     I think a 2-bitmapped button would fail this requirement.
   //     Many 3-rd party buttons fail this requirement.
   // 
   // This class uses DrawToBitmap to capture a temporary Checkbox's appearance.
   // It captures just the checkbox without the text.
   // I want to use a standard checkbox to be consistent with system-wide styles.
   //
   // Design usage:
   // [1] Add this class ToggleButton to project.
   // [2] Add 'normal' checkbox to WinForm
   // [3] Change it's class to this ToggleButton class (in both the declaration and instantiation).
   // [4] Set properties...
   //     Appearance = System.Windows.Forms.Appearance.Button;
   //     TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
   //
   // Room for improvement:
   //    There's probably a way to automatically change Image based on state. I don't know yet.
   //    Create a user control that's more portable (although it's easy to add a class to a project).
   //    Consider making the bitmaps static merely to save space.
 
   System.Drawing.Bitmap bmChecked;
   System.Drawing.Bitmap bmUnChecked;
 
   //constructor
   public ToggleButton() : base() 
   {
 
      System.Windows.Forms.CheckBox chkTemp = new System.Windows.Forms.CheckBox(); // Temporary checkbox with no text.
 
      chkTemp.AutoSize = true;
      chkTemp.BackColor = System.Drawing.Color.Transparent;
      chkTemp.Size = new System.Drawing.Size(15, 14);
      chkTemp.UseVisualStyleBackColor = false;
 
      bmChecked = new System.Drawing.Bitmap(chkTemp.Width, chkTemp.Height);
      bmUnChecked = new System.Drawing.Bitmap(chkTemp.Width, chkTemp.Height);
 
      // Set checkbox false and capture bitmap.
      chkTemp.Checked = false; 
      chkTemp.DrawToBitmap(bmUnChecked, new System.Drawing.Rectangle(0, 0, chkTemp.Width, chkTemp.Height));
 
      // Set checkbox true and capture bitmap.
      chkTemp.Checked = true;
      chkTemp.DrawToBitmap(bmChecked, new System.Drawing.Rectangle(0, 0, chkTemp.Width, chkTemp.Height));
 
      this.CheckedChanged += new System.EventHandler(this.btnToggleButton_CheckedChanged);
 
      this.Image = this.Checked ? bmChecked : bmUnChecked;
 
   }
 
   // Change the this.Image
   private void btnToggleButton_CheckedChanged(object sender, System.EventArgs e)
   {
      this.Image = this.Checked ? bmChecked : bmUnChecked;
   }
 
}