Chrome 下 12px以下字体显示变大 CSS Hack 方案

2012年05月12日

上网搜了一下,原来是中文版 Chrome 的 bug,对中文用户将所有网页最小字体强行限制在12px。

-webkit-text-size-adjust:none;

ubuntu上apache加载配置curl模块

2012年04月4日

一、安装curl相关模块

sudo apt-get install curl libcurl3 libcurl3-dev php5-curl

二、配置curl模块

sudo vi /etc/php5/apache2/php.ini

在extension下面加上

extension=curl.so

三、重启apache

sudo service apache2 restart

ubuntu安装phpmyadmin

2012年03月31日

在ubuntu下,运行:

sudo apt-getinstall phpmyadmin

过一会后会有一些设置,如选择服务器、密码设定等等内容。安装完成后,访问http://localhost/phpmyadmin会出现404错误,这是因为没有将phpmyadmin目录映射到apache目录下面,运行下面命令即可:

sudo ln -s /usr/share/phpmyadmin /var/www

div在整个页面水平居中 垂直居中

2011年12月2日

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>div在整个页面水平居中 垂直居中</title>
<style type=”text/css”>
html,body { margin:0; padding:0; overflow:hidden; height:100%; }
#test { margin:0 auto; border:1px solid #666; background-color:#CCC; width:500px; }
</style>
<script type=”text/javascript”>
window.onload = function() {
document.getElementById(‘test’).style.marginTop = (document.getElementsByTagName(‘body’)[0].offsetHeight – document.getElementById(‘test’).offsetHeight) / 2 + ‘px’;
}
</script>
</head>

<body>
<div id=”test”><p>&nbsp;</p></div>
</body>
</html>

body背景上下左右居中

2011年12月2日

文章出自www.globalenet.com全球E网,转载请注明出处!

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>body背景上下左右居中</title>

<style type=”text/css”>
<!–
*{ padding:0; margin:0;}
html{ height:100%;}
body {
background: url(http://a4.att.hudong.com/03/32/01300000081395124875325123568.jpg) 50% no-repeat;
height:100%;
}
–>
</style></head>

<body>
</body>
</html>

JS获取当月的最后一天

2011年09月1日

<html xmlns=”http://www.w3.org/1999/xhtml” >
<head>
<title>JS获取当月最后一天</title>
<script language=”javascript”>
function getLastDay(year,month)
{
var new_year = year;    //取当前的年份
var new_month = month++;//取下一个月的第一天,方便计算(最后一天不固定)
if(month>12)            //如果当前大于12月,则年份转到下一年
{
new_month -=12;        //月份减
new_year++;            //年份增
}
var newnew_date = new Date(new_year,new_month,1);                //取当年当月中的第一天
return (new Date(new_date.getTime()-1000*60*60*24)).getDate();//获取当月最后一天日期
}
</script>
<body>
<input id=”Button1″ type=”button” value=”取2007年5月的最后一天” onClick=”alert(getLastDay(2007,5))” />
</body>
</html>

mysql 去除重复 Select中DISTINCT关键字的用法 (转)

2011年07月13日

在使用mysql时,有时需要查询出某个字段不重复的记录,虽然mysql提供 有distinct这个关键字来过滤掉多余的重复记录只保留一条,但往往只用它来返回不重复记录的条数,而不是用它来返回不重记录的所有值。其原因是 distinct只能返回它的目标字段,而无法返回其它字段,这个问题让我困扰了很久,用distinct不能解决的话,我只有用二重循环查询来解决,而 这样对于一个数据量非常大的站来说,无疑是会直接影响到效率的。所以我花了很多时间来研究这个问题,网上也查不到解决方案,期间把容容拉来帮忙,结果是我 们两人都郁闷了。。。。。。。。。

下面先来看看例子:

table
id name
1 a
2 b
3 c
4 c
5 b

库结构大概这样,这只是一个简单的例子,实际情况会复杂得多。

比如我想用一条语句查询得到name不重复的所有数据,那就必须使用distinct去掉多余的重复记录。

select distinct name from table
得到的结果是:

name
a
b
c

好像达到效果了,可是,我想要得到的是id值呢?改一下查询语句吧:

select distinct name, id from table

结果会是:

id name
1 a
2 b
3 c
4 c
5 b

distinct怎么没起作用?作用是起了的,不过他同时作用了两个字段,也就是必须得id与name都相同的才会被排除。。。。。。。

我们再改改查询语句:

select id, distinct name from table

很遗憾,除了错误信息你什么也得不到,distinct必须放在开头。难到不能把distinct放到where条件里?能,照样报错。。。。。。。

很麻烦吧?确实,费尽心思都没能解决这个问题。没办法,继续找人问。

拉住公司里一JAVA程序员,他给我演示了oracle里使用distinct之后,也没找到mysql里的解决方案,最后下班之前他建议我试试group by。

试了半天,也不行,最后在mysql手册里找到一个用法,用group_concat(distinct name)配合group by name实现了我所需要的功能,兴奋,天佑我也,赶快试试。

报错。。。。。。。。。。。。郁闷。。。。。。。连mysql手册也跟我过不去,先给了我希望,然后又把我推向失望,好狠哪。。。。

再仔细一查,group_concat函数是4.1支持,晕,我4.0的。没办法,升级,升完级一试,成功。。。。。。

终于搞定了,不过这样一来,又必须要求客户也升级了。

突然灵机一闪,既然可以使用group_concat函数,那其它函数能行吗?

赶紧用count函数一试,成功,我。。。。。。。想哭啊,费了这么多工夫。。。。。。。。原来就这么简单。。。。。。

现在将完整语句放出:

select *, count(distinct name) from table group by name

结果:

id name count(distinct name)
1 a 1
2 b 1
3 c 1

最后一项是多余的,不用管就行了,目的达到。。。。。

唉,原来mysql这么笨,轻轻一下就把他骗过去了,郁闷也就我吧(对了,还有容容那家伙),现在拿出来希望大家不要被这问题折腾。

哦,对,再顺便说一句,group by 必须放在 order by 和 limit之前,不然会报错。。。。。。。。!OK了


补充:

经过本人测试 select *, count(distinct name) from table group by name 就可以了。

mysql版本:5.0.86-community-nt

解决IE8下float right 换行bug

2011年06月15日
<div id="box_prev_next">
<span class="prev" style="float:left;">
  <a href="#" ><img src="templates/default/images/prev.gif" alt="Prev"/></a>
</span>
<span class="next" style="float:right;">
  <a href="#" ><img src="templates/default/images/next.gif" alt="Next"/></a>
</span>
</div>

结果ie8下next.gif换行了,firefox正常。只要把float:right;的span放到最前边就可以解决换行的问题,ie8和firefox下均正常。代码如下

<div id="box_prev_next">
<span  style="float:right;">
  <a href="#" ><img   src="templates/default/images/next.gif"   alt="Next"/></a>
</span>
<span style="float:left;">
  <a href="#" ><img  src="templates/default/images/prev.gif"  alt="Prev"/></a>
</span>
</div>

防止点击空链接时,页面往往重置到页首

2011年05月13日

把代码“javascript:void(null)”代替原来的“#”标记

例如:

原来的代码:
<a href=”#”>…</a>

替换成:
<a href=”javascript:void(null)”>…</a>

变量未定义 upload_5xSoft

2011年03月10日
Microsoft VBScript 运行时错误 '800a01fa'

类没有被定义: 'upload_5xSoft'

你可能会奇怪,为什么传到空间可以,而在本地运行就不行了呢。
如果本地用的是IIS运行是正常的,而如果你用的是netbox,就会产生这样的问题,
只需要把netbox不支持的语句换掉:具体有以下几个方案。

方案一
把upload.inc里面的

  换 成  %>  就OK。

方案二
复制下列代码,另存为upload.inc
<%

dim upfile_5xSoft_Stream

Class upload_5xSoft

dim Form,File,Version

Private Sub Class_Initialize
dim iStart,iFileNameStart,iFileNameEnd,iEnd,vbEnter,iFormStart,iFormEnd,theFile
dim strDiv,mFormName,mFormValue,mFileName,mFileSize,mFilePath,iDivLen,mStr
Version="任翔专用上传程序"
if Request.TotalBytes<1 then Exit Sub
set Form=CreateObject("Scripting.Dictionary")
set File=CreateObject("Scripting.Dictionary")
set upfile_5xSoft_Stream=CreateObject("Adodb.Stream")
upfile_5xSoft_Stream.mode=3
upfile_5xSoft_Stream.type=1
upfile_5xSoft_Stream.open
upfile_5xSoft_Stream.write Request.BinaryRead(Request.TotalBytes)

vbEnter=Chr(13)&Chr(10)
iDivLen=inString(1,vbEnter)+1
strDiv=subString(1,iDivLen)
iFormStart=iDivLen
iFormEnd=inString(iformStart,strDiv)-1
while iFormStart < iFormEnd
iStart=inString(iFormStart,"name=""")
iEnd=inString(iStart+6,"""")
mFormName=subString(iStart+6,iEnd-iStart-6)
iFileNameStart=inString(iEnd+1,"filename=""")
if iFileNameStart>0 and iFileNameStartiStart then
mFileSize=iEnd-iStart-4
else
mFileSize=0
end if
set theFile=new FileInfo
theFile.FileName=getFileName(mFileName)
theFile.FilePath=getFilePath(mFileName)
theFile.FileSize=mFileSize
theFile.FileStart=iStart+4
theFile.FormName=FormName
file.add mFormName,theFile
else
iStart=inString(iEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)

if iEnd>iStart then
mFormValue=subString(iStart+4,iEnd-iStart-4)
else
mFormValue=""
end if
form.Add mFormName,mFormValue
end if

iFormStart=iformEnd+iDivLen
iFormEnd=inString(iformStart,strDiv)-1
wend
End Sub

Private Function subString(theStart,theLen)
dim i,c,stemp
upfile_5xSoft_Stream.Position=theStart-1
stemp=""
for i=1 to theLen
if upfile_5xSoft_Stream.EOS then Exit for
c=ascB(upfile_5xSoft_Stream.Read(1))
If c > 127 Then
if upfile_5xSoft_Stream.EOS then Exit for
stemp=stemp&Chr(AscW(ChrB(AscB(upfile_5xSoft_Stream.Read(1)))&ChrB(c)))
i=i+1
else
stemp=stemp&Chr(c)
End If
Next
subString=stemp
End function

Private Function inString(theStart,varStr)
dim i,j,bt,theLen,str
InString=0
Str=toByte(varStr)
theLen=LenB(Str)
for i=theStart to upfile_5xSoft_Stream.Size-theLen
if i>upfile_5xSoft_Stream.size then exit Function
upfile_5xSoft_Stream.Position=i-1
if AscB(upfile_5xSoft_Stream.Read(1))=AscB(midB(Str,1)) then
InString=i
for j=2 to theLen
if upfile_5xSoft_Stream.EOS then
inString=0
Exit for
end if
if AscB(upfile_5xSoft_Stream.Read(1))<>AscB(MidB(Str,j,1)) then
InString=0
Exit For
end if
next
if InString<>0 then Exit Function
end if
next
End Function

Private Sub Class_Terminate
form.RemoveAll
file.RemoveAll
set form=nothing
set file=nothing
upfile_5xSoft_Stream.close
set upfile_5xSoft_Stream=nothing
End Sub

Private function GetFilePath(FullPath)
If FullPath <> "" Then
GetFilePath = left(FullPath,InStrRev(FullPath, "\"))
Else
GetFilePath = ""
End If
End function

Private function GetFileName(FullPath)
If FullPath <> "" Then
GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)
Else
GetFileName = ""
End If
End function

Private function toByte(Str)
dim i,iCode,c,iLow,iHigh
toByte=""
For i=1 To Len(Str)
c=mid(Str,i,1)
iCode =Asc(c)
If iCode<0 Then iCode = iCode + 65535 If iCode>255 Then
iLow = Left(Hex(Asc(c)),2)
iHigh =Right(Hex(Asc(c)),2)
toByte = toByte & chrB("&H"&iLow) & chrB("&H"&iHigh)
Else
toByte = toByte & chrB(AscB(c))
End If
Next
End function
End Class

Class FileInfo
dim FormName,FileName,FilePath,FileSize,FileStart
Private Sub Class_Initialize
FileName = ""
FilePath = ""
FileSize = 0
FileStart= 0
FormName = ""
End Sub

Public function SaveAs(FullPath)
dim dr,ErrorChar,i
SaveAs=1
if trim(fullpath)="" or FileSize=0 or FileStart=0 or FileName="" then exit function
if FileStart=0 or right(fullpath,1)="/" then exit function
set dr=CreateObject("Adodb.Stream")
dr.Mode=3
dr.Type=1
dr.Open
upfile_5xSoft_Stream.position=FileStart-1
upfile_5xSoft_Stream.copyto dr,FileSize
dr.SaveToFile FullPath,2
dr.Close
set dr=nothing
SaveAs=0
end function
End Class
%>