Other 智能文本重新分析器ala jQuery(和cookie)

<script src="graphics/js/jquery-1.2.6.min.js" type="text/javascript"></script>
<script src="graphics/js/jquery.cookie.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
		// See which font size the user wants
		$(".text a").click(function() {
			switch ($(this).attr("class")) {
				case 'small'	: setFontSize(.8);	break;
				case 'large'	: setFontSize(1.6);	break;
				case 'default'	: setFontSize(1.2);	break;
			}
			return false;
		});

		// Set the font size and set a cookie
		function setFontSize(size) {
	        $("#wrap, input, textarea").animate({fontSize: size+"em"}, 500).fadeIn("slow");
				createCookie(size);
			}

			// Create and read coookies
			// Code functions by: Peter-Paul Koch
			// http://www.quirksmode.org/js/cookies.html
			function createCookie(value) {
				var date = new Date();
				date.setTime(date.getTime()+(30*24*60*60*1000));
				var expires = "; expires="+date.toGMTString();
				document.cookie = "font_size="+value+expires+"; path=/";
			}
		var font_size = $.cookie('font_size');
		   if (font_size == '0.8') {
		        $('#wrap').css("font-size",".8em");
			}
		   if (font_size == '1.6') {
		        $('#wrap').css("font-size","1.6em");
			}
		   if (font_size == '1.2') {
		        $('#wrap').css("font-size","1.2em");
			}
	});
</script>

Other EXTJS - 基本网格蓝图

/**
 * generate a grid, it so commonly used that i decided to make it easy to initiate
 */

var getNewGrid = function (id, store, columns) {
	
	var store = store || new Ext.data.JsonStore({
		    url: 'get-images.php',
		    root: 'elements',
		    fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
		});

	var columns = columns || [
	        {id: 'name', header: 'Name', sortable: true, dataIndex: 'name'},
	        {header: 'Modified', width: 120, sortable: true, dataIndex: 'modified'},
	        {header: 'Type', width: 120, sortable: true, dataIndex: 'type', readOnly: false},
	        {header: 'Size', width: 120, sortable: true, dataIndex: 'size', align: 'right'}
	    ]    	
	
	return  {
		id 			: id
		,xtype		: 'grid'
		,store 		: store
		,columns 	: columns
		,autoLoad	: false
	}
}	// eo function

Other EXTJS - 网格onRowDblClick处理函数

/**
 * grids onRwDoubleClick
 */
var onRowDblClick = function (sm, rowIdx, e) {

	console.log('HO.Class.CRUD.onRowDblClick');
	console.log(this);
	console.log(this.ownerCt);
	console.log(sm);
	console.log(rowIdx);
	console.log(e);
	var rec = this.getStore().getAt(rowIdx);
	this.ownerCt.managerRef.show('ala','makota');
}	// eo function onRowDblClick

Other EXTJS - 远程加载网格的容器

/**
 * Container for a remotely loaded grid
 */

HO.Class.CRUD.prototype.defineGridContainer = function () {		
	this.GridContainer = {
	     id				: 'GridContainer'
	    ,title			: 'grid'
	    ,loadScripts	: true
		,layout			: 'fit'
		,plugins		: [this.Grid]
		,managerRef		: this			// !!!!!!! a reference to managing object, this object, because this is our app logic
	    //,autoShow		: true
	 	,tbar: [{
	        text:'click me',
	        listeners: {
	            click: function(){ alert('test'); }
	        }
	    }]
	}
}	// eo function 

Other EXTJS - 来自远程文件的网格,其中包含用于dbl click的侦听器

/**
 * grid from remote file with a listener for dbl click
 */

HO.Class.CRUD.prototype.defineGrid = function () {	
	console.log('HO.Class.CRUD.initGrid ');
	
	this.Grid = new Ext.ux.Plugin.RemoteComponent({
				url : '/files/ux/RemoteComponent/implementation4/grid_generated.php'
				//,loadOn : 'show'  /* defer processing to container's show-event */
			});
	
	// add events
	this.Grid.on('success', function(cmp){
		cmp.on('rowdblclick', this.onRowDblClick);
	    return false;
	}, this);
}

Other EXTJS - 仅在新选项卡不存在时创建

/**	
 * 	Create new tab only if it does not exist before
 */

// Show tab way
HO.Class.CRUD.prototype.showTab = function (id,name) {

	HO.log("HO.Class.CRUD.showTab " + id + " " + name);

	var tabID = this.ComponentName + id;
	var tab = this.TabPanel.items.find(function(i){
		return i.id === tabID;
	})
	if (!tab) { 
		 showObject = 	this.getShowObject(id,tabID, name);

		this.TabPanel.add( showObject ).show();
		// x = {title: "dupa", layout: 'fit', items: [showObject]
		// ,autoScroll		: 	true
		// ,bodyStyle		: 	'position:relative'
		// 
		// }
		// 	
		// this.TabPanel.add( x ).show();


	} else {
		HO.log('tab exists');
		this.TabPanel.setActiveTab(tabID);
	}
}
//	eo function showTab
	

Bash Unix GZIP备份

# archive
tar -zcvf backup.gz public_html  

# copy archive to current directory
wget http://urlpathto/backup.gz

# compy archive to mac
curl -c -o "http://urlpathto/backup.gz"

# restore to current directory
tar -zxvf backup.gz

PHP rm_wpautop

<?php
/*
Plugin Name: rm_wpautop
Plugin URI: http://rolandog.com/archives/2008/11/12/wp-plugin-rm-wpautop/
Description: This plugin allows you to remove the wpautop filter by placing a 'wpautop' custom field with a key value of 'false' in your pages or posts, therefore allowing WordPress not to automatically add paragraph or break elements.
Author: Rolando Garza
Author URI: http://rolandog.com/
Version: 0.3
*/
function rm_wpautop($content) {
    global $post;
    // Get the keys and values of the custom fields:
    $rmwpautop = get_post_meta($post->ID, 'wpautop', true);
    // Remove the filter
    remove_filter('the_content', 'wpautop');
    if ('false' === $rmwpautop) {
    } else {
    // Adds the filter again, if not set to false.
        add_filter('the_content', 'wpautop');
    }
    return $content;
}
// Hook into the Plugin API
add_filter('the_content', 'rm_wpautop', 9);
?>

Bash 删除.svn Directorys

#!/bin/bash

find . -name .svn -print0 | xargs -0 rm -rf
zenity --info --text "Done."

PHP 在PHP中创建易读的密码

function GenerateRandomString($length) {
	$characters = array('2', '3', '4', '5', '6', '7', '8', '9',
			'a', 'c', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'm', 'p',
			'q', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
	$randomString = "";
	while(strlen($randomString) < $length) {
		$randomCharacterIndex = rand(0, count($characters));
		$randomString .= $characters[$randomCharacterIndex];
	}
	return $randomString;
}