I can’t install google toolbar in archlinux firefox3 for a long time. Today I resolved this issue by searched archlinux forum.
Reference:
http://bugs.archlinux.org/task/13759
Why I can’t install google toolbar?
Google can’t recogonized my firefox version correct, that’s because archlinux mark firefox as “GranParadiso”.
How to change that?
1. Type “about:config” in the url bar of firefox.
2. Search “general.useragent.extra.firefox” key, and change the value from “GranParadiso/3.0.x” to “Firefox/3.0.x”
3. Then go to google toolbar install page and click install.
Linux archlinux, firefox
I read this wonderful example here: http://www.megasolutions.net/python/-args-and—kwargs-78766.aspx
>>> def a(*stuff):
print repr(stuff)
>>> def b(**stuff):
print repr(stuff)
>>> def c(*args, **kwargs):
print 'args', repr(args)
print 'kwargs', repr(kwargs)
>>> a(1,2,3)
(1, 2, 3)
>>> b(hello='world', lingo='python')
{'hello': 'world', 'lingo': 'python'}
>>> c(13,14,thenext=16,afterthat=17)
args (13, 14)
kwargs {'afterthat': 17, 'thenext': 16}
>>> args = [1,2,3,4]
>>> kwargs = {'no-way': 23, 'yet-anotherInvalid.name': 24}
>>> c(*args, **kwargs)
args (1, 2, 3, 4)
kwargs {'no-way': 23, 'yet-anotherInvalid.name': 24}
Here is some simple explaination about *args and **kwargs
Basically ‘args’ is a tuple with all the positional arguments, kwargs is a dictionary with all the named arguments.
Likewise you can pass a tuple to a function like func(*tuple), or a dict like func(**dictionary) or both, where the zuple has to come first.
Python Python
Recently, I’m interesting with android, but they only have online documents now. I can’t access the internet freely when I’m at home, so I want to download the documents and read them offline.
I searched the internet, and found wget can deal with this task very well.
wget --mirror --no-parent --page-requisites --convert-links --no-host-directories http://code.google.com/intl/zh/android/documentation.html
--mirror : Mirror is equivalent to "-r -N -l inf --no-remove-listing" (basically, infinite recursion).
--no-parent : Do not follow links that ascend to the parent directory. Only follow links that are under the given URL.
--page-requisites : Download all page requisites necessary to display the page (images, CSS, javascript, etc.).
--convert-links : Convert links in the pages so that they work locally relative to the OUTPUT_DIR.
--no-host-directories : Don't create host name directories.
Two additional useful options:
-A: Accept list, define which files you need.
-R:Reject list, define which files you don’t need.
I got that from http://www.noah.org/wiki/Offline_mirror_with_wget
Linux
I’m confused by different endline charactors for different systems recently. I organized some information here.
LF(n) — new line
CR(r) — enter
For windows system, it used CRLF(rn) at the end of each line.
For Mac, it used CR(r) at the end of each line.
For Linux, it used LF(n) at the end of each line.
So if you open a windows file in linux or mac system, there is a character ‘^M’ and the end of each line. On the contrary, you will see there is no line break if you open a mac/linux file in windows system.
I used Linux, so I just collect the way to convert the file from CRLF to LF.
1. Used vim
vim somefile
:set ff=unix
:wq
2. used commond tr
tr can delete characters from standard input, writing to standard output. See detail, please man tr
tr -d 'r' < "inputfile" > "outputfile"
3. If you use archlinux, install hd2u package, it includes a tool named dos2unix
With dos2unix, you can convert the file from mac, windows, unix freely.
dos2unix --d2u file
Linux
1. Write a script to sync the tickets from trac to platform(Platform is a internal project.). I don’t need to create the ticket in the trac and copy it to the platform. It’s a waste.
2. Improve google code: getsong project. I want to get the top 500 song list from http://www.9sky.com/ and download the song with getsong script.
Developer
It’s easy to write a email, but it’s not easy to write a good email.
What’s a good email?
As a reader, I want to a email like this:
1. I want to know some context of this email
2. I want to get the key point of the mail immediatly from the email
3. I want to know how you support your point and if I agree with your point
4. I want to know what and when I need to do
5. I want to know which questions I need to answer
How to write a good email?
1. Subject line is key to the email
2. Begin the email by positioning
3. Set the context and explain what you need to
4. Provide the supporting data
5. Towards the end talk about what action you want by whom and by when
6. List questions you want the reader to answer clearly and directly
Other management
I want to share a directory structure comes from my Django project.
Here is basic structure:
/PROJECT/manage.py (under svn)
/PROJECT/__init__.py (under svn)
/PROJECT/urls.py (under svn)
/PROJECT/settings.py (under svn)
/PROJECT/local_settings.py (not under svn)
/PROJECT/env.sh (not under svn)
/PROJECT/run (not under svn)
/PROJECT/apps (under svn)
/PROJECT/docs (under svn)
/PROJECT/static (under svn)
/PROJECT/templates (under svn)
/PROJECT/tests (under svn)
/PROJECT/scripts (under svn)
/PROJECT/initial_data (under svn)
/PROJECT/middlewares (under svn)
/PROJECT/patches (under svn)
/PROJECT/logs (not under svn)
/PROJECT/tmp (not under svn)
Here is the detail for each item.
- manage.py and __init__.py are default, you don’t need to change them.
- urls.py. Actually, we didn’t not write the url patterns in this file, we just include the url patterns from apps.urls in this file
- settings.py and local_settings.py. You must import local_settings.py from settings.py. In the settings.py, you have generic configuration. So you can add this file in the subversion. For in local_settings.py, we will put some particular settings based different environment. You don’t need to worry about breaking other’s environment by checking in the settings.py file any more.
- env.sh. This is a key file in this structure. With my experience, some rookies are always bothered by kinds of module not found issues. In this file you need at least add these two environment variable. They’re PYTHONPATH and DJANGO_SETTINGS_MODULE. I always add a PROJECT_HOME variable, and then I can use this later in my shell scripts. That’s very very useful.
- run. This a shell wrapping of manage.py. That’s because you always need some environment setup before you run the manage.py. Here is a example
PYTHONPATH=$PROJECT_HOME:$PYTHONPATH
DJANGO_SETTINGS_MODULE=settings
python2.5 manage.py $*
- apps directory, it’s the directory hold all of the apps.
- docs, we always put kinds of document about the project here, such as deploy document
- static directory, the static pages are always located here.
- templates, we put template here.
- tests, we plan to put the QA’s test cases there. We also will put some unit test there.
- scripts, some dba scripts located here.
- initial_data: The basic database of the site.
- patches and tmp directory is rarely used.
Python Django, Python
Recent Comments