# windows下由于文件路径中包含空格符导致的bug解决方案

1. 论测试的重要性

2. 开发目录下的所有目录和文件命名尽可能简单，比如只包含英文字母和数字，以免造成不必要的麻烦。

# Something you should know about the abs function

It is a rule in math that the absolute value of a number must be no less than zero. Is it true in computer languages? Well, most of the case except one. Let me take C language for example.

For a 32-bits C interger, its value ranges from [-2147483648, 2147483647] .So for `x = -2147483648`, what is the result of `abs(x)`? `2147483648`, `-2147483648`, `2147483647`, `0` or something else?

The result depends on your compiler! Please be careful to handle this undefined result in your coding.

Let’s look into the implementation of the `abs` function in C:

So a potential bug may skip into your code like this situration:

But if you really test the above code in your computer, probobly you will find that the computer gives you the expected output. Here is a Demo on ideone.com; You are suggested trying on your machine!

What happens to the correct output occassion is that the compiler actually return a longer integer type like `long long` which is 8 bytes usually. For `long long y = abs(INT_MIN);`, y is equal to `INT_MAX + 1` for sure.

This is as much as the modern compiler can help you reduce your bugs. If you code in this way:

This time bugs are more likely to happen on you. Nigel Jones gives some good solutions to the problem in his article: The absolute truth about abs().

In summary, there are several ways to avoid the abs bug: 1. Always use a longer type to store your abs result, like `long long` for `int`. But what type for `long long`? Therefore the better one is `double`, in the cost of casting time and more CPU cycles. 2. Write your own abs function like this one: safe abs function; 3. Carry out the comparision in the negative space because negetive space is larger than the postive space.

Both solution 2 & 3 require you to use your own abs function.

That’s my report on delving the absolute function in C language. Just as a saying goes: Think twice before you code 🙂

# 网站改版记

1. 新的页面设计。好吧，不是我自己设计的，在html5up上找了个叫overflow的模板改的.布局基本沿用了overflow的设计。根据自己的需求做了些小修改。

# 全兼容性的CSS网站页面灰度化处理方式

html {

-webkit-filter: grayscale(100%);

-o-filter: grayscale(100%);

filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);

_filter:none;

}

# Leo

## April 13, 2014

1. 重写了Flickr模块的代码，利用正则表达式提高了图片URL获取速度和加载速度

2. 新增了welcome.js，在控制台打印欢迎信息，很GEEK的方式，是个异步延迟加载模块

3. 把jQuery、nomalize等常见前端库换成了staticfile.org上的CDN，提高加载速度

4. 压缩了前端大部分代码，加载时间得到提升，消耗流量降至1.5M左右

5. 新增favicon，是个fudan的紫色logo

TODO:

1. 我的旅行轨迹

2. 我的摄影集（按主题分类）

3. 我的作品

# Mac直接安裝Canon DPP系列升级版(适合无驱型Mac用户)

1. 首先到下面的网址下载canon最新的升级程序。没错是升级程序，当然的是mac的。
http://support-cn.canon-asia.com/

2. 解压。然后把解压后的文件（dpp3.XX_updater.app）复制到你的RMBP（例如桌面）；

3. 右键dpp3.XX_updater.app，选择“显示包内容”，然后删除“contentsresourcesInfo.datx”。

4. 然后运行dpp3.XX_updater.app，神奇的情况发生了，可以安装DPP了，而不是提示升级。

# sae版的wordpress中的固定链接设置失败导致404解决大全

1. 修改根目录下的config.yaml文件（建议使用在线代码编辑方式，省去SVN不断提交的麻烦）。修改如下：
``` handle: - rewrite: if (!is_file() && !is_dir() && path ~ "^/(.*)") goto "index.php/\$1" ```

2. 点击保存，此时固定链接即可正常访问。

3. 简单解释下原理：is_file() 和 is_dir()判断当前URL是否是本地文件或者本地路径的名字，比如“www.louqibin.me/home.png” ,这个URL是我本地一张图片的路径，此时判断条件不成立，URL不重写，直接访问。但是比如“http://www.louqibin.me/2014/01/22/sae版的wordpress中的固定链接设置失败导致404解决大全/ ”，这个URL既不是一个文件路径也不是一个目录路径，同时path=”/2014/01/22/sae版的wordpress中的固定链接设置失败导致404解决大全/ ”,这个path满足正则表达式“^/(.*)””，该表达式要求判断path是否是以“/”开头之后跟任何字符，显然例子中的path满足，rewrite被激活，goto即为路径跳转，”index.php/\$1″的意思是重定向到：

www.louqibin.me/index.php/2014/01/22/sae版的wordpress中的固定链接设置失败导致404解决大全/

``` handle: - rewrite: if (!is_file() && !is_dir() && path ~ "^/(blog|dev)/(.*)") goto "\$1/index.php/\$2" ```

\$1代表的是blog或者dev中任意一个字符串

\$2代表的是（.*)中的所有字符。