Monday, March 29, 2010

using CKeditor with django

CKEditor is the new version of famous FCKeditor. In this artical, I note the way we use CKEditor with django-1.1

Assumes that you have python and django-1.1 installed in your system. There're 2 steps that you should follow
  1. Download ckeditor from http://ckeditor.com/
  2. Download django-ck from http://code.google.com/p/django-ck/downloads/list
Then, take a look at wiki page at http://code.google.com/p/django-ck/w/list

All done, extract the ckeditor and copy it into your media folder. This step related to
  • Serve the static file in django http://docs.djangoproject.com/en/dev/howto/static-files/. Remember that you must avoid the url name /media resembling to admin media prefix.
Make some changes on settings.py, create CKEDITOR_PATH as exact URL to the ckeditor.js. Open ck/fields.py, set CKeditor.BasePath = "%s/js/ckeditor/";  Don't forget to add 'ck' to your installed apps in settings.py

That okies, all you need is follow the guide in wiki and make admin works.

Saturday, May 23, 2009

prevent apache, mysql by default starting

After install apache & mysql, they will be started automatically when you login. To prevent it, just do simple code

sudo update-rc.d -f mysql remove

sudo update-rc.d -f apache2 remove

Friday, February 13, 2009

some trick with ls command

i use ls command very frequently, and here are some tricks
1. list only directory:
  • ls -l | grep “^d”
  • find . -type d -maxdepth 1 -mindepth 1
  • ls -d */
2. list only file
  • find . -type f -maxdepth 1
  • find . -type f -maxdepth 1 \( ! -iname ".*" \)

Friday, January 23, 2009

amazing with python (string)

developers = set(['tuan', 'chau', 'hung', 'hoang', 'hoan'])
managers = set(['hoang', 'ngoc'])
* find manager who coding
managers & developers
* find manager who not coding
managers - developers
* find all
managers | developers
happy coding

Friday, January 16, 2009

backup and restore mysql in ubuntu

although i use ubuntu with shell, you can use whatever linux's distribution, command should like the same

backup mysqlmysqldump -u [username] -p [password] [database'name] > [backup'sname]
exp: mysqldump -u root -p 123 mysite > mysite.bak.sql


restore from file backup
mysql
-u [username] -p [password] [database'name] < [backup'sname]

note that the only different is mysql <> mysqldump and >
<> <exp: mysql -u root -p 123 mysite < mysite.bak.sql
click here for more details

happy coding!

Saturday, January 10, 2009

code it better guys!

here is the slide which i made for reviewing code of php's team