IP地址在mysql的存储(IP地址和int的转换)

文章作者:Enjoy 转载请注明原文链接。

PHP
echo ip2long(‘192.168.1.38’);
输出:3232235814

MYSQL
SELECT INET_ATON(‘192.168.1.38’);
输出:3232235814

两个函数返回的结果是一样的,都是A*256*256*256+B*256*256+C*256+D的算法
192*256*256*256+168*256*256+1*256+38 = 3 232 235 814

反过来,从int转换为IP地址分别是php的long2ip()和mysql的INET_NTOA()。

mysql存储这个值是字段需要用int UNSIGNED。不用UNSIGNED的话,128以上的IP段就存储不了了。

传统的方法,创建varchar(15),需要占用15个字节,而改时使用int只需要4字节,可以省一些字节。

php存入时:$ip = ip2long($ip);
mysql取出时:SELECT INET_ATON(ip) FROM table …
php取出时,多一步:$ip = long2ip($ip);

转换以前的数据:

1.把以前的varchar()数据转换为int型的SQL语句:
UPDATE `hx_table` SET ip =  INET_ATON(ip) WHERE INET_ATON(ip) is NOT NULL
2.把字段更改为int型:
ALTER TABLE `hx_table` CHANGE `ip` `ip` INT UNSIGNED NOT NULL
3.程序做相应修改上传,完成。

@@UPDATE@@20110310:

在32位的机子上,echo ip2long(‘192.168.1.38’);由于超过32位的最大数,导致输出负数-1062731482。

有两种方法更新为正数:
$ip_long = bindec(decbin(ip2long($ip)));

$ip_long = = sprintf(“%u”, ip2long($ip));
因此一种是修改PHP程序,使其肯定存入正数。
另一种是将mysql的这个字段使用int,非UNSIGNED,使其可以存入负数。

MS SQL SERVER 数据字典 生成SQL

在库内查询,可用于生成如下字段结构:

[表], [字段], [数据类型], [允许为空], [主键], [外键], [引用表], [说明描述]

SELECT TOP (100) PERCENT a.name AS 表, b.name AS 字段, c.name AS 数据类型, CASE WHEN b.isnullable = 0 THEN '-' WHEN b.isnullable = 1 THEN '是' END AS 允许为空,
CASE WHEN d .name IS NULL THEN '-' WHEN d .name IS NOT NULL THEN '是' END AS 主键, CASE WHEN e.parent_object_id IS NULL THEN 0 ELSE 1 END AS 外键,
CASE WHEN e.parent_object_id IS NULL THEN '-' ELSE g.name END AS 引用表, CASE WHEN h.value IS NULL THEN '-' ELSE h.value END AS 说明描述,
i.text AS 默认值
FROM sys.sysobjects AS a INNER JOIN
sys.syscolumns AS b ON a.id = b.id INNER JOIN
sys.systypes AS c ON b.xtype = c.xtype LEFT OUTER JOIN
(SELECT so.id, sc.colid, sc.name
FROM sys.syscolumns AS sc INNER JOIN
sys.sysobjects AS so ON so.id = sc.id INNER JOIN
sys.sysindexkeys AS si ON so.id = si.id AND sc.colid = si.colid
WHERE (si.indid = 1)) AS d ON a.id = d.id AND b.colid = d.colid LEFT OUTER JOIN
sys.foreign_key_columns AS e ON a.id = e.parent_object_id AND b.colid = e.parent_column_id LEFT OUTER JOIN
sys.objects AS g ON e.referenced_object_id = g.object_id LEFT OUTER JOIN
sys.extended_properties AS h ON a.id = h.major_id AND b.colid = h.minor_id LEFT OUTER JOIN
sys.syscomments AS i ON b.cdefault = i.id
WHERE (a.type = 'U') AND (c.name <> 'sysname')
ORDER BY 表, 字段

还有一个查全库表字段的,参见另一篇 《通过(sys.sysobjects)对象表,查询全库表的基础信息Sql Server 查询全库表信息

Vesta 主机控制面板

http://vestacp.com/

Vesta,是一个非常简单明了的服务器主机控制面板界。

它速度快,易于使用
安装很简单,界面友好
无需过多配置即可使用
轻形、 快速,资源占用少。

# 当前支持的操作系统:
# RHEL 5, RHEL 6
# CentOS 5, CentOS 6
# Debian 7
# Ubuntu 12.04, Ubuntu 12.10, Ubuntu 13.04, Ubuntu 13.10, Ubuntu 14.04

多语言界面:英语,法语,德语,荷兰语,挪威语,芬兰语,瑞典语,西班牙语,葡萄牙语,意大利语,希腊语,中国,台湾普通话,印度尼西亚,罗马尼亚,波黑,捷克,匈牙利,乌克兰,俄语,土耳其语,阿拉伯语

安装 Vesta 控制面板

1. Root用户登录 SSH
ssh root@your.server-name

2. 下载安装脚本
curl -O http://vestacp.com/pub/vst-install.sh

3. 运行脚本
sh vst-install.sh

卸载 Vesta 控制面板

1. 停止 vesta 服务
service vesta stop

2. 移除 vesta 软件包和软件资源库
RHEL/CentOS:
yum remove vesta*
rm -f /etc/yum.repos.d/vesta.repo

Debian/Ubuntu:
apt-get remove vesta*
rm -f /etc/apt/sources.list.d/vesta.list

3. 删除数据文件夹
rm -rf /usr/local/vesta

你也可以考虑删除管理员用户帐户和其 cron 作业。

shtml中的脚本 – SSI 服务器端包含 (Server Side Includes)

服务器端包含

 

介绍

服务器端包含(Server Side Includes),通常简称为SSI,是HTML页面中的指令,在页面被提供时由服务器进行运算,以对现有HTML页面增加动态生成的内容,而无须通过CGI程序提供其整个页面,或者使用其他动态技术。

对什么时候用SSI,而什么时候用某些程序生成整个页面的权衡,取决于页面中有多少内容是静态,有多少内容需要在每次页面被提供时重新计算。SSI是一种增加小段信息的好方法,诸如当前时间。如果你的页面大部分是在被提供时生成的,那就要另找方案了。

。将服务器信息添加到一个 HTML 文档。包括以下的形式:

<!--#command variablename="value"-->
Whether or not you can use SSI on your site depends on your provider. Ask your favourite support person if you can use SSI, what server software is used and if there are any special techniques, conditions or rules. For example, on my site I can only use SSI in files that have an .shtml extension instead of the normal .html one. You also have to ask what path to files to use.

Unfortunately, not all includes explained here work for all servers. For example, the #hide and #show includes are specific to WebStar. With Apache server software, you can achieve the same things by using #if and #endif.

更改时间格式

Before starting to use server side includes, you need to configure a number of things. For starters, choose a format for date and time you like (the #echo command is explained later in this chapter).

<!–#config timefmt=”%A, %d %B %Y at %H:%M:%S”–>
<!–#echo var=”date_gmt”–>

Below is a table of many of the options you can use. You can also include things like colons, commas and slashes as well as bits of text and HTML. You can mix the elements below at will.

Element Value Example
%a Abbreviated day of the week Sun
%A Day of the week Sunday
%b Abbreviated month name Jan
%B Month in full January
%d Date 1 (and not 01)
%H 24-hour clock hour 13
%I 12-hour clock hour 1
%j Decimal day of the year 360
%m Month number 11
%M Minutes 08
%p AM or PM AM
%S Seconds 09
%U Week of the year (also %W) 49
%w Day of the week number 05
%y Year of the century 95
%Y Year 1995
%Z Time zone EST

Here are some more examples of different formats:

<!–#config timefmt=”Week %U of %y”–>
<!–#echo var=”date_gmt”–>

<!–#config timefmt=”%d/%m/%y, day %j of the year”–>
<!–#echo var=”date_gmt”–>

<!–#config timefmt=”%I:%S %p”–>
<!–#echo var=”date_gmt”–>

The last format you have set will remain valid throughout the rest of the page. However, unless you want to use the default format (which usually is something like 98/07/12:16:45:34) you will have to set your favourite time format in every page that uses server side includes that have to do with time.

更改大小格式

You can also specify the way file sizes are displayed.

<!–#config sizefmt=”bytes”–>
<!–#fsize file=”top.gif”–>
<!–#config sizefmt=”abbrev”–>
<!–#fsize file=”top.gif”–>


The #fsize include is explained later in this chapter. You can see that the “bytes” option gives the size in full in bytes, the “abbrev” option gives the size in kilobytes.

自定义错误消息

You can change the default error message to anything you want. Here is an example of changing the error message and then trying to include the non-existent file “nosuchfile.html”:

<!–#config errmsg=”Sorry, an error occurred. Please mail your complaints to webmaster@somewhere.net”–>

<!–#include file=”nosuchfile.html”–>

There is only one error message available. However, you can change the error message more than once in a single html file:

<!–#config errmsg=”Sorry, an error occurred including nosuchfile.html. Please mail your complaints to webmaster@somewhere.net”–>

<!–#include file=”nosuchfile.html”–>

<!–#config errmsg=”Sorry, an error occurred including nosuchfileagain.html. Please mail your complaints to webmaster@somewhere.net”–>

<!–#include file=”nosuchfileagain.html”–>

Specifying your own error messages will make it easier for you to spot and solve problems. If you want to use more than one error message, you have to make sure that you change the error message before the command it refers to.

包括文件

The include command allows you to dynamically insert other HTML files into the current HTML file. Use it like this:

<!–#include file=”file.shtml”–>

What path to use, again, depends on your provider. Normally it will be a path that is local to the server, so it will not include http://etc. The most sensible use of this command is to take standard bits of your pages such as headers and footer and put them in a separate file. On all of your pages you use the include command to include that file. That way, in order to change the footer on all pages, you only need to change one file. For example, you could make a simple text file that contains:

<P ALIGN=”center”>Copyright 1998 Tom, Dick and Harry<BR>
Please mail us at tom.dick@harry.com</P

You save this file as ssifooter.html and include it in your other files by using:

<!–#include file=”ssifooter.html”–>

The files you include can be plain text files or can include HTML. You don’t need to give them <HEAD> and <BODY> tags, just put in whatever you want to insert. In these files you can use whatever HTML you want and you can make links, etc.

隐藏 / 显示

With the Hide and Show commands you can avoid that your reader sees certain parts of the document:

<P>Now you see me, <!–#hide–> This text is not shown. <!–#show–> now you don’t.</P

Show and Hide can be used to temporary exclude parts of your document. Hide and Show only work under WebStar, so I cannot show you an example here.

根据时间隐藏和显示

The next example shows how to display bits of HTML only after certain days. Comparisons like this always use the default time format of 1998/07/24:17:34:45 no matter what you have done with the timefmt option.

<!–#hide–>
<!–#show after=”1998/06/30″–>
This text is shown after 30 June 1998.
<!–#show–>

<!–#hide–>
<!–#show after=”1999/06/30″–>
This text is shown after 30 June 1999.
<!–#show–>

Or you can show and hide things on specific days using a combination of ‘hide after’ and ‘show after’:

<!–#hide–>
<!–#show during=”1998/07/12″–>
This text is shown on 12 July 1998.
<!–#show–>

<!–#hide–>
<!–#show during=”1998/07/13″–>
This text is shown on 13 July 1998.
<!–#show–>

<!–#hide–>
<!–#show during=”1998/07/14″–>
This text is shown on 14 July 1998.
<!–#show–>

As you can see, you do not have to specify a full date and time but only what is relevant for you. If you would want to show something during 1998 you could use: during=”1998″.

依据时间隐藏和显示

Here is an example of how to show a bit of text only to a user of Netscape’s Navigator:

<!–#hide–>
<!–#show var=”http_user_agent” operator=”contains”
value=”nav”–>
Welcome Netscape Navigator user!
<!–#show–>

<!–#hide–>
<!–#show var=”http_user_agent” operator=”contains”
value=”MSIE”–>
Welcome Internet Explorer user!
<!–#show–>

As you can see in this example, the output of Webstar is by default on. That’s why you start any of these examples by switching the output of (#hide) and then switching it on again if the appropriate condition is fulfilled. At the end of the example you switch the output on again with a #show include. Again, show and hide do not work under Apache so I cannot show you the result here.

随机隐藏和显示

Show and Hide can also be used at random:

<!–#hide–>
<!–#show var=”random” op=”<” value=”50″ –>
Heads
<!–#hide–>
<!–#show var=”random” op=”=>” value=”50″ –>
Tails
<!–#show–>

If you do a couple of reloads, you should see the text change. Of course you can use the same thing to show and hide images or any other HTML. The number that is used by Webstar is a random number ranging from 1 to 99 inclusive. Here is an example for three random texts:

<!–#hide–>
<!–#show var=”random” op=”<” value=”33″ –>
To be or not to be,
<!–#hide–>
<!–#show var=”random” op=”=>” value=”34″ –>
<!–#hide var=”random” op=”>” value=”66″ –>
that’s the question,
<!–#hide–>
<!–#show var=”random” op=”>” value=”66″ –>
my dear Watson.
<!–#show–>

更多的隐藏和显示

In fact you can show and hide text at will using any of the environment variables (see the section on Echo below). This example shows a bit of text to a user with IP address 195.99.40.125:

<!–#hide–>
<!–#show var=”remote_addr” operator=”=” value=”195.99.40.125″–>
Welcome BTinternet user!
<!–#show–>

If you have friends with fixed IP addresses you can leave messages especially for them in the same manner. Finally, you should know which operators are available:

Operator Meaning
“contains” or “con” variable contains the value string
“starts with” or “start” variable starts with the value string
“ends with” or “end” variable ends with the value string
“=” or “==” variable equals the value string
“!=” or “<>” variable does not equal the value string
“<“ variable is less than the value string
“<=” or “=<“ variable is less than or equal to the value string
“>” variable is greater than the value string
“>=” or “=>” variable is greater than or equal to the value string

If 和 Endif

Because this server runs Apache I could not show the examples of #hide and #show. I can, however, demonstrate the #if and #endif includes (if and endif, in turn, do not work under Webstar):

<!–#config timefmt=”%A”–>
<!–#if expr=”$date_gmt = Friday” –>
Hang in there, it’s almost weekend
<!–#elif expr=”($date_gmt = Saturday) || ($date_gmt = Sunday)” –>
Have a nice weekend
<!–#else –>
Have a good day
<!–#endif –>

Hang in there, it’s almost weekend Have a nice weekend Have a good day

The first thing you will notice is that the #if include, opposite to the #hide and #show, does use the date as formatted with timefmt. This has some clear advantages. You can also see that this example is a bit easier to understand the #show and #hide spaghetti that WebStar seems to need. Note that the #if and #endif are obligatory, the #elif and #else are optional. This example uses date_gmt which is London time -ignoring summertime- rather than date_local which depends on where the server is.

The following operators are available:

Operator Meaning
string1 = string2 string1 equals string2
string1 != string2 string1 does not equal string2
string1 < string2 string1 is less than string2
string1 <= string2 string1 is less than or equal to string2
string1 > string2 string1 is greater than string2
string1 >= string2 string1 is greater than or equal to string2

If, Endif 和环境变量

you can use the #if include to show different information to different browsers. Each browser sets the environment variable http_user_agent differently. This is how Netscape Navigator 4.04, Microsoft Internet Exploder and Apple’s Cyberdog respectively do it:

Mozilla/4.04 (Macintosh; I; PPC, Nav)
Mozilla/4.0 (compatible; MSIE 4.0; Mac_PowerPC)
Cyberdog/2.0 (Macintosh; PPC)

As you can see these are all the Macintosh versions. By the way, this is what your own browser makes of http_user_agent: . So this is how to show different information to different browsers:

<!–#if expr=”$HTTP_USER_AGENT=/MSIE/ ” –>
Fight the Microsoft Monopoly. Get Netscape!
<!–#elif expr=”$HTTP_USER_AGENT=/Nav/ ” –>
Welcome Netscape Navigator user!
<!–#elif expr=”$HTTP_USER_AGENT=/Cyberdog/ ” –>
Welcome Apple Cyberdog user!
<!–#else –>
Welcome! So what browser are you using?
<!–#endif –>

Fight the Microsoft Monopoly. Get Netscape! Welcome Netscape Navigator user! Welcome Apple Cyberdog user! Welcome! So what browser are you using?

Note that the /Nav/ I am looking for here is produced by Netscape Navigator, which is Communicator without the news, mail and webeditor modules. The above is obviously not an exhaustive list of browsers, which is why there is also an #else include for all the browsers that are not covered.

The two slashes around MSIE, Nav and Cyberdog in the example above means that the second string is interpreted as a regular expression, commonly used under Unix. In this case it checks if http_user_agent contains that string.

Set

The #set include can be used to create your own variables and assign them a value. Variables can be printed or can be used in #if statements:

<!–#set var=”carmodel” value=”Mercedes” –>
<!–#echo var=”carmodel” –><BR>
<!–#if expr=”$carmodel = Mercedes” –>
That’s a jolly nice car
<!–#endif –>


That’s a jolly nice car

The $ sign in the #if include is needed to ensure that “carmodel” is interpreted as a variable, not as a string.

Echo

ECHO can be used to insert information from the browser and the server into your document, the so-called environment variables. The following possibilities are available:

Document Name: <!–#echo var=”document_name”–>
Document URI: <!–#echo var=”document_uri”–>
Local Date: <!–#echo var=”date_local”–>
GMT Date: <!–#echo var=”date_gmt”–>
Last Modified: <!–#echo var=”last_modified”–>
Server Software: <!–#echo var=”server_software”–>
Server Name: <!–#echo var=”server_name”–>
Server Protocol: <!–#echo var=”server_protocol”–>
Server Port: <!–#echo var=”server_port”–>
Gateway Interface: <!–#echo var=”gateway_interface”–>
Request Method: <!–#echo var=”request_method”–>
Script Name: <!–#echo var=”script_name”–>
Remote Host: <!–#echo var=”remote_host”–>
Remote Address: <!–#echo var=”remote_addr”–>
Remote User: <!–#echo var=”remote_user”–>
Content Type: <!–#echo var=”content_type”–>
Content Length: <!–#echo var=”content_length”–>
HTTP Accept: <!–#echo var=”http_accept”–>
HTTP User Agent (Browser): <!–#echo var=”http_user_agent”–>
HTTP Cookie: <!–#echo var=”http_cookie”–>
Unescaped query string: <!–#echo var=”query_string_unescaped”–>
Query String: <!–#echo var=”query_string”–>
Path Info: <!–#echo var=”path_info”–>
Path Translated: <!–#echo var=”path_translated”–>
Referer: <!–#echo var=”referer”–>
Forwarded: <!–#echo var=”forwarded”–>

Document Name:
Document URI:
Local Date:
GMT Date:
Last Modified:
Server Software:
Server Name:
Server Protocol:
Server Port:
Gateway Interface:
Request Method:
Script Name:
Remote Host:
Remote Address:
Remote User:
Content Type:
Content Length:
HTTP Accept:
HTTP User Agent (Browser):
HTTP Cookie:
Unescaped query string:
Query String:
Path Info:
Path Translated:
Referer:
Forwarded:

Not all ECHO commands always result in information being printed. This can depend on the server, on your browser and on the way you reached this page. The #echo include works both under WebStar and Apache.

Print Environment

If you want to print the entire environment, you do not need to use a whole list of #echo includes. Instead you can use this shortcut.

<PRE> <!–#printenv –> </PRE>



Note that the environment includes the variable “carmodel” that was defined in an earlier example.

执行脚本

You can use a server side include to run a script. This is what I use on my homepage:

<!–#exec cgi=”ssi.demo.cgi”–>

The CGI script (which is in Perl 5) opens a file with a dozen quotes, selects one at random and prints it to the page. The script, by the way, is courtesy of Matt Wright who offers a brilliant collection of scripts.

文件大小

You can insert the size of a file in this way:

<!–#fsize file=”top.gif”–>

This inserts the size of the file top.gif (the logo at the top of this page). As explained earlier in this chapter, you can determine if the size is displayed in full bytes or abbreviated in kilobytes or megabytes.

文件日期

You can insert the date of a file in this way:

<!–#flastmod file=”top.gif”–>

This inserts the date and the time the file top.gif (the logo at the top of this page) was last modified. The format of the date and time can be customized by you as explained earlier in this chapter.

This page has been translated into Spanish language by Maria Ramos from Webhostinghub.com.

 

 

通过动态字符串获取变量值 & 获取变量名称

一段实例代码, 在 c#中通过 Linq 取变量的名称, 以及 将字符串转为变量名,通过字符串给变量赋值.

        string strApp = "app";
        public string app = "AAA";
        public string strTest = "TEST";
        protected void Button1_Click(object sender, EventArgs e)
        {

            //通过字符串获得变量值
            string aaa1 = this.GetType().GetField("app").GetValue(this).ToString();
            //或者
            string aaa2 = this.GetType().GetField(strApp).GetValue(this).ToString();
            //通过给变量赋值
            this.GetType().GetField("strTest").SetValue(this, "C#123");
            //新的值
            string bbb = this.GetType().GetField("strTest").GetValue(this).ToString();

            //获取变量名称
            string ccc = GetVarName(p=>this.strTest);
        }

        //获取变量名称
        public static string GetVarName(System.Linq.Expressions.Expression<Func<string, string>> exp)
      {
            return ((System.Linq.Expressions.MemberExpression)exp.Body).Member.Name;
      }

 

Team Foundation Server(TFS) 源代码管理服务器 更换IP地址或端口

源码管理服务器 Team Foundation Server(TFS) 的ip地址发生改变后, 解决方案连不上了.

解决方法是:

  • 1  打开”团队” -> “连接到 Team Foundation Server”, 移除原服务器地址

20140804104552

  • 2  编辑 项目解决方案.sln文件, 修改里面的 “SccTeamFoundationServer” 后面的TFS地址为新地址

  20140804105319

  • 3  打开 “C:\Users\Administrator\AppData\Local\Microsoft\Team Foundation\3.0\Cache”  版本不同, 文件夹可能是4.0.

修改 LocationServerMap.xml 文件, 删除其中的 “location” = 原地址的条目.

 20140804104744

  • 4  重新打来项目连接到TFS

 20140804104621

SuperHidden.vbs , 右键 添加\卸载 “显示\隐藏 系统文件”

一段VB脚本,将“显示隐藏系统文件”加入到右键,如图。

20140725101903

Dim WSHShell
Set WSHShell = WScript.CreateObject("WScript.Shell")
WSHShell.RegWrite "HKCR\CLSID\{00000000-0000-0000-0000-000000000012}\Instance\InitPropertyBag\CLSID", "{13709620-C279-11CE-A49E-444553540000}", "REG_SZ"
WSHShell.RegWrite "HKCR\CLSID\{00000000-0000-0000-0000-000000000012}\Instance\InitPropertyBag\method", "ShellExecute", "REG_SZ"
if WSHShell.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\HideFileExt") = 0 then
WSHShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ShowSuperHidden", "0", "REG_DWORD"
WSHShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden", "2", "REG_DWORD"
WSHShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\HideFileExt", "1", "REG_DWORD"
WSHShell.RegWrite "HKCR\CLSID\{00000000-0000-0000-0000-000000000012}\Instance\InitPropertyBag\command", "显示扩展名及文件", "REG_SZ"
WSHShell.SendKeys "{F5}+{F10}e"
else
WSHShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ShowSuperHidden", "1", "REG_DWORD"
WSHShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden", "1", "REG_DWORD"
WSHShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\HideFileExt", "0", "REG_DWORD"
WSHShell.RegWrite "HKCR\CLSID\{00000000-0000-0000-0000-000000000012}\Instance\InitPropertyBag\command", "隐藏扩展名及文件", "REG_SZ"
WSHShell.SendKeys "{F5}+{F10}e"
end if
Set WSHShell = Nothing
WScript.Quit(0)

VPS下对mysql内存性能的优化

VPS的内存对性能至关重要,所以很有必要优化一下。

看了几篇针对vps小内存优化的文章,于是自己也动手参照优化下自己的mysql。

修改过调整好的 my.cnf ,service mysqld restart 启动时报错。

查看log,发现 skip-innodb / skip-bdb / skip-locking,这几个参数有问题。

 

继续学习,查资料,得知 使用的参数都是老版本的参数,mysql5.1对应的为:

skip-innodb  –>  loose-skip-innodb

skip-locking  –> skip-external-locking

skip-bdb (已经废除了skip-bdb这个参数!)

 

配置文件: /etc/my.cnf

# low memory stuff – Mr.Tang
# Tue May 26 22:23:15 CST 2015

[mysqld]

loose-skip-innodb
skip-external-locking
skip-host-cache
skip-name-resolve

character_set_server = utf8
default-storage-engine = myisam

key_buffer_size = 256M
key_buffer = 256K
max_allowed_packet = 1M
myisam_sort_buffer_size = 8M
net_buffer_length = 128K
query_cache_size= 16M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
sort_buffer_size = 1M
table_cache = 4M
table_open_cache = 16M
thread_cache_size = 8M
thread_stack = 131072

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
#safe-updates

[isamchk]
key_buffer = 8M
sort_buffer_size = 8M

[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

优化WordPress,解决加载慢,等待google引用地址超时问题

近几个月发现空间经常很慢,特别是WordPress响应非常迟钝,但一直懒得动它。 前几天实在受不了,正巧看到一个特价的vps,就用paypal支付了$,买了一个. 搞好了系统,配置好环境,就在准备迁移WordPress数据的时候,偶然看到一个文章,说近来几个月很多人的WordPress都是变的很慢。 查了查相关文章,跟google被墙有关,原因是wp的字体加载的都是 在google托管的,还有些js,css脚本等等,比如:

<link href='http://fonts.googleapis.com/css?family=Open+Sans:300,400,600&subset=latin,latin-ext' rel='stylesheet'>

<script src="http://html5shim.googlecode.com/svn/trunk/html5.js">

<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=3.4.2'></script>

这样 googleapis.com,googlecode.com 无法联通,自然相关引用的字体,脚本也都无法加载,只有等待主机超时, 所以WordPress都变的很慢。 知道问题所在就处理它。

 [ 只解决最影响加载速度的字体就可以了 ]

1。不使用google字体

编辑主题的 functions.php文件,在末尾添加以下代码:
//禁用Open Sans
class Disable_Google_Fonts {
public function __construct() {
add_filter( ‘gettext_with_context’, array( $this, ‘disable_open_sans’             ), 888, 4 );
}
public function disable_open_sans( $translations, $text, $context, $domain ) {
if ( ‘Open Sans font: on or off’ == $context && ‘on’ == $text ) {
$translations = ‘off’;
}
return $translations;
}
}
$disable_google_fonts = new Disable_Google_Fonts;

这里提供了由360网站卫士CDN驱动的常用前端公共库以及和谐使用Google公共库&字体库的调用方法

下面的方法2,3是使用 – 360网站卫士常用前端公共库CDN服务 替换 google的对应引用地址。

2。手动修改替换引用地址

打开wordpress文件: wp-includes/script-loader.php

搜: fonts.googleapis.com

替换:fonts.googleapis.com替换为 fonts.useso.com ,保存文件,发现问题解决了。

原理就是用360来加速google字体。

速度很好,360的加速很快。

3。使用插件

如何通过第三方Wordpress字体转换插件继续使用Google字体库? (感谢来自淘宝的soulteary童鞋开发了这个插件) 插件说明地址:http://www.soulteary.com/2014/06/08/replace-google-fonts.html 插件下载地址:http://www.soulteary.com/wp-content/uploads/2014/06/Replace-Google-Fonts.zip

—- P.S. 这样暂时就不用站点迁移了. 差点误会了服务商.

程序员的持续学习之道

原文出处: ShareCore (@Justin_Programer)

 

我其实是一个悲观主义者,从开始成为一名程序员的那一天开始,我就对自己的职业充满着担忧。早期,我担忧的是我刚进入这一行,落后身边从事这一行多年的人太多,跟他们比,我一开始就处于“不公平“的起跑线上;二是当我稍微深入这行后,发现技术的道路充满了歧路和死胡同,稍不留神,就将落入再也跟不上技术进步的节奏,身边也充斥着类似的示例。

好在在这条路上,我找到了一个克服担忧的良方:学习,坚持不懈的学习!

人类最大的恐惧莫过于对未知的恐惧,而学习,是克服未知的一个最有效途径。那作为一个程序员,该如何才能做到坚持不懈的学习呢?我想主要有以下几点:

1. 不抗拒变化,跟踪变化

这里说的变化,更多指的是技术的变化。新技术永远层出不穷,如果你抗拒变化,或惧怕变化,在心里优势上就落后了一大截。很多程序员的技术道路越走越窄,当一门新技术来临时,他们从不去了解或研究,他们要么认为这是”换汤不换药“的”技术幌子“,不值得去研究,要么等着别人去研究,自己被动的接受别人的结论与成果。诚然,等待别人的研究结果也可行,但是,当身边没有人去研究呢?当研究的人不愿意提供给你他的研究结果呢?当别人的结论和结果是错误的呢?

当然,业界的新技术层出不穷,要去跟踪每一项新技术的变化也是不可能的,我的建议是尽量掌握基础的技术,越是基础的技术越是恒定。如计算机的体系架构,TCP,HTTP,各类编程范式,OOP,MVC架构等,都是好多年来没有发生过变化的技术了。许多新技术也是建立在他们上面,当你了解了这些基础的技术,建立在他们之上的新技术也就能很快掌握了,并能迅速而准确地对这些新技术作出“价值判断”。

技术的变化,其实也并不全是指业界的新技术来临,更多指的是,超出自己当前技术能力外,主动研究和选择的“新技术” ,主动丢弃老的套路和技术,不固步自封。见过很多的程序员,他们写了很多年的代码了,技术能力还停留在数据库层写一个Sql(存储过程)+前端调用上。为什么如此呢?因为自开始写代码起,这样简单粗暴的方式就可以解决他们面对的问题了。所以,当碰到新的问题,他们就继续沿用着这种方式,而从不去看看业界是不是有更合适的方案来解决。长此以往,他们的技术能力也就不会有任何的变化,工作十年,只是将第一年所学的技术重复十年而已

2. 书宜杂读,业宜精钻

建筑学家梁思成赴美留学,其父梁启超告诫说:你该挤出一部分时间学些常识性东西,特别是文学或人文科学,稍稍多用点工夫就能有大的收获。我深怕你因所学太专一,把多彩的生活弄得平平淡淡,生活过于单调,则生厌倦心理,厌倦一生即成苦恼之事……书宜杂读,业宜精钻。

学习本身应该是一件很快乐的事情,但如果只是一味地沉浸于专业学习之中,难免会将本来快乐的事情弄成平淡和单调,更可怕的是,由此产生厌倦心理,放弃学习。

所以,可以尽量跟随自己的兴趣,去更广泛地读书。历史,文学,心理学,哲学等等各方面的书都可以尝试去读,它们不仅丰富你的知识,更能让你在阅读中受到感动、教育和启迪。书读的更多更广泛,知道的事也就多,思路更加开阔,解决问题的能力也就能高于常人,从而反过来帮助到你专业能力的提升。

3. 投资团队,积极打造学习型团队

现代社会,难免的一点就是个人必须置身于群体之中,程序员更是如此。从群体心理学的角度来看,在群体里,个人的才智被削弱,异质性被同质性所吞没。由此,如果一个团队不爱学习,那么,其中的成员也很难坚持学习(个性和意志力特别强的人除外)。

如果你爱学习,请想办法让你的团队也变得爱学习,这样,你对学习的坚持将变得更加容易。或许你认为建立学习氛围,是团队领导的事情,跟自己无关。领导当然可以来做也需要来做这样的事情,但要明白的一点,学习这事,如果变成从上向下,就难免“政治化”了,容易失去它本身的意义。而从下往上,更能建立轻松和谐的学习环境。