Monthly Archive for September, 2010

让Google Chrome模拟各种手机浏览器

  • 谷歌Android:
    1
    google-chrome --user-agent="Mozilla/5.0 (Linux; U; Android 2.2; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
  • 苹果iPhone:
    1
    google-chrome --user-agent="Mozilla/5.0 (iPad; U; CPU OS 3_2_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B500 Safari/531.21.10"
  • 诺基亚N97:
    1
    google-chrome --user-agent="Mozilla/5.0 (SymbianOS/9.4; Series60/5.0 NokiaN97-1/20.0.019; Profile/MIDP-2.1 Configuration/CLDC-1.1) AppleWebKit/525 (KHTML, like Gecko) BrowserNG/7.1.18124"

Python类例子

1
2
3
4
5
6
7
8
9
10
11
12
class Message:
    def __init__(self, aString):
        self.text = aString
    def printIt(self):
        print self.text

m1 = Message("Hello world")
m2 = Message("So long, it was short but sweet")

note = [m1, m2] # put the objects in a list
for msg in note:
    msg.printIt() # print each message in turn

详细指南

新手指导:jQuery提交表单

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<script type="text/javascript">
  $(document).ready(function(){
    $("#post-button").click(function(){
      postcomment();
    } );
  });
function postcomment() {
  $.ajax({
    type: "POST",
    url: "<?php echo $this->createUrl('game/play/post_comment') ?>",
    data: "content="+$("#comment-content").val(),
                success: function(msg){                    //提交成功后的回调,msg变量是ok.php输出的内容。    
                     alert("数据提交成功");                     //如果有必要,可以把msg变量的值显示到某个DIV元素中    
               }
  });
}

更改Linux启动磁盘检测频率

1
sudo tune2fs -c 50 /dev/hda1

Google Map 雅安市地区卫星照片清晰更新

终于可以在GOOGLE MAP上看清晰看到川农的地图了,可惜不是2001时候那几年的样子了。还是可以怀念一下。We love google map.


View 四川农业大学 in a larger map

MySQL锁表机制分析

为了给高并发情况下的mysql进行更好的优化,有必要了解一下mysql查询更新时的锁表机制。
一、概述
MySQL有三种锁的级别:页级、表级、行级。
MyISAM和MEMORY存储引擎采用的是表级锁(table-level locking);BDB存储引擎采用的是页面锁(page-level
locking),但也支持表级锁;InnoDB存储引擎既支持行级锁(row-level locking),也支持表级锁,但默认情况下是采用行级锁。
Continue reading ‘MySQL锁表机制分析’

哈佛商学院和斯坦福要求学生必看的20部电影

在复杂的商业社会,你想创业,不懂经济,不懂商业,不懂人情世故,不懂法律边沿,你只有勇气,只有梦想,只有天真,只有一场空。

这20部电影可以学到的商业社会必须的经济常识,以及每天都发生着的经济欺诈。 这20部电影都是英语(论坛)国家孩子在学习商业知识方面必须看的影片。其中包括哈佛商学院一直排第一位的Wall Street,还有沃顿商学院排第一位的Trading Place,以及斯坦福要求商科学生必须看的Boiler Room。 Continue reading ‘哈佛商学院和斯坦福要求学生必看的20部电影’

GIMP Vista Button

A friend of mine requested that i make a simple yet cool Vista style button tutorial for gimp, so here is what i came up with.


Continue reading ‘GIMP Vista Button’

HOWTO: configure MySQL’s my.cnf file

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
[mysqld]
user=mysql
bind-address=127.0.0.1
datadir=/var/lib/mysql
pid-file=/var/run/mysqld/mysqld.pid
socket=/var/run/mysql/mysql.sock
port=3306
tmpdir=/tmp
language=/usr/share/mysql/english
skip-external-locking
query_cache_limit=64M
query_cache_size=32M
query_cache_type=1
max_connections=15
max_user_connections=300
interactive_timeout=100
wait_timeout=100
connect_timeout=10
thread_stack=128K
thread_cache_size=128
myisam-recover=BACKUP
key_buffer=64M
join_buffer=1M
max_allowed_packet=32M
table_cache=512M
sort_buffer_size=1M
read_buffer_size=1M
read_rnd_buffer_size=768K
max_connect_errors=10
thread_concurrency=4
myisam_sort_buffer_size=32M
skip-locking
skip-bdb
expire_logs_days=10
max_binlog_size=100M
server-id=1
[mysql.server]
user=mysql
basedir=/usr
[safe_mysqld]
bind-address=127.0.0.1
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
open_files_limit=8192
SAFE_MYSQLD_OPTIONS=”–defaults-file=/etc/my.cnf –log-slow-queries=/var/log/slow-queries.log”
[mysql]
[isamchk]
key_buffer=64M
sort_buffer=64M
read_buffer=16M
write_buffer=16M
[myisamchk]
key_buffer=64M
sort_buffer=64M
read_buffer=16M
write_buffer=16M
[mysqlhotcopy]
interactive-timeout
max_heap_table_size = 64 M
tmp_table_size = 64 M
!includedir /etc/mysql/conf.d/

Continue reading ‘HOWTO: configure MySQL’s my.cnf file’

MySQL性能优化21 – 使用随机函数产生采样

RAND() 函数是 MySQL 提供的产生随机数的函数。没有指定参数时,每次执行会返回 0-1 的浮点数:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
mysql> select rand();

+------------------+
| rand() |
+------------------+
| 0.56110724207117 |
+------------------+

1 row in set (0.02 sec)

mysql> select rand();

+-----------------+
| rand() |
+-----------------+
| 0.3343874880433 |
+-----------------+

1 row in set (0.00 sec)

Continue reading ‘MySQL性能优化21 – 使用随机函数产生采样’