Posts

Showing posts from 2010

Something I just know about MBP.

Aha, I bought MBP since April, But I don't know much about key pad sign on manual. Now something warn me that control key -> ^ option -> something not same as command key "force quit" menu -> option + command + esc Thank, This knowledge from Mac people of Internet.

Issue about django latest()

If u need to use latest() function when get something from db. First use need to aware of latest( field_name ) of model._meta = 'field_name' in your model to make it clear what your latest out from your db.

Django combine 2 Queryset

Do you know that we can combine 2 Querysets by >> q1 = q1 | q2 # get another queryset so you can use .order_by() or something behind note: don't know about side effect.

Change default python on debian ubuntu

Ubuntu automatically installs python 2.5 and uses it as the default python … I have crashed my system 2 times to solve this .. I wanted to make the default python to version 2.4. This is the way before begaining Thanks to (Luiz Rocha (lsdr) ) http://ubuntuforums.org/showthread.php?t=440358 and http://www.gossamer-threads.com/lists/python/python/685071 First, edit the /usr/share/python/debian_defaults, changing the default version arg to python2.4 2nd, $ sudo mv /usr/bin/python /usr/bin/python25 $ sudo ln -s /usr/bin/python2.4 /usr/bin/python reference( http://tareqalam.wordpress.com/2008/11/28/change-the-default-python-version-in-ubuntu/ )

Cools script

Never seen short code to get some page (python) >>print __import__('urllib').urlopen('http://google.com').read() ----> damn cools (other may have , but i just like this :)) note import re str_var = re.sub(r'\s',' ', str_var) # may be its make u a easy life

Using re and elementtree

import re import xml.etree.ElementTree as ET def extract(stream): r = re.compile('\}(?P \w+)') tree = ET.fromsrting(stream) dfeed = {} dfeed[r.search(tree.tag).group(1)] = None # feed l0_node = dict() for node in tree: # l0 l1_children = node.getchildren() l1_node = dict() if l1_children: # l1 for l1_child in l1_children: l2_children = l1_child.getchildren() l2_node = dict() if l2_children: # l2 for l2_child in l2_children: l3_children = l2_child.getchildren() l3_node = dict() if l3_children: #l3 for l3_child in l3_children: l3_node[r.search(l3_child.tag).group(1)] = l3_child.text l2_node[r.search(l2_child.tag).group(1)] = l3_node else: l2_node

How to create firefox instance more than one instance

for linux >> firefox -ProfileManager to create new profile when you start using >> firefox -no-remote -P yourprofilename

Think I have to do....

- learn about django signal - multiprocessing module - mocking and patching with import mock

Pagination in Django is COOL :)

http://docs.djangoproject.com/en/dev/topics/pagination/ before to to other module , try is before

Solution for Crossite Scripting

http://remysharp.com/2007/10/08/what-is-jsonp/ from kirit, pam . Its use for solve problem about CROSSSITE SCRIPT by don't care where's our js

IRC for django folk

- irc:freenode #django-lfc #django-cms #django-lfs their folks : diefenbach kai, bartTC #selenium #windmill

How to Create Tutorial with Opensource

Ubuntu 10.04 - xvidcap : capture screen vid > file format : avi (uncheck audio) - subtitle editor : create sub(srt) file (need manual change ext. to .srt) > 8-10 sec (for long word) > 3-5 sec (general word) - open shot video editor

Django model

1.when u create 'sample_field' field in model with field attribute 'related_name'. 2.u can backward retrieve data with 'sample_fields' will check later

Tips for django, python

python function argument for example : def func(input1, *input2, **input3) *input2 > tuple **input3 > dict for concrete example: def bucha(name, *things_have,**dudu): print name print things_have print dudu yh get result by call bucha('sirs','duma','dugu',damn='kin') sirs ('duma','dugu') {'damn':'kim'} django models Q > LIKE keyword F > for compare model field with another field in that model -> one to one -> models.OneToOneField() -> many to many -> models.ManyToManyField()

Idea for php, python in one server

P'Pai guide In 1 server we should use... 1.mod_fastcgi for php 2.mod_wsgi for python/django (apache server)

Uninstall Xcode

After google and other mac information web, I get sudo /Developer/Library/uninstall-devtools –mode=all

Matlab's Tip for tonight

Don't know type of variable in Matlab? use function >> classe( ) example >> class( 'thie amrko'); >> ans = >> char >> class(cell(1,1)); >> ans = >> cell

Beginning of my VIM

Change tabs to space in vim Temporarily :set tabstop=4 :set expandtab do command :retab # after set expandtab to activate above command Permanently add above command by vi ~/.vimrc

SVN External

http://beerpla.net/2009/06/20/how-to-properly-set-svn-svnexternals-property-in-svn-command-line/

About Javascript

aha === - jquery have plugin that can pop-up image 'fancy box' or use jquery-ui instead. - selenium and windmill are quite interested - can use command 'typeof' to detect type of object in javascript (done by firebug console) but need to check version of javascript before do something crazy. - mad damn problem may occur!!! about loading order of javascript file in html page, I think last one will override above same keyword. Beware of it

Create patch file

1.diff -crB src dest > patchfile # c-output num, r-recursive, B-ignore blankline 2.patch -p0 -i patchfile

If you want to do something, Do its the best.

อืม วันนี้ ดูรายการ the idol เหมือนว่าเขาจะเสนอประวัติของผู้บริหารอาวุโส ของ โตโยต้า ถึงได้ดูนิดเดียวก่อนจบเหมือนจะได้ ยืนคำว่า "ถ้าจะทำอะไรแล้วต้องทำให้มันดีที่สุด" เริ่มมีพลังขึ้นมาอีกแล้ว ในการเป็นช่างเทคนิคที่เก่งที่สุดในโลก (ทางด้านซอฟทแวร์คอมพิวเตอรหละนะ) :)

Install Full Feature PIL

before install PIL we must... sudo aptitude install build-essential libpng-dev libjpeg-dev libpq-dev python-dev (thank joe)

Tutorial from Svn's Goddess

General todo before merge code - svn ci -m 'message' - svn log --stop-on-copy from working branch for get revision number from to - svn up from trunk - svn merge -r from:to from trunk -> if something conflict , there have some choice to 1.choose one is mine 2.choose others 3.postpone (leave conflict file there) if choose 3 : go to that file to remove unwanted line - then >> svn resolved filename - svn st for check everything allright - svn ci -m 'message' (very thank air)

sftp's stuff

sftp for download multiple files >> mget gaga/* part

Installation tip for django nose

easy_install nose easy_install nosedjango (very thank PPam)

Linux, change fonts for qt4 application

1. alt-f2 for call run app dialog 2. sudo qtconfig-qt4 3. lets change what u want 3. don't forget to save

Django modify request.POST

I found an error about trying to change request.POST['xxxx']. After googling i get an answer... # copy queryset to q for mutatable purpose q = request.POST.copy() q.update({'xxxx': you value}) # then use q instead request.POST :) i'm not sure but it should give a correct result 99% (thk wrong (demigod))

Django's Contenttype

from django.contrib.contenttypes.models import ContentType from mission.objects import Mission -> cmission = ContentType.objects.get(model='mission',app_label='mission') and -> cmission = ContentType.objects.get_for_model(Mission) You will get same object.

Jquery, Ajax and Django

Last working day, I have problem about $('#xxxxxxx').onclick(foo()) that not catch the EVENT with chrome but its work with firefox. So Wrong (demi-god) told me to replace onclick with onchange,gizzzzz its work :) Thank Demi-God Wrong. ps. not quite has a detail about ajax, django,(- -) may be next time

Resize Icon in Ubuntu Linux

Hi there :), If u need to resize desktop icon, U gotta do something like me. press ALT+F2 to bring "Run Application" Dialog up. type "/usr/bin/nautilus" click Edit>Preference and from View tab change Default Zoom Level under Icon View Default catagery. thk , www.addictivetips.com/ubuntu-linux-tips/how-to-resize-desktop-icons-in-ubuntu-linux/

tip's daily

about firebug: if use console.log BUT when u start test without ACTIVATE firebug , Will cause a very damn bug in javascript thank wrong(proteusian) for help

change font of qt4 -application (such as skype)

i have found problem that i can't change font (thai font) in skype on fedora 12 for who havn't qt4-setting in system>>preference please use qtconfig-gq4 in commandline instead then change font to "Loma" very thank to this tread (http://forums.fedoraforum.org/showthread.php?t=223708)

stuff for web dev#2

http://www.saltycrane.com/blog/2009/05/notes-using-pip-and-virtualenv-django/ http://mojodna.net/2009/05/20/an-idiots-guide-to-oauth-10a.html http://hueniverse.com/oauth/ http://oauth.net/documentation/getting-started/ http://bitbucket.org/jespern/django-piston/wiki/Documentation http://www.thedigitalself.com/exposing-rest-services-with-python-and-django http://beautifulisbetterthanugly.com/posts/2009/jul/23/restful-web-service-using-django-piston/ http://blog.carduner.net/2010/01/26/django-piston-and-oauth/ http://hedgehoglab.com/blog/2008/03/03/django-debug-techniques-and-ipython/ THANK FOR ALL MANKINDS

knowledge from joe

requirements.txt # Use as follows: 'pip install -E -r requirements.txt' # Make sure you have mercurial installed because pip gives you useless error # messages when it's not installed and you think that your links are broken. ## General development environment. docutils==0.5 nose ipython django #-e git+git://github.com/robhudson/django-debug-toolbar.git#egg=django-debug-toolbar NoseDjango BeautifulSoup ## Application specific dependencies. PIL pycrypto http://www.satchmoproject.com/snapshots/trml2pdf-1.2.tar.gz PyYAML http://www.reportlab.org/ftp/ReportLab_2_3.tar.gz -e hg+http://bitbucket.org/bkroeze/django-threaded-multihost/#egg=django-threaded-multihost -e hg+http://bitbucket.org/bkroeze/django-caching-app-plugins/#egg=django-caching-app-plugins -e hg+http://bitbucket.org/bkroeze/django-signals-ahoy/#egg=django-signals-ahoy -e hg+http://bitbucket.org/chris1610/satchmo/@v0.9#egg=satchmo http://geopy.googlecode.com/svn/trunk/ ---------------------------------------- afte

the needs for web dev with django

http://www.saltycrane.com/blog/2009/05/notes-using-pip-and-virtualenv-django/ http://www.saltycrane.com/blog/2008/12/card-store-project-3-installing-satchmo-part-2/

to create branch/tag for subclipse(eclipse)

http://www.saltycrane.com/blog/2007/03/how-to-setup-subclipse-project-to/

tips for skype on fedora 12 (64bit)

http://akdwivedi.wordpress.com/2009/05/09/skype-on-64bit-fedora-10/

new tips for linux

for user environment variable -> export name="value" -> export name=value alias name -> alias name="value" for all users -put filename.sh to /etc/profile.d -source filename.sh /// export ZZZZZ=VVVVVV ///

great code formatting with pygment

โอ้ว หลังจากงง อยู่่นานก็หา วิธี ใส่ รูปแบบการแสดง โค้ด จนได้หนะคับเนี่ย โดยใช้งานโมดูล pygment ตัวอย่างเช่น import os print os . VERSION for i in range ( 1000 ): print 'round %d ' % ( i ) โดยการใช้งานคำสั่ง >> pygmentise -f html -o test.html test.py การใช้งานเบื้องต้น ที่แสนจะเบื้องต้น ก็ประมาณนี้หละคับ รู้สึกเหมือนสีของไฮไลท์มันจะไม่มาด้วย อาจจะค้นหาในโอกาสวาระถัดไปหนะคับ

just thinking

อืม มานั่งคิดดูแล้ว บลอคที่ผมเขียนอยู่นี่ ก็ไม่รู้เหมือนกันว่าเขียนเกี่ยวกับเรื่องอะไร เป็นประเภทไหน สรุปแล้วว่ามันอาจจะเป็นพวกที่เตือนความจำของคนเขียนก็ได้ แต่ว่ายังงัย ผม ก็จะลองปรับปรุงการแสดงโค้ดของภาษาต่างๆ แล้วก็อาจจะปรับปรุงเรื่องของหน้าตา หรือ format ของ การเขียนก็เป็นได้

use python 32 bit in mac show leopard :)

# Prefer 32-bit execution for Python 2.6.1 on Snow Leopard $ defaults write com.apple.versioner.python Prefer- 32 -Bit -bool yes for unset >>> -bool no thk Jaharmi (http://www.jaharmi.com/2009/08/29/python_32_bit_execution_on_snow_leopard)

some things So Cool from P.Pai (fedora)

fedora 12 ====== mirror.in.th mirror1.ku.ac.th fastmirror - help find nearest mirror rpmfusion (free/non free) (http://rpmfusion.org) - for listen mp3 fedora has presto by default (update fedora by download small diff pieces of code) (very thk for p.pai)

Hail My New Machine

microsoft messenger has build a slowly speed by take a big cpu usage!!! damn

disable autoplay for window

1. ctrl-r 2. type "gpedit.msc" -> open group policy program 3.spotted to "turn off autoplay" , and play with it :)

Ubuntu set env

https://help.ubuntu.com/community/EnvironmentVariables

Somethings should Notice

The canonical way to begin a python script is ! /usr/bin/env python This will work on any posix system, while /usr/bin/python won’t. (thank TRauMa) On September 26, 2007, James Bennett said : Fredrik, I’m not sure what you mean; there are examples in the code snippets of setting DJANGO_SETTINGS_MODULE , but it’s not “relative to” anything — it’s a dotted Python path to a Django settings module, and I’m hoping that folks who are reading this have at least gotten far enough along to understand that (and to understand what a Django settings module is) :) (thank James Bennett)

Great Stuff of Django

->install django on ubuntu server http://jeffbaier.com/articles/installing-django-on-an-ubuntu-linux-server/ ->many way to setup django environment http://www.b-list.org/weblog/2007/sep/22/standalone-django-scripts/ thanks all ref

installing ubuntu 9.10

my step 1.use ubuntu9.10cd+gpart , do partitioning 2.setup ubuntu9.10 3.setup window 4.use ubuntu9.10cd for booting 4.1.open terminal 4.2.sudo fdisk -l => find linux's partition for example => /dev/sda5 , my win /dev/sda1 4.3.sudo mount /dev/sda5 /mnt 4.4.sudo grub-install --root-directory=/mnt /dev/sda 5.reboot 6.if lux can't see windows 6.1.open terminal 6.2.sudo update-grub :) thanks P'aoh (phd. candidate IT Fac,KMITL) ps. Can't find flash plugin for firefox? use command below ->( thk Locke_99GS) sudo apt-get install ubuntu-restricted-extras

โอ้ feature ของ google search ยอดไปเลย

นั่งหาข่าว tsunami อยู่อยู่ๆก็เจอ feature ตอน search http://www.google.com/search?q=tsunami+warning&hl=en& tbs=rltm :1&tbo=u&ei=Z1uJS-OCNYq-rAfUz8iaCg&sa=X&oi=realtime_result_group_more_results_link&ct=title&resnum=8&ved=0CDcQ5QUwBw ไอ้ตัว bold ถ้าใส่ไปแล้วเป็น google.com ด้วย จะมี options ในการแสดงด้านซ้ายขึ้นมาชื่อว่า latest จะำทำให้แสดงผลการค้นหาเป็นแบบ realtime ฮ่าๆๆ ยอดไปเลยว่ามั้ย (หรือว่าเขารู้กันอยู่แล้วหว่า)

thai in debian

i try to put 'thai stuff' in debian first i 1.add line in /etc/apt/source.list 2." deb ftp://ftp.debianclub.org/debclub unstable main contrib non-free" second i apt-get install ttf-thai-tlwg third i #apt-get install xfonts-thai* #dpkg-reconfigure locales choose thai-> th_utf-8 and last resize font in config desktop theme

Python Script Rename

During serial collecting data from cyberglove , Some accident happens!!! timeout signal from cyberglove coming when chatting with phd candidate from tokai u. Have to change name of file follow order that continue from last time collecting. So import os for fname in os.listdir(os.getcwd()): if fname.endswith('.dat'): os.rename(oldname, newname) i google and get interested information smart author!!!:)

Build DLL Using Command line Visual C++ cl.exe

กำลังแกะ code ของ การ capture ท่ามือ อยู่ดีๆ เจอ struct timeb.h เลย งง หาไปหามา เจอ link สุดเท่ ก็เลยเอามาขึ้นหนะคับ cl -o myoutput.dll myfile1.cpp myfile2.cpp /I D:\required1\include /I D:\required2\include\win32 /link /DLL ref http://codediaries.blogspot.com/2009/07/build-dll-using-command-line-visual-c.html ได้อีกอันมาด้วย Simple Windows C++ DLL Example with Implicit and Explicit Calls