易栈网-膘叔

发文热力图 2025-12-07 ~ 2026-12-06
少 多 近 365 天共 27 篇
浏览模式: 标准 | 列表 | 图文

Minify的简单介绍

上篇从老王的博客里抓了点东西,在文末我提到了minify,然后我又从nio的博客中找到minify的资料,同样贴给大家,具体的英文更新,还是可以从:http://code.google.com/p/minify/来进行获取,下面的是nio的翻译。。。

原文网址:http://nio.infor96.com/archives/862

内容如下:

Minify 是使用 PHP5 开发的用于合并压缩 js/css 文件的应用程序。合并压缩之后的结果可通过 HTTP gzip/deflate 及一些相关头,优化客户端缓存。可参考 Yahoo 的 Rules for High Performance Web Sites。

Minify 的安装使用很简单,下载最新版本,解压,将 min 目录复制到发布目录下,然后访问 http://example.com/min/,在显示的界面中加入你想合并压缩的 js/css 路径,点击 'Update' 之后会为你生成一个 url,如:

http://localhost/min/b=googletesting/js&f=mootools.js,iAction.js,iAjax.js,global.js

接下来你就可以将这个 url 放到你的页面中了。这样可以使请求数减少,传输的字节数也小了很多。而且 Minify 支持服务器端 cache,即将合并压缩的结果 cache 到服务器端文件中,下次访问就不需要再重新做合并压缩的操作了。如果需要组合的文件很多,url 就会变得很长,Minify 支持 group,可以将这些文件分组,这样 url 中只需指定 g=group名字 就可以了。

总之,Minify 很实用 :)


以下是最新更新的内容:

Version 2.1.0 (2008-09-18)

  • "min" default application for quick deployment
  • Minify URI Builder app & bookmarklet for quickly creating minify URIs
  • Relative URIs in CSS file are fixed automatically by default
  • "debug" mode for revealing original line #s in combined files
  • Better IIS support
  • Improved minifier classes:
    • JS: preserves IE conditional comments
    • CSS: smaller output, preserves more hacks and valid CSS syntax, shorter line lengths, other bug fixes
    • HTML: smaller output, shorter line lengths, other bug fixes
  • Default Cache-Control: max-age of 30 minutes
  • Conditional GETs supported even when max-age sent
  • Experimental memcache cache class (default is files)
  • Minify_Cache_File has flock()s (by default)
  • Workaround for Windows mtime reporting bug

2f06a09fb29a6e9e478c0cbd44cc95dc

dfbf186ae496a036a33eb2ce933feabd

Javascript堵塞问题的解决[转]

Javascript堵塞问题的解决[转]

本文来自:Thinking in LAMP - 老王的技术手册,网址是在baidu上面的,文章URL是:http://hi.baidu.com/thinkinginlamp/blog/item/1ebc2e730600891b8601b049.html

原文内容如下:(为了方便,我将图片COPY过来了,而并非是引用,不好意思老王)

所谓“Javascript堵塞问题”,指的是浏览器在下载javascript文件的时候,会堵塞其他下载进程,并且多个javascript文件之 间,只能一个一个下载,不能并行下载。浏览器之所以要这么干,一来是因为javascript里可能会有一些涉及页面渲染的操作,比如 document.write,所以要先把他们加载完,以免影响用户体验,二来是如果并发下载javascript文件,代码执行的先后顺序会错乱,从而 引起逻辑错误。为了规避上述弊端,YSlow建议如果有多个javascript文件,并且这些文件里没有类似document.write等页面渲染的 操作,那么应该尽可能把他们合并成一个文件,并放到页面的尾部。不过很多时候,合并javascript文件是个浩大的工程,不仅破坏了模块化结构,而且 还可能会给代码维护带来不必要的麻烦,今天说说另一个方法,以期避免对现有代码的大规模修改。

先做两个javascript文件,他们是a.php,b.php,之所以用php文件是因为我只会这个,内容如下:

<?php sleep(1); ?>

可以看到a.php和b.php的内容是一样的,其中之所以sleep一秒钟,是为了让演示的效果更明显。

现在让我们来做一个页面(x.htm),看看javascript堵塞问题是如何产生的:

<html>
<head>
<title>DEMO</title>
<script type="text/javascript" src="a.php"></script>
<script type="text/javascript" src="b.php"></script>
</head>
<body>
<img src="http://www.google.com/intl/en_ALL/images/logo.gif">
</body>
</html>

浏览这个页面的时候,通过Pagetest软件,我们可以看到类似下面的结果:

2f06a09fb29a6e9e478c0cbd44cc95dc

我们可以看到,logo.gif图片的下载进程被堵塞了,并且a.php和b.php是分别下载的。

下面让我们再来做一个页面(y.htm),看看是怎么解决这个问题的:
<html>
<head>
<title>DEMO</title>
<script>
var load = function(file) {
var scriptElement = document.createElement("script");
scriptElement.src = file;
document.getElementsByTagName("head")[0].appendChild(scriptElement);
}
load('a.php');
load('b.php');
</script>
</head>
<body>
<img src="http://www.google.com/intl/en_ALL/images/logo.gif">
</body>
</html>
浏览这个页面的时候,通过Pagetest软件,我们可以看到类似下面的结果:
dfbf186ae496a036a33eb2ce933feabd
结论显而易见,logo.gif图片的下载进程并没有被堵塞,并且a.php和b.php是并行下载的。

参考资料:http://stevesouders.com/docs/web20expo-20080425.ppt


膘叔:虽然从我个人而言,我会考虑将js换到其他的域名下面,以防止堵塞(所谓的YAHOO设计网页14条军规中的),然后通过一个程序minify来进行引用。关于minify我会单独介绍。(其实也是COPY别人的文章而来,最近是很懒了。一是要考试,二是单位太忙,只能做到天天更新,但无法原创了)
FormValidator又升级了

FormValidator又升级了

jQuery里面这个插件应该用的是相对比较多的,最起码在提交表单的时候方便了不少,不需要再自己一个一个的根据条件写JS,主要还是为了方便。。。

这次更新的内容有:

这次的更新内容摘要如下:

1、为compareValidator里的datatype属性增加新的类型:date、datetime。
那么到目前为止,插件支持4种常类型:"string"、"number"、"date"、"datetime",默认值为"string"

2、为inputValidator里的属性type增加类型为date、datetime,min和max必须为string类型,会自动转换
"size":表示比较长度 ,默认值
"number":数值型比较
"string":字符型比较
"date":短日期类型
"datetime":长日期类型

3、为initConfig增加属性errorfocus,表示发生错误的时候,第一个出错控件是否获得焦点。默认获得焦点。

4、initConfig增加属性forcevalid属性;formValidator增加forcevalid属性,表示是否一直输入正确为止才允许离开焦点。
initConfig的forcevalid优先等级最高,即全局配置;而formValidator里的forcevalid是局部设置。

5、initConfig增加属性wideword,默认为false,表示是否把一个汉字当做一个长度的参数。
请见demo1最上面的按钮演示。

6、增加ajaxValidator对password控件的支持

7、修正升级中出现的一些bug,现都已修复
在升级的过程中,造成公用一个tip的功能丢失,现已修复。
bug描述:只显示第一个控件的信息,后面的控件正确与否都不理睬。
ajaxValidator的一些状态显示bug

固定发布(下载)页面:
http://www.cnblogs.com/wzmaodong/archive/2008/01/11/1034901.html

有兴趣的朋友可以去订阅作者的博客,以后就可以第一时间知道他的更新。

利用PHP裁剪图片

利用PHP裁剪图片

其实,用PHP裁剪图片的原理是很简单的,无非就是用javascript画出一个方块,计算一下四个角的顶点,然后从原图中按照这四个点的坐标把当中的图切出来。

网上有现成的例子:http://www.coderhome.net/zifa/?p=351,不过里面的JS库用的是mootools的,如果要看,请直接到该网上去看,以后,等有空了,用jQuery的模拟一下,呵呵。
jQuery的插件还是很好开发的

Google Reader改版了?

Google Reader改版了?

不知道是我太迟顿,又或者是我的流览器的关系?我感觉google reader的界面改掉了。原来的界面很朴素啊,现在不对了。风格很强烈的说。

仔细一看,原来右边还有一条提示:New! Things look pretty different around here. Learn more about Reader's fresh new look. Dismiss this message.

哇,原来是这样的,我就想,我就应没有那么傻吧。确实是变了,一下子都没有适应过来。。

得道者多助,失道者寡助

得道者多助,失道者寡助

  天时不如地利,地利不如人和。
  三里之城,七里之郭,环而攻之而不胜。夫环而攻之,必有得天时者矣;然而不胜者,是天时不如地利也。
  城非不高也,池非不深也,兵革非不坚利也,米粟非不多也;委而去之,是地利不如人和也。
  故曰: 域民不以封疆之界,固国不以山溪之险,威天下不以兵革之利。 得道者多助,失道者寡助。寡助之至,亲戚畔⑧之;多助之至,天下顺之。以天下之所顺,攻亲戚之所畔;故君子有不战,战必胜矣。”

Linux下的MSN:galaxium

Linux下的MSN:galaxium

好象是说这款MSN软件不错(当然是linux下的),先加入源,顺便说一下,我的源是通过ubuntu tweak来进行更新的,这款tweak软件很方便,只要在第三方源里加入再刷新就行了,以下是需要加入的源的内容:

deb http://ppa.launchpad.net/galaxium/ubuntu hardy main
deb
-src http://ppa.launchpad.net/galaxium/ubuntu hardy main

然后更新一下:apt-get update
最后运行 安装程序 :apt-get install galaxium

然后就可以运行 了,界面也和msn差不多。。。

就是,连接的速度和成功率不如MSN,唉,没办法。。。没有先天优势啊

叫卖fans123..com和fans123.net

这两个域名在我身边很久了,当初的一些想法最后都没有做。在征得团队成员的同意后,决定出售这两个域名。

有需要的可以在此留言,或者加我QQ或者MSN等 。。。
QQ:19129540
msn:goukixiao@hotmail.com,学学坏人,用全角,呵呵

7199d304a65b80434538d0ca7b70ad6f

i200812491011.rar

Good and Bad PHP Code

Good and Bad PHP Code

by Kevin Yank

The following is republished from the Tech Times #165.

When interviewing a PHP developer candidate for a job at SitePoint, there is one question that I almost always ask, because their answer tells me so much about the kind of programmer they are. Here’s the question: “In your mind, what are the differences between good PHP code and bad PHP code?”

The reason I like this question is because it tests more than just a candidate’s encyclopedic knowledge of PHP’s functions. Zend’s PHP certification does a good job of that (as does the test that Yahoo! issues to applicants for its PHP developer jobs, apparently).

Rather, the answer to this question tells me whether a PHP developer has, for example, experienced the pain of working with poorly-written code inherited from a careless predecessor, and whether he or she will go the extra mile to save the rest of the team from that same pain.

I don’t have a set notion of the perfect answer to the question, but I do know the kinds of things I’m hoping to hear. Just off the top of my head:

Good PHP code should be structured. Long chunks of code can be broken up into functions or methods that achieve sub-tasks with simple code, while non-obvious snippets should be commented to make their meaning plain. As much as possible, you should separate frontend HTML/CSS/JavaScript code from the server-side logic of your applications. PHP’s object oriented programming features give you some especially powerful tools to break up your applications into sensible units.

Good PHP code should be consistent. Whether that means setting rules for the names of variables and functions, adopting standard approaches to recurring tasks like database access and error handling, or simply making sure all of your code is indented the same way, consistency makes your code easier for others to read.

Good PHP code should be portable. PHP has a number of features, such as magic quotes and short tags, that can break fragile code when they are switched on or off. If you know what you’re doing, however, you can write code that works by adapting to its environment.

Good PHP code should be secure. While PHP offers excellent performance and flexibility out of the box, it leaves important issues like security entirely in the hands of the developer. A deep understanding of potential security holes like Cross-Site Scripting (XSS), Cross-Site Request Forgeries (CSRF), code injection vulnerabilities, and character encoding loopholes is essential for a professional PHP developer these days.

Once a candidate has answered this question, I usually have a pretty good idea of whether they’ll be hired or not. Of course, there’s always the possibility that an interviewee simply isn’t able to articulate these types of things, so we also have our candidates sit a PHP developer exam.

Many of the questions in this exam seem straightforward on the surface, but they give candidates plenty of opportunity to show how much they care about the little details.

The following “bad” code is a highly simplified example of the sort of thing we might put in our PHP developer exam. The question might be something like “How would you rewrite this code to make it better?”

<?php
echo("<p>Search results for query: " .
$_GET['query'] . ".</p>");
?>

<?php
echo("<p>Search results for query: " . $_GET['query'] . ".</p>");
?>

The main problem in this code is that the user-submitted value ($_GET['query']) is output directly to the page, resulting in a Cross Site Scripting (XSS) vulnerability. But there are plenty of other ways in which it can be improved.

So, what sort of answer are we hoping for?

Good:

<?php
echo("<p>Search results for query: " .
htmlspecialchars($_GET['query']) . ".</p>");
?>


<?php
echo("<p>Search results for query: " .
htmlspecialchars($_GET['query']) . ".</p>");
?>

This is the least we expect. The XSS vulnerability has been remedied using htmlspecialchars to escape dangerous characters in the submitted value.

Better:

<?php
if (isset($_GET['query']))
{
echo '<p>Search results for query: ',
htmlspecialchars($_GET['query'], ENT_QUOTES), '.</p>';
}
?>


<?php
if (isset($_GET['query'])) {
echo '<p>Search results for query: ',
htmlspecialchars($_GET['query'], ENT_QUOTES), '.</p>';
}
?>

Now this looks like someone we might want to hire:

* The “short” opening PHP tag (<?) has been replaced with the more portable (and XML-friendly) <?php form.
* Before attempting to output the value of $_GET['query'], isset is used to verify that it actually has a value.
* The unnecessary brackets (()) around the value passed to echo have been removed.
* Strings are delimited by single quotes instead of double quotes to avoid the performance hit of PHP searching for variables to interpolate within the strings.
* Rather than using the string concatenation operator (.) to pass a single string to the echo statement, the strings to be output by echo are separated by commas for a tiny performance boost.
* Passing the ENT_QUOTES argument to htmlspecialchars to ensure that single quotes (') are also escaped isn’t strictly necessary in this case, but it’s a good habit to get into.

Somewhat distressingly, the number of PHP developers looking for work that are able to give a fully satisfactory answer to this sort of question—at least here in Melbourne—are few and far between. We spent a good three months interviewing for this latest position before we found someone with whom we were happy!

So, how would you do when asked a question like this one? Are there any factors that make PHP code good or bad that you feel I’ve left out? And what else would you look for in a PHP developer?

JavaScript---Web流程定义工具

JavaScript---Web流程定义工具

用javascript+vml来做工作流,确实是第一次看到,所以我在看到有这个新闻的时候,就觉得特别的吃惊。当年的TRS就是因为有一个activex版的工作流控件的CMS,导致他的价格非常的高,今天能够看到有javascript版的,惊讶是难免的。。。

只是并非所有的机器都支持VML,所以它的适用范围还是有限的,不过,话又说回来,activex也只支持IE,但仍然有那么多人在用。看来,只要是好东西,即使你不跨平台,照样有人用的起劲。

闲话不说了,附上原文网址和他的说明,原文:http://www.cssrain.cn/article.asp?id=1192

开发语言;javascript,html,vml,json,css
功能:
1.环节可用鼠标拖拽
鼠标选中环节后不释放,拖拽鼠标,环节将随鼠标移动,释放鼠标后,环节不再移动。
2.路径的两个端点可以通过鼠标拖拽,改变路径指向的环节
鼠标选中路径的端点后不释放,拖拽鼠标,路径被选中的端点将鼠标移动,在选中的环节释放鼠标后,路径被选中的端点将指向该选中的环节。
3.ctrl+a,全选。
4.按住ctrl,鼠标选中对象,可以多选。
5.delete,删除选中对象。
6.使用鼠标多选
鼠标点击空白处不释放,拖拽鼠标,会出现一个长方形虚框,虚框的范围随着鼠标移动而变化,虚框范围内的对象将被选中。
7.动态添加环节和路径的属性

7199d304a65b80434538d0ca7b70ad6f

由于对这个东西很吃惊,所以,把图片和附件保存到了本地。需要的朋友可以点上面那个网址或者点本文的附件进行下载

(不好意思,刚发现附件有密码,我也不知道是什么密码,有破解软件的朋友只能辛苦一下了,或者去上面的cssrain.cn问站长去吧,我这里仅仅是作个备份)