Archive for the '技术点滴' Category

Install RMagick on Mac X

报错信息如下:

jinguoli@MacBook:~$sudo gem install rmagick
Password:
Building native extensions. This could take a while…
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install rmagick
checking for Ruby version >= 1.8.2… yes
checking for gcc… yes
checking for Magick-config… yes
checking for ImageMagick version >= 6.3.0… yes
checking for HDRI disabled version […]

Install postgresql psycopg2 for CentOS 5

[root@localhost ~]# axel2 http://initd.org/pub/software/psycopg/psycopg2-2.0.8.tar.gz
[root@localhost ~]# yum install postgresql-devel
[root@localhost ~]# tar xvf psycopg2-2.0.8.tar.gz
[root@localhost ~]# cd psycopg2-2.0.8
[root@localhost psycopg2-2.0.8]# python2.5 setup.py build
[root@localhost psycopg2-2.0.8]# python setup.py install
[root@localhost psycopg2-2.0.8]# python
Python 2.5.2 (r252:60911, Nov  7 2008, 19:14:29)
[GCC 4.1.2 20071124 (Red Hat 4.1.2-42)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import psycopg2
>>>

PIL在mac下报没有安装_imaging的解决办法

报错信息如下:
In [1]: from PIL import Image as PILImage, ImageDraw, ImageFont
—————————————————————————
ImportError                               Traceback (most recent call last)
/Users/jinguoli/Projects/pbi/ in ()
/Users/jinguoli/Projects/pbi/PIL/ImageFont.py in ()
113 # truetype factory function to create font objects.
114
–> 115 class FreeTypeFont:
116     “FreeType font wrapper (requires _imagingft service)”
117
/Users/jinguoli/Projects/pbi/PIL/ImageFont.py in FreeTypeFont()
133         return self.getmask2(text, mode)[0]
134
–> 135     def getmask2(self, text, mode=””, fill=Image.core.fill):
136         size, offset = self.font.getsize(text)
137         im = fill(”L”, size, […]

django chm documentation

django 1.0正式发布了,顺手生成了一个CHM格式的文档,有需要的朋友请下载吧,呵呵。

python中list结构的三个重要方法

对于list,有三个内置函数非常有用:
1. filter(function, sequence):返回一个sequence(序列),包括了给定序列中所有调用function(item)后返回值为True的元素。如果sequence是一个string或者tuple,返回值必定是同一类型,否则总是返回list;
2. map(function, sequence):为每一个元素依次调用function(item)并将返回值组成一个list返回。可以传入多个序列,函数也必须要有对应数量的参数,执行时会依次用各序列上的对应的元素调用函数(如果某些序列比其它的短,就用None来代替)。
3. reduce(function, sequence):返回一个单值,它是这样构造的:首先以序列的前两个元素调用函数,再以返回值和第三个参数调用,依次执行下去。如果序列中只有一个元素,就返回它,如果序列为空,则抛出异常。可以传入第三个参数做为初始值,如果序列为空,就返回初始值。

[MacOS]iTerm下显示和输入中文

新安装完iTerm后怎么也不能输入中文,也不能显示中文,只要是中文全是?号,在同事的指点下终于可以了,现记下步骤备忘:
1.更改iTerm的编码为UTF-8
2.修改.bash_profile,加入
export LC_ALL=’en_US.UTF-8′
,然后source ~/.bash_profile

JavaScript中的Boolean对象最好用原始值

在JavaScript中所有的对象都会被自动转换为true,即如下代码bResult的值是true:

var oFalseObject = new Boolean(false);
var bResult = oFalseObject && true;

JavaScript中的Object类具有的属性和方法

属性:
Constructor:对创建对象的函数的引用(指针)。对于Object类,该指针指向原始的object()函数。
Prototype:对该对象的对象原型的引用。对于所有的类,它默认返回Object对象的一个实例。
方法:
hasOwnProperty(property):判断对象是否有某个特定的属性。必须用字符串指定该属性(例如,o.hasOwnProperty(”name”))。
isPrototypeOf(object):判断该对象是否为另一个对象的原型。
propertyIsEnumerable(property):判断给定的属性是否可以用for…in语句进行枚举。
toString():返回对象的原始字符串表示。对于Object类,ECMA-262没有定义这个值,所以不同的ECMAScriipt实现具有不同的值。
valueOf():返回最适合该对象的原值。对于许多类,该方法返回的值都与toString()的返回值相同。

Mac OS X下php不能连接到数据库的解决办法

其实很简单,打开/etc/php.ini文件,修改
mysql.default_socket = /tmp/mysql.sock
重新启动apache,完事!

修复在ubuntu下netbeans中的Ruby Gems报错问题

今天在ubuntu下安装了netbeans6.0,准备学习一下ruby on rails。在启动netbeans后,其它配置都没有问题,唯独用Tools/Ruby Gems时总是报:
The gem directory is not writable as this user. Either install your gems elsewhere by setting $GEM_HOME to an alternative (and writable) directory before launching NetBeans, or run as root, or manually change the gem directory file permission, or build your own Ruby installation with user permissions. See the http://wiki.netbeans.org/wike/view/RubyGems for more.
我按那个提示的wiki设置了半天也不行,在.profile里设置$GEM_HOME指向~/.rubygems还是不行,但是在命令行里直接GEM_HOME=~/.rubygems […]