CSS HTML5重置

html,body,div,span,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,cite,code,del,dfn,em,img,ins,kbd,q,samp,
small,strong,sub,sup,var,b,i,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent;}
body {line-height:1;}
article,aside,canvas,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary{display:block;}
nav ul {list-style:none;}
blockquote, q {quotes:none;}
blockquote:before, blockquote:after,q:before, q:after {content:'';content:none;}
a {margin:0;padding:0;border:0;font-size:100%;vertical-align:baseline;background:transparent;}
ins {background-color:#ff9;color:#000;text-decoration:none;}
mark {background-color:#ff9;color:#000;font-style:italic;font-weight:bold;}
del {text-decoration: line-through;}
abbr[title], dfn[title] {border-bottom:1px dotted #000;cursor:help;}
table {border-collapse:collapse;border-spacing:0;}
hr {display:block;height:1px;border:0;border-top:1px solid #cccccc;margin:1em 0;padding:0;}
input, select {vertical-align:middle;}
video {display:block;}

PHP 简单验证类

<?php

/*************************************************************************
*** Example of Usage: ****************************************************
***** Validate::string('717 123 4567',Validate::SPACE.Validate::PHONE); **
***** returns true *******************************************************
*************************************************************************/

class Validate
{

	const name = 'Simple Validation Class';
	const version = '0.2a';

	const NUM = '0-9';
	const SPACE = '\s';
	const ALPHA_LOWER = 'a-z';
	const ALPHA_UPPER = 'A-Z';
	const ALPHA = 'a-zA-Z';
	const EALPHA_LOWER = 'a-z�¡�©�­�³�º�½� �¨�¬�²�¹�¤�«�¯�¶�¼�¿�¢�ª�®�´�»�£�±�µ�¡�¥�¦�§���°�¸�¾��';
	const EALPHA_UPPER = 'A-Z���������������������������������¸����������������� ��������������';
	const EALPHA = 'a-z�¡�©�­�³�º�½� �¨�¬�²�¹�¤�«�¯�¶�¼�¿�¢�ª�®�´�»�£�±�µ�¡�¥�¦�§���°�¸�¾��A-Z���������������������������������¸����������������� ��������������';
	const PUNCTUATION = '\s\.\-_,;\/\:&"\'\?\!\(\)';
	const ALL = '0-9\s\.\-_,;\/\:&"\'\?\!\(\)a-z�¡�©�­�³�º�½� �¨�¬�²�¹�¤�«�¯�¶�¼�¿�¢�ª�®�´�»�£�±�µ�¡�¥�¦�§���°�¸�¾��A-Z���������������������������������¸����������������� ��������������';
	const PHONE = '0-9\s+\-.\(\)#\*\/';

	static private function version_check() {
		return version_compare(PHP_VERSION, '5.2.0', '>=');
	}//end function

	public function url ($url, $length = 12, $http=TRUE) {
		if (strlen($url) < $length) return false;
		if (self::version_check()) {
			$flag = null;
			if ($http) $flag = FILTER_FLAG_PATH_REQUIRED;
			return (bool) filter_var($integer, FILTER_VALIDATE_URL, $flag);
		}//end if
		return !preg_match('/ /', $url) 
			&& preg_match('|^'.($http?'http(s)?://':'').'[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url);
	}//end function
	
	public function string ($string, $charset=self::ALL, $length=1) {
		return strlen($string) >= $length
			&& preg_match("|^[$charset]*\$|s", $string);
    	}//end function
	
	public function integer ($integer, $min=null, $max=null) {
		if (self::version_check()) {
			$options = array('default'=>false);
			if (isset($min)) $options['min_range'] = $min;
			if (isset($max)) $options['max_range'] = $max;
			return filter_var($integer, FILTER_VALIDATE_INT, $options);
		}//end if
		return is_int($integer) && (!isset($min) || $integer>=$min) && (!isset($max) || $integer<=$max);
	}//end function

	public function email ($email) {
		if (self::version_check()) return (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
		$broken = explode('@',$email);
		return empty($broken[2])
			&& self::url($broken[1],5,FALSE)
			&& self::string($broken[0],self::ALPHA.self::NUM.'\.\-_');
	}//end function

}

?>

C# 绑定可见性属性(View)与Bool属性(ViewModel)

<!-- XAML VisibilityConverter Usage -->


<Window.Resources>
    <vw:VisibilityConverter x:Key="VisibilityConverter" />
</Window.Resources>

<Grid Visibility="{Binding MyBoolean, Converter={StaticResource VisibilityConverter}}">
  ...
</Grid>


// C# VisibilityConverter implementation

public class VisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            Visibility rv = Visibility.Visible;
            try
            {
                var x = bool.Parse(value.ToString());
                if (x)
                {
                    rv = Visibility.Visible;
                }
                else
                {
                    rv = Visibility.Collapsed;
                }
            }
            catch (Exception)
            {
            }
            return rv;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return value;
        }
    }

PHP 更新WordPress中的永久链接

global $wp_rewrite;
$wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
$wp_rewrite->flush_rules();

JavaScript 打印对象

function printObject(o){
	var output = '';
	for (property in o) {
	  output += property + ': ' + o[property]+'; ';
	}
	alert(output);
}

CSS 清除修复

.clear_fix {
	_height: 1%;
}

.clear_fix:after {
	content: ".";
	visibility: hidden;
	display: block;
	clear: both;
	height: 0;
    font-size: 0;
}

PHP 修剪角色

function trimchars($chars, $subject)
{
  return preg_replace("/\s*([$chars])\s*/", '\1', $subject);
}

#                 V
# a b c d e => a bcd e
trimchars('c', 'a b c d e');

#                  V V
# 23 + 2 = 25 => 23+2=25
trimchars('+=', '23 + 2 = 25');

#     V          V    V     V    V
# body{background:#fff;color:#fff;}
trimchars('{}:;', 'body { background: #fff; color: #fff; }');

CSS 圆形菜单栏,带有html5和css3

a {
    text-decoration: none;
}
nav {
    background-color: #A3A5A8;
    border: 1px solid #FFF;
    border-radius: 6px;
    display: block;
    -moz-border-radius: 6px;
    -webkit-border-radius: 6px;
    -moz-box-shadow: 0 0 14px #123;
    -webkit-box-shadow: 0 0 14px #123;
    box-shadow: 0 0 14px #123;
    font-size: 15px;
    margin-bottom: 10px;
    padding: 8px 2px;
    width: 450px;
}	
nav a {
    padding: 5px 10px;	
    color: #141414;
}
nav .active,
nav a:hover {
    background-color: #000;
    border-radius: 6px;
    color: #FFF;
    -moz-border-radius: 6px;
    -webkit-border-radius: 6px;
}

jQuery jQuery插件模板

(function($) {
    // Shell for your plugin code
    $.fn.yourNameHere= function() {
        // Plugin code

    }
})(jQuery);

CSS 交叉浏览器CSS框阴影与Sass

@mixin shadow($color: #333333) {
  -moz-box-shadow: 0px 1px 2px $color;
  -webkit-box-shadow: 0px 1px 2px $color;
  box-shadow: 0px 1px 2px $color;
  -ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=90, Color='$color')";
  filter: progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=90, Color='$color');
}

.shadow {
  @include shadow(#111111);
}