— AH|Blog

Archive
Info Tech

又有好久没有写blog了

还有4天就是Apple WWDC 2011了,感觉上一次发布iPhone 4就好像昨天一样.根据会前的消息,今年的WWDC会介绍Mac OS X Lion (10.7), iOS 5和iCloud! 这次虽然没有新的硬件产品,但是iOS 5和iCloud还是让我相当兴奋.据说iOS 5会改进推送通知系统和加入语音识别,而iCloud则允许用户上传音乐到Apple的服务器上,然后在其他的iOS设备上收听.Lion也会是另一个重头戏,在这些全新的功能中,我最喜欢的就是Launchpad和Mail 5了.一起期待6月6号的到来吧!

Read More

coolshell看到这套麻省理工的CS公开课,讲的非常系统,从简单的问题逐渐深入,个人认为是非常好的一套教程.视频全部都内嵌字幕,质量非常高.

1: Introduction and Goals; Data Types, Operators, and Variables Go to this video
2: Branching, Conditionals, and Iteration Go to this video
3: Common Code Patterns: Iterative Programs Go to this video
4: Abstraction through Functions; Introduction to Recursion Go to this video
5: Floating Point Numbers, Successive Refinement, Finding Roots Go to this video
6: Bisection Methods, Newton/Raphson, Introduction to Lists Go to this video
7: Lists and Mutability, Dictionaries, Introduction to Efficiency Go to this video
8: Complexity: Log, Linear, Quadratic, Exponential Algorithms Go to this video
9: Binary Search, Bubble and Selection Sorts Go to this video
10: Divide and Conquer Methods, Merge Sort, Exceptions Go to this video
11: Testing and Debugging Go to this video
12: Debugging, Knapsack Problem, Introduction to Dynamic Programming Go to this video
13: Dynamic Programming: Overlapping Subproblems, Optimal Substructure Go to this video
14: Introduction to Object-oriented Programming Go to this video
15: Abstract Data Types, Classes and Methods Go to this video
16: Encapsulation, Inheritance, Shadowing Go to this video
17: Computational Models: Random Walk Simulation Go to this video
18: Presenting Simulation Results, Pylab, Plotting Go to this video
19: Biased Random Walks, Distributions Go to this video
20: Monte Carlo Simulations, Estimating pi Go to this video
21: Validating Simulation Results, Curve Fitting, Linear Regression Go to this video
22: Normal, Uniform, and Exponential Distributions Go to this video
23: Stock Market Simulation Go to this video
24: Course Overview; What Do Computer Scientists Do? Go to this video

Read More

今天研究了一下wordpress在nginx上的rewrite规则,在这里记录一下,也分享给有需要的人

在站点的nginx配置文件中加入如下配置,选择是否要在域名中加入www,两者必须选择一项

# enforce www (exclude certain subdomains)
if ($host !~* ^(www|subdomain))
{
rewrite ^/(.*)$ $scheme://www.$host/$1 permanent;
}

或者
# enforce NO www
if ($host ~* ^www\.(.*))
{
set $host_without_www $1;
rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
}

再加入

# unless the request is for a valid file, send to bootstrap
if (!-e $request_filename)
{
rewrite ^(.+)$ /index.php?q=$1 last;
}

重启nginx即可.在wordpress后台Settings – Permalinks里更改你的设置.

Read More

经过两天的研究,在我的linode上安装了nginx, php-fpm和mysql.在这里记录一下整个过程,也给有需要的人分享.

先安装updates
sudo apt-get update
sudo apt-get upgrade --show-upgraded

然后装aptitude
sudo apt-get install aptitude

安装mysql,按照屏幕提示输入root密码
sudo aptitude install mysql-server

接着是nginx
sudo aptitude install python-software-properties
sudo add-apt-repository ppa:nginx/stable
sudo aptitude update
sudo aptitude install nginx

创建/var/www
mkdir /var/www

php-fpm和一些模块
sudo aptitude install php5-cgi php5-mysql php5-fpm php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl

修改fastcgi_params
sudo vi /etc/nginx/fastcgi_params

加入以下参数
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;

附nginx的范例配置文件

最后,重启nginx和php-fpm
sudo /etc/init.d/nginx restart
sudo /etc/init.d/php5-fpm reload

Read More

上周五linode搞了个活动,早上9点开始前100位购买服务的人都可以获得100美金的礼金,可以用来付月租,因为还有时差的关系,于是我那天一大早就起来坐在电脑前等着抢,结果成功抢到,不过最后听说差不多130分钟后才卖完.

之前我一直推崇mediatemple,主要的原因是他们有很多大公司的客户,只是他们的(dv)的价格真是vps中的劳斯莱斯,实在无法接受,只好参加了大猫的合租(顺便说一句,大猫的合租一直都很稳定,推荐!).用了linode一个星期下来,我对他们的看法大大改观,最让我惊讶和感动的就是他们support的速度,我开了5个ticket,每个都在5分钟内就收到回复,其中有两个还是凌晨1点多开的.这点很值得称赞.linode library的文章非常全面,也浅显易懂,非常适合我这样的新手.

在这里做个小广告,如果你也对linode的服务感兴趣,不妨考虑填我的referral code,
aba73904570c8608451f2cb9557fbba0c721038e
这样我也可以获得一些小的收益,两全其美.

Update 1: 刚才跑了一遍unixbench,把分数贴上来

==============================================================
System Benchmarks Index Values BASELINE RESULT INDEX
Dhrystone 2 using register variables 116700.0 54276450.3 4650.9
Double-Precision Whetstone 55.0 9296.7 1690.3
Execl Throughput 43.0 4583.5 1065.9
File Copy 1024 bufsize 2000 maxblocks 3960.0 284893.6 719.4
File Copy 256 bufsize 500 maxblocks 1655.0 73340.2 443.1
File Copy 4096 bufsize 8000 maxblocks 5800.0 925806.9 1596.2
Pipe Throughput 12440.0 1688667.5 1357.4
Pipe-based Context Switching 4000.0 152433.9 381.1
Process Creation 126.0 7258.8 576.1
Shell Scripts (1 concurrent) 42.4 9079.2 2141.3
Shell Scripts (8 concurrent) 6.0 1190.2 1983.7
System Call Overhead 15000.0 1518083.0 1012.1
========
System Benchmarks Index Score 1152.0

Read More