Ubuntu 10.10 Pentax K-5

Thursday, January 11, 2018

耶鲁永续模式

1985年,大卫·史文森先生从雷曼兄弟离职,来到母校耶鲁大学负责运营约20亿美元的耶鲁捐赠基金。当时,他果断抛弃了传统的60%美股40%美债的投资模式,大幅增配了私募股权、对冲基金和资源商品等所谓的另类资产。截止到2015年6月30日,该基金披露的总市值已经超过了250亿美元。




耶鲁捐赠基金配置的资产包含以下8类:绝对收益(对冲基金)、美股、美债、海外股票(包括发达国家和新兴市场)、私募股权、自然资源、房地产和创投基金。细看可以发现,美股和美债的配置极低,近几年均不及整个投资组合的5%。而对冲基金、私募股权和创投基金的配置均较高,2015年分别为20.5%、16.2%和16.3%。此外,耶鲁捐赠基金近几年似乎更为青睐美国以外国家的股票,其配置从9%不断增长至14.7%;同时,基金不断减少组合中房地产的比重,其配置从20.2%降低至14%。
耶鲁模式最为重要的三个特征:其一,高度分散化;其二,偏好股权类具有高收益潜力的资产类别;其三,偏好非传统、低流动性的私有资产,并进行主动管理。

Saturday, December 02, 2017

regex 中文

在javascript中,要判断字符串是中文是很简单。比如:
1
2
3
4
5
6
var str = "php编程";
if (/^[\u4e00-\u9fa5]+$/.test(str)) {
alert("该字符串全部是中文");
else {
alert("该字符串不全部是中文");
}
 PHP正确匹配中文方式, “u" for utf-8 mode
1
2
3
4
5
6
$str = "php编程";
if (preg_match("/^[\x{4e00}-\x{9fa5}]+$/u",$str)) {
print("该字符串全部是中文");
else {
print("该字符串不全部是中文");
}

Tuesday, November 28, 2017

QRCode Generator in Php

phpqrcode http://phpqrcode.sourceforge.net/ can be used to generate qrcode in php.

It supports to generate the code and save to external file or export to browser.

ob_start();
\PHPQRCode\QRcode::png('http://www.chatcai.tk/player-chatroom/register?code='.$model->invitation_code, null, 'L', 4, 2);
$imageString = base64_encode( ob_get_contents() );
ob_end_clean();

Monday, April 14, 2014

MySQL Command

Navicat and Sqlyog are two best administrator tools i have used for mysql.

# [mysql dir]/bin/mysql -h hostname -u root -p

Creating a new user. Login as root. Switch to the MySQL db. Make the user. Update privs.
# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO user (Host,User,Password) VALUES('%','username',PASSWORD('password'));
mysql> flush privileges;

Change a users password from unix shell.

# [mysql dir]/bin/mysqladmin -u username -h hostname.blah.org -p password 'new-password'

Change a users password from MySQL prompt. Login as root. Set the password. Update privs.

# mysql -u root -p
mysql> SET PASSWORD FOR 'user'@'hostname' = PASSWORD('passwordhere');
mysql> flush privileges;

Recover a MySQL root password. Stop the MySQL server process. Start again with no grant tables. Login to MySQL as root. Set new password. Exit MySQL and restart MySQL server.

# /etc/init.d/mysql stop
# mysqld_safe --skip-grant-tables &
# mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("newrootpassword") where User='root';
mysql> flush privileges;
mysql> quit
# /etc/init.d/mysql stop
# /etc/init.d/mysql start

Give user privilages for a db. Login as root. Switch to the MySQL db. Grant privs. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv) VALUES ('%','databasename','username','Y','Y','Y','Y','Y','N');
mysql> flush privileges;

or

mysql> grant all privileges on databasename.* to username@localhost;
mysql> flush privileges;

Wednesday, April 09, 2014

Start a simple web server on Mac (or with Python)

Just navigate to the directory you want to use and enter the following command:P
python -m SimpleHTTPServer 8000P

Wednesday, May 15, 2013

Problems in Django Setups

1. How to run the activate of virtualenv

You need to change to bash first if your default shell is not.
> bash
$ source bin/activate

2. Apache2 Issues
2.1.Where is the log for apache2?
/var/log/apache2/error.log
2.2 how to create virtualhost at apache2
In site-available, create the file, e.g. pms
$ a2ensite pms
It will create a symbolic link in site-enabled folder.

3. Why it can't find all my tables?

If you use sqlite3 database for django backend, you need to put the absolute path of the sqlite3 file rather than relative path.

'NAME': '/tmp/mysite.sqlite3',

4. Database error: attempt to write a readonly database
This happens for sqlite3 database.
For linux, you need to set the write permission for both sqlite3 file and its folder
$ chmod a+x pms
$ cd pms
$ chmod a+x dev.db

5. How to disable signup for django website?
In the settings.py, change ACCOUNT_OPEN_SIGNUP to false;

Check the rest for need email confirmation or not.


ACCOUNT_OPEN_SIGNUP = False
ACCOUNT_USE_OPENID = False
ACCOUNT_REQUIRED_EMAIL = False
ACCOUNT_EMAIL_VERIFICATION = False
ACCOUNT_EMAIL_AUTHENTICATION = False
ACCOUNT_UNIQUE_EMAIL = EMAIL_CONFIRMATION_UNIQUE_EMAIL = False




Monday, April 15, 2013

Sqlite3 dump to sql and read from sql

Objective:
* to dump the sqlite3 database to sql file
* to read the sql file into an empty sqlite3 database

1. >sqlite3 dev.db '.dump'>temp.sql
2. >sqlite3 temp.db
    sqlite> .help
    sqlite> .read temp.sql