Bash Bash函数可以轻松地将文件添加到svn

svnadd(){
 svn status| awk /$@/'{print $2}'| xargs svn add
}

# usage is simple
svnadd(filename)

JavaScript [ExtJS]在Ext.form.ComboBox下拉列表中显示空字符串

Ext.override(Ext.form.ComboBox, {
	initList: (function(){
		if(!this.tpl) {
			this.tpl = new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item">{',  this.displayField , ':this.blank}</div></tpl>', {
				blank: function(value){
					return value==='' ? '&nbsp' : value;
				}
			});
		}
	}).createSequence(Ext.form.ComboBox.prototype.initList)
});

JavaScript jQuery Attributes / attr

$("input.search-input").attr("value", "Search TechRelish");

C# 从字符串中删除非数字值

System.Text.RegularExpressions.Regex.Replace(Value, "\\D", "");

PHP 自动加载类和函数

foreach($autoload as $type => $name) {
  
    if($type=='libraries' && $name != NULL) {
      require_once(SYS_PATH . 'libraries' . DIRSEP . $name . '.php');
      eval("\${$name} = new {$name}({$Pronto});");
      $Pronto->set($name);
    }
    
    if($type=='helpers' && $name != NULL) {
      require_once(SYS_PATH . 'helpers' . DIRSEP . $name . '.php');
    }
  
}

JavaScript [ExtJS]自动调整Ext.form.CombBox的大小以适应其内容

function resizeToFitContent() {
	if (!this.elMetrics)
	{
		this.elMetrics = Ext.util.TextMetrics.createInstance(this.getEl());
	}
	var m = this.elMetrics, width = 0, el = this.el, s = this.getSize();
	this.store.each(function (r) {
		var text = r.get(this.displayField);
		width = Math.max(width, m.getWidth(text));
	}, this);
	if (el) {
		width += el.getBorderWidth('lr');
		width += el.getPadding('lr');
	}
	if (this.trigger) {
		width += this.trigger.getWidth();
	}
	s.width = width;
	this.setSize(s);
	this.store.on({
		'datachange': this.resizeToFitContent,
		'add': this.resizeToFitContent,
		'remove': this.resizeToFitContent,
		'load': this.resizeToFitContent,
		'update': this.resizeToFitContent,
		buffer: 10,
		scope: this
	});
}

var combo = new Ext.form.ComboBox({
	//combobox config...
	config: ''
});

combo.on('render', resizeToFitContent, combo);

PHP 剥离html并修改标签和空格

function stripTagsAmendSpaces($str)
{
	$str = trim($str);
	$str= strip_tags($str);
	return $str = preg_replace('/\\s{2,}/',' ',$str);
}

PHP php html Parser

Class HTML_Parser {
    // Private properties
    var $_parser;
    var $_tags = array();
    var $_html;
    var $output = array();
    var $strXmlData;
    var $_level = 0;
    var $_outline;
    var $_tagcount = array();
    var $xml_error = false;
    var $xml_error_code;
    var $xml_error_string;
    var $xml_error_line_number;

    function get_html () {
        return $this->_html;
    }

    function parse($strInputXML) {
        $this->output = array();

        // Translate entities
        $strInputXML = $this->translate_entities($strInputXML);

        $this->_parser = xml_parser_create ();
        xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, true);
        xml_set_object($this->_parser,$this);
        xml_set_element_handler($this->_parser, "tagOpen", "tagClosed");
          
        xml_set_character_data_handler($this->_parser, "tagData");
      
        $this->strXmlData = xml_parse($this->_parser,$strInputXML );

        if (!$this->strXmlData) {
            $this->xml_error = true;
            $this->xml_error_code = xml_get_error_code($this->_parser);
            $this->xml_error_string = xml_error_string(xml_get_error_code($this->_parser));
            $this->xml_error_line_number =  xml_get_current_line_number($this->_parser);
            return false;
        }

        return $this->output;
    }


    function tagOpen($parser, $name, $attr) {
        // Increase level
        $this->_level++;

        // Create tag:
        $newtag = $this->create_tag($name, $attr);

        // Build tag
        $tag = array("name"=>$name,"attr"=>$attr, "level"=>$this->_level);

        // Add tag
        array_push ($this->output, $tag);

        // Add tag to this level
        $this->_tags[$this->_level] = $tag;

        // Add to HTML
        $this->_html .= $newtag;

        // Add to outline
        $this->_outline .= $this->_level . $newtag;
    }

    function create_tag ($name, $attr) {
        // Create tag:
        # Begin with name
        $tag = '<' . strtolower($name) . ' ';

        # Create attribute list
        foreach ($attr as $key=>$val) {
            $tag .= strtolower($key) . '="' . htmlentities($val) . '" ';
        }

        # Finish tag
        $tag = trim($tag);
        
        switch(strtolower($name)) {
            case 'br':
            case 'input':
                $tag .= ' /';
            break;
        }

        $tag .= '>';

        return $tag;
    }

    function tagData($parser, $tagData) {
        if(trim($tagData)) {
            if(isset($this->output[count($this->output)-1]['tagData'])) {
                $this->output[count($this->output)-1]['tagData'] .= $tagData;
            } else {
                $this->output[count($this->output)-1]['tagData'] = $tagData;
            }
        }

        $this->_html .= htmlentities($tagData);
        $this->_outline .= htmlentities($tagData);
    }
  
    function tagClosed($parser, $name) {
        // Add to HTML and outline
        switch (strtolower($name)) {
            case 'br':
            case 'input':
                break;
            default:
            $this->_outline .= $this->_level . '</' . strtolower($name) . '>';
            $this->_html .= '</' . strtolower($name) . '>';
        }

        // Get tag that belongs to this end
        $tag = $this->_tags[$this->_level];
        $tag = $this->create_tag($tag['name'], $tag['attr']);

        // Try to get innerHTML
        $regex = '%' . preg_quote($this->_level . $tag, '%') . '(.*?)' . preg_quote($this->_level . '</' . strtolower($name) . '>', '%') . '%is';
        preg_match ($regex, $this->_outline, $matches);

        // Get innerHTML
        if (isset($matches['1'])) {
            $innerhtml = $matches['1'];
        }
        
        // Remove level identifiers
        $this->_outline = str_replace($this->_level . $tag, $tag, $this->_outline);
        $this->_outline = str_replace($this->_level . '</' . strtolower($name) . '>', '</' . strtolower($name) . '>', $this->_outline);

        // Add innerHTML
        if (isset($innerhtml)) {
            $this->output[count($this->output)-1]['innerhtml'] = $innerhtml;
        }

        // Fix tree
        $this->output[count($this->output)-2]['children'][] = $this->output[count($this->output)-1];
        array_pop($this->output);

        // Decrease level
        $this->_level--;
    }

    function translate_entities($xmlSource, $reverse =FALSE) {
        static $literal2NumericEntity;
        
        if (empty($literal2NumericEntity)) {
            $transTbl = get_html_translation_table(HTML_ENTITIES);

            foreach ($transTbl as $char => $entity) {
                if (strpos('&"<>', $char) !== FALSE) continue;
                    $literal2NumericEntity[$entity] = '&#'.ord($char).';';
                }
            }

            if ($reverse) {
                return strtr($xmlSource, array_flip($literal2NumericEntity));
            } else {
                return strtr($xmlSource, $literal2NumericEntity);
            }
      }
}

Haskell CONCAT

concat [[1,2,3], [1,2,3]]
{{{
[1,2,3,1,2,3]
}}}

Haskell 相比

*Main> compare 1 2
LT
*Main> compare 3 2
GT
*Main> compare 3 3
EQ
*Main> compare 3.0 2.9
GT
*Main> compare 3.0 2
GT
*Main> :t (compare 1 1)
(compare 1 1) :: Ordering
*Main> :t compare
compare :: (Ord a) => a -> a -> Ordering