Ruby 使用或不使用时间格式化日期

def format_date(date, use_time = false)
    if use_time == true
        ampm = date.strftime("%p").downcase
        new_date = date.strftime("%B %d, %Y at %I:%M" + ampm)
    else
        new_date = date.strftime("%B %d, %Y")
    end
end

PHP PHP - Limpiarinyecciónsql

//mysqli_xxx
function inSql($value){
	global $conn;
	if( get_magic_quotes_gpc() ) $value = stripslashes( $value );
	$value = mysqli_real_escape_string( $conn, $value );
	return $value;
}
#echo inSql("testeando '"); 

//mysql_xxx
function inSql($value){
	global $conn;
	if( get_magic_quotes_gpc() ) $value = stripslashes( $value );
	$value = mysql_real_escape_string( $value );
	return $value;
}
#echo inSql("testeando '");

#Diferentes versiones de php:
function inSql ($string) {
   global $conn,
   if(version_compare(phpversion(),"4.3.0")=="-1") {
     mysql_escape_string($string);
   } elseif ($conn) {
     mysql_real_escape_string($string,$conn);
   } else { return false; }
}

SQL 计算一年中nodeviews的数量

SELECT SUM(count.totalcount) FROM node_counter count LEFT JOIN node n ON n.nid = count.nid where n.created > (UNIX_TIMESTAMP(NOW())-31536000);

PHP toogle对象的可见性

function toggle(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	} else {
		el.style.display = '';
	}
}

CSS 删除Google笔记本文字

#gnotes-statusbar-lbl {
   display: none !important;
}

Bash 查看MacBook上是否已连接电源

ioreg -l | grep ExternalConnected | cut -d'=' -f 2

Ruby Ver sessao

<%= debug(@request.session.instance_variable_get("@data")) %>

Bash 查找大文件

find . -size +10240000c -exec du -h {} \;

JavaScript 扩展字符串方法示例

function fmtHeading(level) {
	stringtext = this.toString();
	starttag = "<h" + level + ">";
	endtag = "</h" + level + ">";	
	return starttag + stringtext + endtag;
}

String.prototype.heading = fmtHeading;
document.write("This is a heading!".heading(2));

Bash 什么在听什么端口/插座?

netstat -an