Bash 使用drush激活Drupal维护模式

#Activate maintenance mode
drush vset --always-set site_offline 1
drush cc all

#Desactivate maintenance mode
drush vset --always-set site_offline 0
drush cc all

CSS 更好的CSS字体堆栈

body {
    font-family: Arial, Helvetica, "Liberation Sans", FreeSans, sans-serif;
   
}

HTML 元标记 - 在HTML文档页面标题中自动刷新,以便在工作编码时在IE FF中预览所有浏览器

<meta http-equiv="CACHE-CONTROL" content="NO-CACHE">
		<meta http-equiv="PRAGMA" content="NO-CACHE">
		<meta http-equiv="REFRESH" content="25">

PHP 获取WordPress中的当前页面模板名称

global $post;
$page_tempate_name = get_post_meta($post->ID,'_wp_page_template',true);

C# 获取枚举说明

public enum PaymentTypes
    {
        [Description("Mooring Licence Fee")]
        MooringLicenceFee = 1, 
        Contact = 2,
        Vessel = 3,
        Enquiry = 4,
        [Description("Inspection Entry")]
        InspectionEntry = 5,
        Lease = 6,
        [Description("Licence Transfer")]
        LicenceTransfer = 7,
        Other = 8
    }

public static class Extensions
    {
        public static string GetDescription(this PaymentTypes value)
        {
            Type type = value.GetType();
            string name = Enum.GetName(type, value);
            if (name != null)
            {
                FieldInfo field = type.GetField(name);
                if (field != null)
                {
                    DescriptionAttribute attr = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute;
                    if (attr == null)
                    {
                        return name;
                    }
                    else
                    {
                        return attr.Description;
                    }
                }
            }
            return null;

        }
    }

Apache HTACCESS - 将旧页面重定向到新页面

Redirect 301 /oldpage.html http://www.domain.com/newpage.html

JavaScript 拖放库

/*
 * Created August 19, 2010; updated February 26, 2011
 * Released into the public domain by Josh Atkins
*/

var dragEnabled, curDragElmnt, curDropLoc, curCursorX, curCursorY, cursorX, cursorY, positionStyles;

function get(elmnt) {
	return document.getElementById(elmnt);
}

function beginDrag(dragElmnt, dropLocation, dragEvent) {
	if(curDragElmnt) get(curDragElmnt).style.zIndex = '1';
	curDragElmnt = dragElmnt;
	dragEnabled = 1;
	get(curDragElmnt).style.zIndex = '2';
	if(dropLocation&&dropLocation!='') curDropLoc = dropLocation;
	updateCursorPos(dragEvent);
	return false;
}

function updateCursorPos(moveEvent) {
	curCursorX = moveEvent.clientX + document.body.scrollLeft - document.body.clientLeft;
	curCursorY = moveEvent.clientY + document.body.scrollTop - document.body.clientTop;
}

function drag(dragEvent) {
	cursorX = dragEvent.clientX + document.body.scrollLeft - document.body.clientLeft;
	cursorY = dragEvent.clientY + document.body.scrollTop - document.body.clientTop;
	if(dragEnabled==1) {
		get(curDragElmnt).style.left = get(curDragElmnt).offsetLeft + cursorX - curCursorX + 'px';
		get(curDragElmnt).style.top = get(curDragElmnt).offsetTop + cursorY - curCursorY + 'px';
	}
	updateCursorPos(dragEvent);
}

function stopDrag() {
	if(dragEnabled==1) {
		curCursorX = null;
		curCursorY = null;
		if(curDropLoc&&!checkIfElmntInsideAnother(curDragElmnt, curDropLoc)) {
			positionStyles = get(curDragElmnt).className.substring(get(curDragElmnt).className.indexOf('posStart')+8,
							 get(curDragElmnt).className.indexOf('posEnd')+6).split('px');
			get(curDragElmnt).style.left = positionStyles[0] + 'px';
			get(curDragElmnt).style.top = positionStyles[1] + 'px';
		}
		curDropLoc = null;
		dragEnabled = 0;
	}
}

function trimSpaces(value) {
	value = value.substring(0, 1) == ' ' ? value.substring(1) : value;
	return value.substring(value.length-1) == ' ' ? value.substring(0, value.length-1) : value;
}

function enableDragDrop(dragObjs, dropLocation) {
	if(document.body.className.indexOf('dragDropEnabled')==-1) {
		document.body.className = trimSpaces(document.body.className + ' dragDropEnabled');
		document.body.setAttribute('onmousemove', trimSpaces((document.body.getAttribute('onmousemove')||'') + ' drag(event);'));
		document.body.setAttribute('onmouseup', trimSpaces((document.body.getAttribute('onmouseup')||'') + ' stopDrag();'));
	}
	for(var i=0;i<dragObjs.length;i++) {
		if(get(dragObjs[i]).className.indexOf('dragDropEnabled')==-1) {
			get(dragObjs[i]).setAttribute('onmousedown', trimSpaces((get(dragObjs[i]).getAttribute('onmousedown')||'') +
			' return beginDrag(this.id, '+(dropLocation!=null&&dropLocation!=''?'\''+dropLocation+'\'':'null')+', event);'));
			get(dragObjs[i]).className = trimSpaces(get(dragObjs[i]).className+' posStart'+get(dragObjs[i]).offsetLeft+'px'+get(dragObjs[i]).offsetTop+'pxposEnd dragDropEnabled');
			if(!get(dragObjs[i]).style.width) get(dragObjs[i]).style.width = get(dragObjs[i]).offsetWidth + 'px';
			get(dragObjs[i]).style.left = get(dragObjs[i]).offsetLeft + 'px';
			get(dragObjs[i]).style.top = get(dragObjs[i]).offsetTop + 'px';
		}
	}
	for(i=0;i<dragObjs.length;i++) {
		if(get(dragObjs[i]).style.position!='absolute') get(dragObjs[i]).style.position = 'absolute';
	}
}

function disableDragDrop(dragObjs) {
	for(var i=0;i<dragObjs.length;i++) {
		get(dragObjs[i]).setAttribute('onmousedown', trimSpaces(get(dragObjs[i]).getAttribute('onmousedown').replace(/return beginDrag([^\)]+)\);/, '')));
		get(dragObjs[i]).className = trimSpaces(get(dragObjs[i]).className.replace(/dragDropEnabled/, ''));
	}
}

function checkIfElmntInsideAnother(first, second) {
	return get(first).offsetTop+get(first).offsetHeight<=get(second).offsetTop+get(second).offsetHeight&&
		   get(first).offsetLeft+get(first).offsetWidth<=get(second).offsetLeft+get(second).offsetWidth&&
		   get(first).offsetTop>=get(second).offsetTop&&get(first).offsetLeft>=get(second).offsetLeft;
}

CSS css3投影

-moz-box-shadow: 3px 3px 3px #666;
-webkit-box-shadow: 3px 3px 3px #666;
box-shadow: 3px 3px 3px #666;

CSS css3文字阴影

text-shadow: 1px 1px 1px #000;

JavaScript 使用JavaScript获取URL参数

function getUrlParameters()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}