Ubuntu 10.10 Pentax K-5

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

Friday, March 22, 2013

django Plugins used

1. django-schedule (for event of calendar)
https://github.com/bartekgorny/django-schedule

2. django-photologue (for gallery)
https://code.google.com/p/django-photologue/
https://code.google.com/p/django-photologue/wiki/ReadMe

Install PIL on mac (Snow Leopard) for django


http://proteus-tech.com/blog/cwt/install-pil-in-snow-leopard/
(转)
====


 I download libjpeg latest version (http://www.ijg.org/files/jpegsrc.v7.tar.gz), untar it, and configure it:

$ tar zxvf jpegsrc.v7.tar.gz
$ cd jpeg-7
$ ./configure --enable-shared --enable-static
$ mzake
$ sudo make install
Now, you just installed libjpeg into /usr/local/lib. So, it's time to install PIL. Download the PIL source code from http://effbot.org/downloads/Imaging-1.1.6.tar.gz then untar it:

$ tar zxvf Imaging-1.1.6.tar.gz
$ cd Imaging-1.1.6
This is the trick, you must open setup.py with your prefered text editor then looking for the line JPEG_ROOT = None and then it to JPEG_ROOT = libinclude("/usr/local") then save the file and continue:

$ python setup.py build
If everything fine, you can install PIL to your system library. If the PIL need something that didn't exist, it will tell you on the error message. You may install the missing library via fink or download and compile it by yourself. Then install the PIL as root:

$ sudo python setup.py install --optimize=1

* python selftest.py still shows "lib jpeg not available", but fact is that I can use it already

Friday, March 02, 2012

Django + Pinax (python-based web development framework

Under xiaogang's supervision, i am testing the python-based web development framework.

Django
https://docs.djangoproject.com/en/1.3/

Installed pip.exe (python package management tool)
Installed virtualenv.exe and pinax.exe

Pinax  packs a lot of moduels of Django and with easy deployment (WSGI).
http://pinax.readthedocs.org/en/latest/index.html



To run:
Create a new virtualenv
> virtualenv.exe nanhua-env
> nanhua-env\Scripts\activate

> pip install pinax

>pinax-admin setup_project -b basic nanhua  (create a project/folder)
>cd nanhua

> python manage.py syncdb  (update the database from models.py)
> python manage.py runserver

For the problem at virtualenv, to setup mysql-python:
>easy_install file://c:/users/you/downloads/mysql-python-1.2.3.win32-py2.7.exe (modify to reflect the location of the downloaded installer and its name).

Friday, December 09, 2011

世为棋局我为棋

Thursday, October 06, 2011

genEpak

It gives error at building the solution. 

then i change the position of
#include "platform32/WinEpak.h"

=======

Steps to use genEpak:
1. pack the folders to different .epk files and copy into the game folder
2. some folders are required to be there to contain some files for update
2.1 scripts  server/prefs.cs+config.cs client/prefs.cs data/mission/..ml
2.2 art/../
2.3 shades/procedural/
2.4 core/data/fonts/...


Wednesday, September 21, 2011

欧文15首发11球令弗格森惊叹!2年3冠以曼联为荣

记得欧文做精美的resume四处求职的时候 被多少人嘲笑

认真的人最可怕 话糙理不糙

http://baike.baidu.com/view/5588.htm

===================================================================

曼联官方并没有透露欧文准确的薪资待遇,但英媒体普遍推测欧文的周薪将为5万英镑,相当于在纽卡时的一半,另外曼联将会根据欧文的出场次数以及进球数额外给他一部分可观的奖金。
曼联主帅弗格森在签下欧文之后,第一时间表达了对欧文到来的欢迎,“毫无疑问,迈克尔是一名世界级的球员,他在很多豪门球队效力过,始终都拥有非常让人信服的能力。来到曼联的欧文,就是为了和我们共同战斗,为我们的理想和追求而战斗。”
青春不再的欧文在签约之后非常激动,“此前,我曾尝试和许多俱乐部联系过,但是结果都不是很理想。让我非常意外的是,星期三下午的时候,弗格森打电话邀请我第二天共进早餐。在随后的会面中,他说曼联真心的希望我能来到老特拉福德。我听到他的话之后,甚至连一秒钟都没有犹豫就同意了。”
随后,欧文也表达了对于弗爵爷知遇之恩的感激之情,“弗格森对我的信任,让我倍感荣幸,我将用更多的进球来回报弗格森和所有人对我的支持。 ”
“对我来说,这简直就是一个梦幻般的机会。我希望通过自己的努力,能让所有人重新了解我。我现在已经有些迫不及待想穿上曼联的球衣成为红魔的一员。”久疏战阵的欧文对未来也非常的乐观,“我在老特拉福德有很多的朋友,我相信未来在卡灵顿基地的日子将会非常愉快和幸福。”

Tuesday, September 20, 2011

Before sleep

Dabao and beibei are watching Tom and jerry.

Sunday, September 18, 2011

MySQL UDF Execution - strong password

For mysql 5.5.8 or earlier on Windows, there is such danger about "User-defined-functions" execution.

So help, there is a need to 
1. Ensure the password is strong
2. Delete the "root" account for hostname "%" (i.e. others cannot use "root" account at other host)

A good habit:
1. Create new user privilege only on specific database it belongs to.
2. Have a strong password for the user account

What is a strong password:
Hint:
  • It needs to contain special characters such as @#$%^&
  • It must be at least 8 characters long.
  • It must not have any common words such as 123, password, your birth date, your login name and any words that can be found in the dictionary.
  • a variation of capitalization and small letters

Todo:
1. A password manager is needed to remember for you.

Friday, September 16, 2011

Dublin Core

The Dublin Core set of metadata elements provides a small and fundamental group of text elements through which most resources can be described and cataloged.


简单的都柏林核心原数据集(DCMES) 包括15种元数据元素:
  1. 标题(Title)
  2. 创建者(Creator)
  3. 主题(Subject)
  4. 描述(Description)
  5. 发行者(Publisher)
  6. 资助者(Contributor)
  7. 日期(Date)
  8. 类型(Type)
  9. 格式(Format)
  10. 标识符(Identifier)
  11. 来源(Source)
  12. 语言(Language)
  13. 关系(Relation)
  14. 范围(Coverage)
  15. 权限(Rights)
每一个都柏林核心元素都是可选合可以重复的。

 Now studying how greenstone or Dspace to make an online archive for qipao project.

Friday, August 19, 2011

Wordpress problem

For Worldpress web, need to enable



LoadModule rewrite_module modules/mod_rewrite.so



in httpd.conf



otherwise, the webpage can't show correctly.



http://155.69.146.102/category/networking/research-collaborator



Need to use the model to write to a pseudo html file

Monday, August 15, 2011

Backup innoDB database of mysql

Two main types of databases in mysql: MyISAM and InnoDB.



mysql/data contains all the databases. Each database is shown as a folder.



For MyISAM, just copy the data folder under mysql.

For InnoDB, can't just copy the frm files under data folder. There is a need to copy the "ibdata1" which contains the table info.



Best practice: use the backup function to export the database to mysql, then import.

Tuesday, June 07, 2011

7/6/2011 An end

Today I finish my oral defense.

Chair: Prof. Stephen Tuner
Prof. Thein Yin Leng
Prof. Yow Kin Choong, skype from Canada

Prof. Miao Chun Yan

Though I have used so many years on it, it is great to have a good full stop.
I need to thank a lot people who have ever helped me.

Thank you so much.

Friday, April 22, 2011

At Zoo

 


Weiheng plays at Singapore Zoo.
Posted by Picasa

Friday, April 15, 2011

黄昏 (罗文)

如果我能為你求得一點青春
我會留在心中保存
縱然青絲如霜黃花飄落
紅顏已老只求心中還有一些純真

日落西山天際一片暮色沈沈
我倆就要走進黃昏
回首多少甜蜜幾番哀愁起起落落
始終不悔與你共度此生

山谷中已有點點燈火
暮色就要漸漸昏沈
你和我也然笑淚滿唇
感歎年華竟是一無餘剩

晚風中佈滿我的歌聲
道盡多少舊夢前塵
夜色中只看到彼此眼神
我倆終會消失在那黃昏