2011 年 11 月

浏览模式: 标准 | 列表 | 图文
apache 404转发

apache 404转发

平时我们用apache的404转发,大多数是:
ErrorDocument 404 /404.html
但这样其实也只能做到404的提示信息,会更加人性化一一点,但事实上我们要做到几件事情
比如我的图片不存在,我转发后,会根据图片的URL自动生成一张,这一点行不行呢?
于是乎,利用404转发就势在必行了
ErrorDocument 404 /xxx.php
在PHP里写上
<?php
header("Location:http://xxx.xxx.com".$_SERVER['REQUEST_URI']);
?>
或许有人说,为什么我的不起作用呢?
嗯,在ErrorDocument中,如果用其他域名就不行了
比如说我ErrorDocument 404 http://xxx.xxx.com/xxx.php
在其他域名下的Xxx.php不要说$_SERVER['REQUEST_URI']取不到,连HTTP_REFERER也没有的。
所以,还是在自己当前的项目写一下文件 ,利用header转发一下才是最OK的

Infomation:WebKit Does HTML5 Client-side Database Storage

资料备份,其中有两个链接很重要 :
原资料中的:client-side database storage.已经打不开了,好象是换成这个了:10.1.2.2 A worker for updating a client-side database
但我也说不准,详情还是看这个页面吧:http://www.whatwg.org/specs/web-apps/current-work/multipage/

对了,因为是基于webkit的,所以,FF上是没法用的。更多的还是用于ipad,iphone之类的上面吧。

jQueryMobile的代码里应该是有了

WebKit Does HTML5 Client-side Database Storage

Posted by Brady Eidson on Friday, October 19th, 2007 at 4:04 pm

The current working spec for the HTML5 standard has a lot of exciting features we would eventually like to implement in WebKit. One feature we felt was exciting enough to tackle now even though the spec is still in flux is client-side database storage. So for the last few weeks andersca, xenon, and I have been cooking up an implementation!

The client-side database storage API allows web applications to store structured data locally using a medium many web developers are already familiar with – SQL.

The API is asynchronous and uses callback functions to track the results of a database query.
Compact usage defining a callback function on the fly might look something like this:

var database = openDatabase("Database Name", "Database Version");

database.executeSql("SELECT * FROM test", function(result1) {
// do something with the results
database.executeSql("DROP TABLE test", function(result2) {
// do some more stuff
alert("My second database query finished executing!");
});
});

There will also be a small example of how to use the API in a real site that we’ll try to keep up to date as things evolve.

This initial implementation has some things missing from the spec as well as a few known bugs. But it does the basics and the best way to discover what needs work is to get it out there for people to start using it!

If you find any bugs, would like to suggest features, or have gripes about the spec itself, please drop by #webkit or drop us a line on the WebKit email lists.

Oh, and one more thing…

We’re landing this initial implementation with pretty cool Web Inspector support!
So far you can view the full contents of any table and run arbitrary queries on each database a page is using. We have a lot of ideas for improvements but would also love to hear yours.
DatabaseInspector

光棍节

光棍节

最后一秒

----

还是晚了。。。晚了一秒。

光棍节又可以称为六一儿童节,所以我和老婆去过儿童节了,很开心。Over

你妹啊,19129540惹的祸

你妹啊,19129540惹的祸

受不了,最近很多人加我QQ说要跳舞,我就纳闷了。我没有说过我要跳舞啊?
怎么会有这种事情?然后居然在QQ邮箱里也收到了邮件,说是什么闵行跳舞总群活动了。。
一下子纠结起来,看了一下所谓的贴子,居然还真是留的19129540
我一开始以为是某个人冒充我的名义发的贴子,想着谁那么无聊,但后来一想,不对啊。跳舞总群,难道是QQ群
所以。。。搜索了一下,果然:

776d52d0c333e2cc49640bce36d193fb

哎,真悲催啊

Oauth的变迁

Oauth的变迁

因为新浪的Oauth即将变成2.0,所以找找资料
老王更新了,还画了ascii图,说实话我是对他文中的那个画ascii图的视频有兴趣。。。
老王在博客里是这么介绍的:

OAuth2.0

OAuth1.0虽然在安全性上经过修补已经没有问题了,但还存在其它的缺点,其中最主要的莫过于以下两点:其一,签名逻辑过于复杂,对开发者不够友好;其二,授权流程太过单一,除了Web应用以外,对桌面、移动应用来说不够友好。

为了弥补这些短板,OAuth2.0做了以下改变:

首先,去掉签名,改用SSL(HTTPS)确保安全性,所有的token不再有对应的secret存在,这也直接导致OAuth2.0不兼容老版本。

其次,针对不同的情况使用不同的授权流程,和老版本只有一种授权流程相比,新版本提供了四种授权流程,可依据客观情况选择。

在详细说明授权流程之前,我们需要先了解一下OAuth2.0中的角色:

OAuth1.0定义了三种角色:User、Service Provider、Consumer。而OAuth2.0则定义了四种角色:Resource Owner、Resource Server、Client、Authorization Server:

  • Resource Owner:User
  • Resource Server:Service Provider
  • Client:Consumer
  • Authorization Server:Service Provider

也就是说,OAuth2.0把原本OAuth1.0里的Service Provider角色分拆成Resource Server和Authorization Server两个角色,在授权时交互的是Authorization Server,在请求资源时交互的是Resource Server,当然,有时候他们是合二为一的。

-------
当然,我这里CP的不全,更详细的请看:http://huoding.com/2011/11/08/126
如果不把ascii图CP过来,老王是不是很伤心?

+----------+
| resource |
| owner |
| |
+----------+
^
|
(B)
+----|-----+ Client Identifier +---------------+
| -+----(A)-- & Redirection URI ---->| |
| User- | | Authorization |
| Agent -+----(B)-- User authenticates --->| Server |
| | | |
| -+----(C)-- Authorization Code ---<| |
+-|----|---+ +---------------+
| | ^ v
(A) (C) | |
| | | |
^ v | |
+---------+ | |
| |>---(D)-- Authorization Code ---------' |
| Client | & Redirection URI |
| | |
| |<---(E)----- Access Token -------------------'
+---------+ (w/ Optional Refresh Token)
哈哈,好象失败了。。。
OK,还有一篇介绍 :http://hueniverse.com/2010/05/introducing-oauth-2-0/

6 New Flows

  • User-Agent Flow – for clients running inside a user-agent (typically a web browser).
  • Web Server Flow – for clients that are part of a web server application, accessible via HTTP requests. This is a simpler version of the flow provided by OAuth 1.0.
  • Device Flow – suitable for clients executing on limited devices, but where the end-user has separate access to a browser on another computer or device.
  • Username and Password Flow – used in cases where the user trusts the client to handle its credentials but it is still undesirable for the client to store the user’s username and password. This flow is only suitable when there is a high degree of trust between the user and the client.
  • Client Credentials Flow – the client uses its credentials to obtain an access token. This flow supports what is known as the 2-legged scenario.
  • Assertion Flow – the client presents an assertion such as a SAML assertion to the authorization server in exchange for an access token.

Native application support (applications running on a desktop or mobile device) can be implemented using many of the flows above.

----其实看起来就很纠结,反正先了解一下,refresh_token还得向新浪申请。真纠结

 
下载了zentao pms

下载了zentao pms

一句话:下载了zentao pms,准备用它来做项目管理,同时给自己写文档
嗯,用于neatpic项目。

精读项目,居然没时间写。最近在纠结于JS。。。所幸剩下的功能不多了。需要尽快完成才OK啊

neatpic项目可能会改名了。
不想再单文件处理,单文件有很多事情无法完成,比如,如果真的要按文件的更新时间排序,效率将会非常的低。所以,还是要靠数据库,或者其他方式。

当然,不放弃neatpic,如果我再做修改那就是最后一版了。

新浪微博API更换

新浪微博API更换

纠结,新浪微博的接口更新到V2了
不知道以后的项目中还能不能使用目前的方法了。
不管怎么样,先看起来再说吧。TNND

自11月1日起,新浪微博开放平台将启用新版接口,新版接口采用api.weibo.com的URL,更加高效,规范,也为开发者带来更多功能。


更高效:

1. 微博、评论、用户等接口返回值增加了trim开关,可屏蔽返回值字段。

2. 支持数据过滤与应用隔离,新增feature参数可以按“全部、原创、图片、视频、音乐”过滤输出微博;base_app参数可以设置是否只输出基于当前应用产生的微博内容;


更规范:

1. 使用OAuth2.0授权机制。

2. 重新梳理了URI里资源类的概念,比如:statuses/comments 改为 comments/show;

3. 统一参数、返回值字段,全新的错误返回值格式。

4. 放弃REST风格URI,采用域+版本号+资源类+接口名+返回值格式+参数


更多功能:

新增100多个新接口,其中包含:增强的关系接口、推荐接口、搜索推荐接口 、短链接接口、热门微博接口、帐号接口,陆续还会有更多新接口开放。


其中,OAuth2.0授权更安全,更简单


更安全:

Access Token不再永久有效,约定回调页,接口使用https,对用户和开发者都更加安全。


更简单:

授权流程更简单,签名机制大大简化,不再需要特殊的编码处理和对参数排序。


注:需要说明的是,新版接口只能使用OAuth2.0授权机制,建议大家近期逐渐开始迁移工作,以保证应用的正常使用;但短时间内旧的授权接口依旧可以使用,具体下线日期另行通知。


如您在迁移工作中有任何疑问,请发邮件至weibo_app@vip.sina.com,或者私信@微博api,会有专人为您解答问题。


新版接口WIKI文档:http://t.cn/aF4zI1

OAuth2.0开发指南:http://t.cn/aF4we8

----------------
短时间内可用旧接口,哎,怎么办
这是官网的地址:http://open.weibo.com/wiki/OAuth2/access_token#OAuth2.2Faccess_token

转:Linux操作系统下Screen命令的使用方法

转:Linux操作系统下Screen命令的使用方法

Linux在操作的时候,不想等待当前的操作而关闭终端,那么要么在结尾加&,要么。。。就用这个screen了。
screen这个是最方便的。用法也简单,而且,还可以操作给别人看。所以,了解一下还是有好处的:

首先敲入命令screen,会创建一个跑着shell的单一窗口,在这里面你可以跑你所需要的程序
然后Ctrl+a d退出刚创建的窗口(回到进入screen前的环境)
然后再敲入命令screen创建新的终端窗口,循环往复,你可以建立多个有shell的窗口(这些窗口里都可以跑你自己的应用),于是乎,即使你退出远程管理窗口(进入screen的环境),你的screen窗间的窗口都不会关闭,里面跑得应用自然也不会当掉
1、screen -ls可以看所有的screen sessions
2、screen -r sessionid可以进sessionid指定的特定的screen session

如果screen session不再使用的时候,用screen -r sessionid进去exit退出即可
------------------------------------
参考资料:
Unix/Linux 工具: Screen 命令使用
screen使用
使用screen非常简易.只需在SHELL键入screen,便可打开一个screen session。
而在每个screen session 下,所有命令都以 ctrl+a(C-a) 开始。现在让我来简单介绍基本的命令C-a c -> Create,开启新的 window
C-a n -> Next,切换到下个 window
C-a p -> Previous,前一个 window

C-a C-a -> Other,在两个 window 间切换
C-a w -> Windows,列出已开启的 windows 有那些
C-a 0 -> 切换到第 0 个 window
C-a 1..9 -> 切换到第 1..9 个windowC-a a -> 发出 C-a,在 emacs, ve, bash, tcsh 下可移到行首C-a t -> Time,显示当前时间,和系统的 load
C-a K(大写) -> kill window,强行关闭当前的 windowC-a [ -> 进入 copy mode,在 copy mode 下可以回滚、搜索、
复制就像用使用 vi 一样C-b Backward,PageUp
C-f Forward,PageDown
H(大写) High,将光标移至左上角
L Low,将光标移至左下角
0 移到行首
$ 行末
w forward one word,以字为单位往前移
b backward one word,以字为单位往后移
Space 第一次按为标记区起点,第二次按为终点
Esc 结束 copy mode
C-a ] -> Paste,把刚刚在 copy mode 选定的内容贴上C-a ? -> Help,显示简单说明C-a d -> detach,将目前的 screen session (可能含有多个 windows)
丢 到后台执行 当按了 C-a d 把 screen session detach 掉后,会回到还没进 screen 时的状态,此时在 screen session 里每个 window 内运行的 process (无论是前台/后台)都在继续执行,即使 logout 也不影响。 下次 login 进来时:screen -ls -> 显示所有的 screen sessions
screen -r [keyword] -> 选择一个screen session 恢复对话若 screen -ls 里有 Attached sessions:
screen -d [keyword] -> 强制 detach,以便「接手」过来 实例
说明看了那么多,让我们用一个实际例子来结束我们今天的学习。在我们开启一个screen后,然后使用joe编辑一个文件,之后因为临时需要离开这时就可以运行Ctrl+a d,显示如下:[becks@ec-base becks]$ screen
[detached]这个时候当我们运行ps -e 可以看到pts/2这个我刚刚运行的screen正在运行joe
6264 pts/2 00:00:00 bash
6354 pts/2 00:00:00 joe而当我们回来后想恢复这个session,只需要键入screen -r,而当你有多个session时候,系统将提示你选择一个,如下:
[becks@ec-base becks]$ screen -r
There are several suitable screens on:
6263.pts-1.ec-base (Detached)
6382.pts-1.ec-base (Detached)
Type "screen [-d] -r [pid.]tty.host" to resume one of them.输入该session的pid进行恢复
[becks@becks becks]$ screen -r 6263想退出screen的session,和退出shell一样,只需要键入exit命令,成功退出后将有以下提示
[screen is terminating]

原文来自:http://www.souzz.net/html/server/Linux/33280.html

deleted inode has zero dtime

deleted inode has zero dtime

Q: How do I get rid of lengthy Linux boot delays dealing with "deleted inode has zero dtime" messages?

Booting Linux on my laptop takes a long time. THis is because a message appears saying "deleted inode 6323 has zero dtime. Set dtime? yes". There are also two other deleted inodes with zero dtime — 229543 and 229544. Should I just ignore these messages and be patient, or is something wrong?

A: This shouldn`t happen every time you boot. It is a result of not having cleanly turned the machine off the previous time you used it. To turn the machine off, you must type halt as root. (type man halt or man shutdown for more info.) To reboot, you must hit control-alt-delete or use the reboot command.

svn 切换源

svn 切换源

由于IT对整个公司的IP网段进行了更替,导致svn连接不上。
于是想到了用命令行切换源的IP。
在windows平台下是很方便的,直接用小乌龟relocate就OK了。可是mac下面没有,linux下面也没有这样的gui界面。所以就用命令行了
网上找到资料都是svn relocate,但运行了一下,发现没有这个命令,只有svn switch --relocate
嗯,于是发现命令就是这样的:
svn switch --relocate FROM TO 原来的svn地址 新的SVN地址

--------

郝老师说svn sw就可以了,没有试过,我先备一下