手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表2025年07月的文章

netbeans 包含路径乱码解决方案

本来一直在用komodo的,也没有注意过使用netbeans的情况。
但最近使用的时候发现有点小问题,所以就临时先转到netbeans下了。
问题情况是,使用komodo增加一个live folder,但是这个live folder里的class和function都不会被自动提示。。。一下子郁闷了。所以才转为netbeans

netbeans有一个全局包含,很爽的。。当然也可以 项目中包含路径。可惜,包含的文件一直乱码。我已经设置了netbeans的程序语言编码为UTF-8了。。最后没办法 ,只能询问google了。。还好,google是很大方的。他告诉了我一个链接:http://www.java2000.net/p12904,让我了解了解决方法

一直在网上找这个问题的解决方法,可是都是只有Netbenas5.5的解决方案,而且并没有根本的解决,今天上官方看了下,原来官方就有解决方法~哈哈~这招可以解决目前所有的版本,全部文件将用UTF-8解码.所以转移工作平台就更加简单咯~
这是原文:
For those who need to use international and multibyte characters, NetBeans can support UTF-8 editing. To enable it, go to your NetBeans installation directory and find the etc folder. There will be a file there called netbeans.conf.

This file keeps some configuration for NetBeans, including the default command line arguments. These are parameters that will be sent to a new starting Netbeans IDE.

Every argument lives inside a double-quoted variable called netbeans_default_options, and each one is separated from another by a space.

To enable UTF-8 in NetBeans, just place this parameter anywhere on the list of netbeans_default_options:-J-Dfile.encoding=UTF-8

中文解释一下:
1.找到你的Netbeans安装目录下的etc文件夹,如C:\Program Files\NetBeans 6.0 M9\etc
2.用记事本打开netbeans.conf
3.找到netbeans_default_options这一句(没带#号的,带#号的是注释)
4.在最后面加上一个空格,再加入-J-Dfile.encoding=UTF-8
如我现在的设置:
netbeans_default_options="-J-DAM_CONFIG_FILE=\"C:\Sun\AppServer\domains\domain1\config\AMConfig.properties\" -J-Dcom.sun.aas.installRoot=\"C:\Sun\AppServer\" -J-Xms128m -J-Xmx512m -J-XX:PermSize=32m -J-XX:MaxPermSize=160m -J-Dapple.laf.useScreenMenuBar=true -J-XX:+UseConcMarkSweepGC -J-XX:+CMSClassUnloadingEnabled -J-XX:+CMSPermGenSweepingEnabled -J-Dfile.encoding=UTF-8"
这样,打开的文件所有都用UTF-8解码了~哈哈,不再有乱码咯~

--EOF--
文中的意思是看官网才知道的,可惜我不认识英文啊。。不过,幸好解决了。打开netbeans一看,果然不再乱码。。激动了。

附上全局包含的图片,避免有同学误解:

大小: 10.69 K
尺寸: 265 x 171
浏览: 1715 次
点击打开新窗口浏览全图

 

看【博客园首页优化心得】

关注博客园那还是很早时候的事了。从博客园没几个人开始,到现在博客园的访问量超大,我都一直在看着,虽然我是用PHP进行开发,但并不妨碍我学习和关注.net的世界。

我不知道博客园是不是还在用那个什么text-blog【好象是这个,记得好象是开源的?】的系统了。反正博客园的页面是一改再改,当然我现在都是纯RSS订阅的,可能关注的也就少了一点。不过,对于博客园的大访问量,我还是依稀有印象,有一次dudu发博客说被百度的爬虫爬死的。

下面这篇文章是博客园团队关于首页优化的心得:

  周末,我们对博客园首页进行了优化,将其中的一些心得与大家分享。

  背景图片的优化

  博客园首页主导航的背景图片之前存在这样的问题:在IE和Chrome中第一次打开页面时,背景图片加载延迟比较明显,如果刷新页面,背景图片 所在位置会闪一下,即使图片是304状态(在FireFox中未出现这样问题,可能是FireFox加载背景图片的机制不同)。由于导航文字用的是淡灰色 (#EEEEEE),在没有背景图片的白色背景色下看起来很不舒服。

  开始我们使用两种优化方法,并没有产生效果。

  1. 背景图片的预加载

JavaScript代码
  1. <script type="text/javascript">  
  2. jQuery.preloadImages = function() {  
  3.         for (var i = 0; i < arguments.length; i++) {  
  4.             jQuery("<img>").attr("src", arguments[i]);  
  5.         }  
  6.     }  
  7. var staticImgUrl ="http://static.cnblogs.com/images/";  
  8. $.preloadImages(staticImgUrl + "bg_menu_nav.png");  
  9. </script>  

  参考文章:了解jQuery技巧来提高你的代码

  2. 背景图片的压缩

  所用工具:Pngcrush

  操作命令:pngcrush -reduce -brute bg_menu_nav.png bg_menu_nav2.png

  参考文章:Best Practices for Speeding Up Your Web Site

  接着,我们就想不用背景图,但用CSS不能实现背景图中的渐变色(filter只支持IE),于是试着用多个1px高的div拼渐变色效果,也没成功。

  后来,我们用了一个欺骗式的方法缓解了这个问题,给导航栏加一个与背景图片最接近的背景色,这样从无背景图片到有背景图片的加载过程中,颜色上的变化不会很大,从我们的体验,感觉还是可以接受的。

  HTML代码中的空格、空行处理

  使用下面的ASP.NET代码对页面输出进行清理

C#代码
  1. private static readonly Regex REGEX_LINE_BREAKS = new Regex(@"\n\s*", RegexOptions.Compiled);  
  2. private static readonly Regex REGEX_LINE_SPACE = new Regex(@"\n\s*\r", RegexOptions.Compiled);  
  3. private static readonly Regex REGEX_SPACE = new Regex(@"( )+", RegexOptions.Compiled);  
  4.   
  5. protected override void Render(HtmlTextWriter writer)  
  6. {  
  7.     using (HtmlTextWriter htmlwriter = new HtmlTextWriter(new System.IO.StringWriter()))  
  8.     {  
  9.         base.Render(htmlwriter);  
  10.         string html = htmlwriter.InnerWriter.ToString();  
  11.         html = REGEX_LINE_BREAKS.Replace(html, string.Empty);  
  12.         html = REGEX_LINE_SPACE.Replace(html, string.Empty);  
  13.         html = REGEX_SPACE.Replace(html, " ");  
  14.         writer.Write(html.Trim());  
  15.     }  
  16. }  

  更进一步的需要清理回车换行符。

  js文件压缩

  工具:JSMin

  命令:jsmin <site.src.js >site.js

  CSS命名缩短

  抱着省一个字节是一个字节的原则,将CSS的class命名缩短。

  部分内容采用脚本加载

  比如网站二级分类,改为jQuery调用WebService加载,不仅减小了页面大小,而且减小了服务器端显示首页时的处理负担。

  小结

  这次的首页优化,从我们的使用体验上看效果是比较明显的,当然首页的优化还有很大的空间,我们会继续优化。

  如果您对博客园首页优化有什么建议,期待您的分享!

原文地址:http://www.cnblogs.com/cmt/archive/2009/12/07/1618301.html

不过看样子,这样的优化效果应该不会太明显,主要还是由于大部分作者在发布博客的时候,都不使用摘要,所以,对于页面的压缩其实并没有起到什么作用。。【强制截取摘要,或许还是有点作用的吧?否则几十篇上万字的文章贴在首页,怎么着也快不了】

thinksns部分更新记录【自己更改的】

由于自己更改了thinksns的部分核心内容,不得己,先记录下来,如果以后被thinksns官方所更改,那么,我就从其中去掉,否则。。。每次TS一更新,我都要重新更新这些地方

1、关于Ucenter的整合【主要是添加了API等,还有就是用户登录和退出那块,暂时不更换】

2、修改了/thinkphp/api/Model/AttachLWModel.class.php的upload方法【约 line:69】,在foreach($uploadinfo as $u)这个循环中,添加了

PHP代码
  1. $map['key'] = $u['key'];  

主要原因是,这个api只能针对页面中的FILE上传表单处理,而且,都是同名字段的表单,这对我来说有点不方便,比如我的表单里有<input type="ffile" name="a"><input type="file" name="b">,这个API就不能工作,所以添加了这个变量处理: $u['key']这个键值在thinkPHP的upload里是存在的,所以直接添加就可以了。

 

而且这个变量的赋值,相信在以后的thinksns上传附件有多个不同字段的时候,应该是会用得到的。。。

 

 

 

Tags: thinksns, upload

Google 公共 DNS 解析服务器

上周五,传闻新网的DNS服务解析出问题,很多人的网站都不能访问,包括我访问我们公司的网站。
后来,换上了OPENDNS,再后来在群里面知道了一些google的DNS,8.8.8.8,和8.8.4.4,结果今天一看张宴的网页,才发现,原来还有这些多的DNS服务器啊。。

---以下内容来自张宴的博客

Google 推出了公共的 DNS 解析服务器(Google Public DNS),可以用来代替 OpenDNS。Google承诺将严格遵循DNS协议,即不阻挡、不劫持和不过滤用户查询。Google Public DNS服务器IP非常好记,过目难忘:

引用
8.8.8.8        google-public-dns-a.google.com
8.8.4.4        google-public-dns-b.google.com

当然,短IP的DNS服务器还有以下这些:
引用
4.3.2.1
4.2.2.1
4.2.2.2
4.2.2.3
4.2.2.4
4.2.2.5
4.2.2.6

---原文地址:http://blog.s135.com/google_public_dns/

估计好记一点的,也就上面的8.8.8.8,和4.3.2.1了。。
真不错,不过。再怎么样也没用,如果你的客户不知道这些DNS,那商业网站再健康也没用啊。。。

Using PHP As A Shell Scripting Language

这是一篇有点老的文章了,但是因为它带有译文,所以我就转摘一下。
命令行下的PHP,以前也是经常用的,现在用的少了。毕竟命令下行,效果更好,以前都是用来循环处理订单和检测无效信息的。。。
前两天我写了博客说bluehost的命令行不支持yii框架呢。。

以下是原文:

Author:Darrell Brogdon

As most of us already know, PHP is the best language for developing dynamic web pages available today. Not many people are aware that it can be used as a shell scripting language as well. While PHP as a shell script isn't as robust as Bash or Perl it does have definite advantages, especially if you're like me and are more proficient in PHP than you are in Perl.
The requirements for using PHP as a shell language is that you must compile PHP as a CGI binary instead of as an Apache module. There are certain security issues related to this so please refer to the PHP Manual when doing so.
Where the code is concerned, the only difference between a PHP shell script and a regular PHP web page is the existence of the standard shell call at the top of the script:
#!/usr/local/bin/php -q
We're using the '-q' switch so that the HTTP headers are suppressed. Also, you're still required to begin and end the script with the standard PHP tags:
<?php ?>
So let's delve into the standard code sample we all know and love:
#!/usr/local/bin/php -q
<?php

   
print("Hello, world!\n"
);

?>

This, as most of you know already (about a billion times over) will simply output to the screen "Hello, world!".

Passing arguments to the shell script

Commonly with a shell script you need to pass arguments to the script. This is easily done using the built-in '$argv' array as show in the following example:
#!/usr/local/bin/php -q
<?php
    $first_name
= $argv[1
];
   
$last_name = $argv[2
];

    print(
"Hello, $first_name $last_name!  How are you today?\n"
);

?>

So in the above script we're printing out the first two arguments to the script which would be called like this:
[dbrogdon@artemis dbrogdon]$ scriptname.ph Darrell Brogdon
Which would print out:
Hello, Darrell Brogdon!  How are you today?
[dbrogdon@artemis dbrogdon]$


The only major difference with the '$argv' array between a shell script and a web page is that in a shell script, '$argv[0]' is the name of your script. In a web page it is the first argument in your query string.
Making a script more interactive
But how do we wait for user input? How do we create a truly interactive script? Well, PHP has no native functions like the 'read' command in shell but we can always emulate it using the following PHP function:
*Note that this function will only work for Unix.

<?php

function read
() {
   
$fp=fopen("/dev/stdin", "r"
);
   
$input=fgets($fp, 255
);
   
fclose($fp
);

    return
$input
;
}

?>

This function opens a file pointer to Standard In (/dev/stdin on Linux) and reads anything from this pointer up to 255 bytes, newline, or EOF. In this case a newline is most likely to occur. It then closes the file pointer and returns the data.

So now let's modify our previous script to wait for user input using the newly created 'read()' function:
#!/usr/local/bin/php -q
<?php

   
function read
() {
        
$fp=fopen("/dev/stdin", "r"
);
        
$input=fgets($fp, 255
);
        
fclose($fp
);

        return
$input
;
    }

    print(
"What is your first name? "
);
   
$first_name = read
();

    print(
"What is your last name? "
);
   
$last_name = read
();

    print(
"\nHello, $first_name $last_name!  Nice to meet you!\n"
);

?>

You may notice, however, that when you execute this script the last line to be printed is broken into three lines instead of one as it should be. This is because our 'read()' function also takes in the newline character. This is easily fixed by stripping off the newline before we return the data:

<?php

function read
() {
   
$fp=fopen("/dev/stdin", "r"
);
   
$input=fgets($fp, 255
);
   
fclose($fp
);

    return
str_replace("\n", "", $input
);
}

?>
Embedding PHP shell scripts within a regular shell script
Sometimes it might be handy to embed a PHP shell script within a script written in Bash or other shell. This is fairly simple but can get a tad tricky.
First, how to embed the PHP code:
#!/bin/bash
echo This is the Bash section of the code.

/usr/local/bin/php -q << EOF
<?php
   
print("This is the PHP section of the code\n"
);
?>
EOF

Pretty simple huh? Until you add a variable that is. This is the tricky part. Try running the following code segment:
#!/bin/bash
echo This is the Bash section of the code.

/usr/local/bin/php -q << EOF
<?php
    $myVar
= "PHP"
;
    print(
"This is the $myVar section of the code.\n"
);
?>
EOF

You'll get the following error:
<b>Parse error</b>: parse error in <b>-</b> on line <b>2</b><br>
To fix this you have to escape all of the '$' characters in your PHP code:
#!/bin/bashecho This is the Bash section of the code./usr/local/bin/php -q << EOF<?php        \$myVar = "PHP";        print("This is the \$myVar section of the code.\n");?>EOF
So that should get you started on creating your own shell scripts using PHP!


译文:
可能很多人都想过使用PHP编写一些定时发信之类的程序,但是却没有办法定时执行PHP;一次去PHPBuilder的时候,发现了这一篇文章,于是想给大家翻译一下(同时做了一些修改),希望对大家有用。第一次翻译文章,不好请多多见谅。

我们都知道,PHP是一种非常好的动态网页开发语言(速度飞快,开发周期短……)。但是只有很少数的人意识到PHP也可以很好的作为编写Shell脚本的 语言,当PHP作为编写Shell脚本的语言时,他并没有Perl或者Bash那么强大,但是他却有着很好的优势,特别是对于我这种熟悉PHP但是不怎么 熟悉Perl的人。
要使用PHP作为Shell脚本语言,你必须将PHP作为二进制的CGI编译,而不是Apache模式;编译成为二进制CGI模式运行的PHP有一些安全性的问题,关于解决的方法可以参见PHP手册(http://www.php.net)。
一开始你可能会对于编写Shell脚本感到不适应,但是会慢慢好起来的:将PHP作为一般的动态网页编写语言和作为Shell脚本语言的唯一不同就在于一个Shell脚本需要在第一行生命解释本脚本的程序路径:
#!/usr/local/bin/php -q
我们在PHP执行文件后面加入了参数“-1”,这样子PHP就不会输出HTTPHeader(如果仍需要作为Web的动态网页,那么你需要自己使用header函数输出HTTPHeader)。当然,在Shell脚本的里面你还是需要使用PHP的开始和结束标记:
<?php 代码 ?>
现在让我们看一个例子,以便于更好的了解用PHP作为Shell脚本语言的使用:
#!/usr/local/bin/php -q
<?php
print("Hello, world!\n");
?>
上面这个程序会简单的输出“Hello, world!”到显示器上。

一、传递Shell脚本运行参数给PHP:
作为一个Shell脚本,经常会在运行程序时候加入一些参数,PHP作为Shell脚本时有一个内嵌的数组“$argv”,使用“$argv”数组可以很 方便的读取Shell脚本运行时候的参数(“$argv[1]”对应的是第一个参数,“$argv[2]”对应的是第二个参数,依此类推)。比如下面这个 程序:
#!/usr/local/bin/php -q
<?php
$first_name = $argv[1];
$last_name = $argv[2];
printf("Hello, %s %s! How are you today?\n", $first_name, $last_name);
?>
上面的代码在运行的时候需要两个参数,分别是姓和名,比如这样子运行:
[dbrogdon@artemis dbrogdon]$ scriptname.ph Darrell Brogdon
Shell脚本在显示器上面会输出:
Hello, Darrell Brogdon! How are you today?
[dbrogdon@artemis dbrogdon]$
在PHP作为动态网页编写语言的时候也含有“$argv”这个数组,不过和这里有一些不同:当PHP作为Shell脚本语言的时候“$argv[0]”对 应的是脚本的文件名,而当用于动态网页编写的时候,“$argv[1]”对应的是QueryString的第一个参数。

二、编写一个具有交互式的Shell脚本:
如果一个Shell脚本仅仅是自己运行,失去了交互性,那么也没有什么意思了。当PHP用于Shell脚本的编写的时候,怎么读取用户输入的信息呢?很不 幸的是PHP自身没有读取用户输入信息的函数或者方法,但是我们可以效仿其他语言编写一个读取用户输入信息的函数“read”:
<?php
function read() {
$fp = fopen('/dev/stdin', 'r');
$input = fgets($fp, 255);
fclose($fp);
return $input;
}
?>
需要注意的是上面这个函数只能用于Unix系统(其他系统需要作相应的改变)。上面的函数会打开一个文件指针,然后读取一个不超过255字节的行(就是fgets的作用),然后会关闭文件指针,返回读取的信息。
现在我们可以使用函数“read”将我们前面编写的程序1修改一下,使他更加具有“交互性”了:
#!/usr/local/bin/php -q
<?php
function read() {
$fp = fopen('/dev/stdin', 'r');
$input = fgets($fp, 255);
fclose($fp);
return $input;
}
print("What is your first name? ");
$first_name = read();
print("What is your last name? ");
$last_name = read();
print("\nHello, $first_name $last_name! Nice to meet you!\n");
?>
将上面的程序保存下来,运行一下,你可能会看到一件预料之外的事情:最后一行的输入变成了三行!这是因为“read”函数返回的信息还包括了用户每一行的结尾换行符“\n”,保留到了姓和名中,要去掉结尾的换行符,需要把“read”函数修改一下:
<?php
function read() {
$fp = fopen('/dev/stdin', 'r');
$input = fgets($fp, 255);
fclose($fp);
$input = chop($input); // 去除尾部空白
return $input;
}
?>

三、在其他语言编写的Shell脚本中包含PHP编写的Shell脚本:
有时候我们可能需要在其他语言编写的Shell脚本中包含PHP编写的Shell脚本。其实非常简单,下面是一个简单的例子:
#!/bin/bash
echo This is the Bash section of the code.

/usr/local/bin/php -q << EOF
<?php
print("This is the PHP section of the code\n");
?>
EOF
其实就是调用PHP来解析下面的代码,然后输出;那么,再试试下面的代码:
#!/bin/bash
echo This is the Bash section of the code.

/usr/local/bin/php -q << EOF
<?php
$myVar = 'PHP';
print("This is the $myVar section of the code\n");
?>
EOF
可以看出两次的代码唯一的不同就是第二次使用了一个变量“$myVar”,试试运行,PHP竟然给出出错的信息:“Parse error: parse error in - on line 2”!这是因为Bash中的变量也是“$myVar”,而Bash解析器先将变量给替换掉了,要想解决这个问题,你需要在每个PHP的变量前面加上“\” 转义符,那么刚才的代码修改如下:
#!/bin/bash
echo This is the Bash section of the code.

/usr/local/bin/php -q << EOF
<?php
\$myVar = 'PHP';
print("This is the \$myVar section of the code\n");
?>
EOF

好了,现在你可以用PHP编写你自己的Shell脚本了,希望你一切顺利。如果有什么问题,可以去http://www.PHPBuilder.com或者http://www.zPHP.com上面讨论。

---EOF---

仔细看上面的一段, fopen("/dev/stdin"),如果你看过yii的框架,你会发现,现在很多人都在使用php://stdin,其实,这只是PHP把这种封装成了一个协议,更方便而己。。可以参考yiiframework.com