Jan 8, 2009

Motorola E2 删除mpkg软件

mpkg软件不像jar软件那样,可以卸载。所以要用下面的方法删除...

a. 编辑 .system/java/CARDREGISTRY, 删除对应的MPKGl软件的"键和值"
b. 删除 .system/QTDownLoad 里面对应的MPKG软件
c. 刷新sd卡

Word 清除保存网页的乱码

有些网站你看的时候正常,但是你把他们复制保存到文本编辑器中却出现很多
乱码。
查看网页源码基本都可以发现如下的代码:
<font style="font-size:0px;color:#FFF">
乱码其实隐藏在白色背景中

解决方案:
把你要copy的内容paste到word文档中,编辑->替换->查找和替换,高级->格式
->字体,从"全部文字"中的"字体颜色"内的下拉菜单,选择 白色
然后 替换为 不填就可以了,再点下 全部替换 就ok了

mount error 13 = Permission denied

ubuntu 8.10
$ sudo smbmount //192.168.1.7//SMG /mnt/smb
mount error 13 = Permission denied

系统使用当前用户名mount的,所以如果该用户名你的192.168.1.7上没权限(或者
根本就不存在),就会出现上面的错误

加个-o username=administrator 就没问题了
$ sudo smbmount //192.168.1.7//SMG /mnt/smb -o username=administrator
$ ls /mnt/smb
CG0_0x10080000.smg CG33_0x000A0000.smg CG7_0x10350000.smg
CG1_0x100800C8.smg CG34_0x001A0000.smg RDL1_0x03FC8000.smg
CG18_0x10330000.smg CG35_0x00AA0000.smg RDL3_0xA0DE0000.smg
CG2_0x10390000.smg CG36_0x010A0000.smg SBFData.dat
CG3_0x10040000.smg CG39_0x01CE0000.smg SBFHeader.hdr
CG31_0x00060000.smg CG41_0x01DE0000.smg
CG32_0x00080000.smg CG43_0x02600000.smg

Jan 7, 2009

Motorola E2 声音配置 (增多/调小)

调大手机通话音量
把下面的内容保存为 ezx_volumetable.cfg,修改相应字段的值
然后看下你手机的/root/autorun.txt,确定下放的手机那块才起作用
比如,我的autorun.txt中是:
# 用户音量配置
if [ -f $MYFAVOR/ezx_volumetable.cfg ]
then
    mount --bind $MYFAVOR/ezx_volumetable.cfg /usr/SYSqtapp/sound/ezx_volumetable.cfg
    kill `pidof soundmanager`
fi

所以把 ezx_volumetable.cfg 放到 mystuff\unKnown\My_FAVOR下

[pcap_loudspk_music]
 12, 12, 12, 12, 12, 12, 15, 15, 15, 15;
[pcap_headset_stero]
 1, 4, 4, 2, 1, -1, -1, 1, 1, -1;
[pcap_loudspk_hfree]
 12, 12, 12, 12, 12, 12, 12, 12, 12, 12;
[pcap_handset_vcall]
 3, 4, 5, 5, 5, 5, 5, 5, 5, 5;
[pcap_headset_mono]
 3, 3, 3, 3, 3, 3, 3, 3, 3, 3;
[pcap_car_kit_vcall]
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
[pcap_3mm5_nomic_st]
 1, 4, 4, 2, 1, -1, -1, 1, 1, -1;
[pcap_3mm5_nomic_cl]
 1, 4, 4, 2, 1, -1, -1, 1, 1, -1;
[pcap_mic_normalrec]
 28, 28, 28, 28, 28, 28, 28, 28, 28, 28;
[pcap_mic_voicecall]
 29, 29, 29, 29, 29, 29, 29, 29, 29, 29;
[pcap_mic_handsfree]
 31, 31, 31, 31, 31, 31, 31, 31, 31, 31;
[pcap_headmic_music]
 28, 28, 28, 28, 28, 28, 28, 28, 28, 28;
[pcap_headmic_vcall]
 19, 19, 19, 19, 19, 19, 19, 19, 19, 19;
[pcap_carkit_mic_in]
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
[pcap_emukit_spk_ou]
 -3, -3, -3, -3, -3, -3, -3, -3, -3, -3;
[pcap_emukit_mic_in]
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
[pcap_emukit_spk_cl]
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
[pcap_emukit_mic_cl]
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
[pcap_fmradi_spk_ou]
 -18, -18, -12, -6, 0, 3, 6, 9, 9, 9;
[pcap_3mm5_st_miccl]
 22, 22, 22, 22, 22, 22, 22, 22, 22, 22;
[end]

注:

[pcap_loudspk_music]  扬声器音量
[pcap_headset_stero]  耳机音量
[pcap_loudspk_hfree] 
通话免提
[pcap_handset_vcall]  听筒音量
[pcap_3mm5_nomic_st] 
3.5通用立体声不带mic
[pcap_3mm5_nomic_cl] 
3.5线输出不带mic
[pcap_mic_normalrec] 
MIC录音
[pcap_mic_voicecall] 
MIC语音拨号
[pcap_mic_handsfree] 
MIC免提
[pcap_emukit_spk_ou] 
收音机扬声器



 

Motorola E2 /root/autorun.txt

/root/autorun.txt 文件内容:

#!/bin/sh


# 用户字体
if [ -f $MYFAVOR/myfont.ttf ]
then
    mount --bind $MYFAVOR/myfont.ttf /usr/language/fonts/AMCSL.TTF
fi

# 用户音量配置
if [ -f $MYFAVOR/ezx_volumetable.cfg ]
then
    mount --bind $MYFAVOR/ezx_volumetable.cfg /usr/SYSqtapp/sound/ezx_volumetable.cfg
    kill `pidof soundmanager`
fi

# 自动开关机
[ -f /ezxlocal/.autopower ] && /bin/autopower

# 脚本接口
for DIRS in $MYFAVOR $UNKNOWN $OTHERS $MYFAVOR/autorun $UNKNOWN/autorun $OTHERS/autorun $MMCA1/autorun
do
    [ ! -f $DIRS/startup.txt ] && continue
    . $DIRS/startup.txt &
done

for DIRS in $MYFAVOR $UNKNOWN $OTHERS $MYFAVOR/autorun $UNKNOWN/autorun $OTHERS/autorun $MMCA1/autorun
do
    [ ! -f $DIRS/startup.sh ] && continue
    chmod +x $DIRS/startup.sh
    $DIRS/startup.sh &
done

for DIRS in $MYFAVOR $UNKNOWN $OTHERS $MYFAVOR/autorun $UNKNOWN/autorun $OTHERS/autorun $MMCA1/autorun
do
    for FILES in $DIRS/S*
    do
        [ ! -f $FILES ] && continue
        chmod +x $FILES
        $FILES &
    done
done

# 多分区自动挂载
if [ -f /ezxlocal/.mmca6 ]
then
    mkdir -p --mode=777 $MMCA6
    mount -t ext3 /dev/mmca6 $MMCA6
    if [ "$?" != "0" ]
    then
        rm -rf $MMCA6
    fi
else
    rm -rf $MMCA6
fi

if [ -f /ezxlocal/.swap ]
then
    swapon /dev/mmca5
fi

# 重新载入SD端主题
/usr/SYSqtapp/systemsetup/sdthemesetup reload

/usr/data_resource/tools/incalladd//incalladd_loop.lin &

Dec 24, 2008

Ubuntu 软件备份与清理

备份快速设置已下载的部分软件包,以便重装系统再次使用,免去重新下载的时间
tar cizvf backup.tar.gz /var/cache/apt/archives --exclude=/var/cache/apt/archives/partial/* --exclude=/var/cache/apt/archives/lock  重装系统,设置好源列表后,导入已备份的软件包即可,操作方法:sudo apt-get update && sudo tar xzvf backup.tar.gz -C /  清理 sudo apt-get clean  rm -rf ~/.thumbnails/fail/gnome-thumbnail-factory/*   

Dec 15, 2008

django 生成 下载 csv 文件

django生成并下载 csv文件:

import csv

download(request, qstr):
    response = HttpResponse(mimetype='text/csv')
    response['Content-Disposition'] = 'attachment;filename=%s.csv' %qstr
    writer = csv.writer(response)
    csvtitle = [u'姓名'.encode('GBK'), u'手机号'.encode('GBK'), u'商品名称'.encode('GBK'), u'售出数量'.encode('GBK'), u'单价(RMB)'.encode('GBK'), u'日期'.encode('GBK')]
    writer.writerow(csvtitle)
    return response

pyExcelerator django 创建可供下载的 excel


pyExcelerator 创建excel的代码大概如下:

from pyExcelerator import *
wb = Workbook()
ws = w.add_sheet('Sheet1')
ws.set_show_headers = 0
header = ['姓名', '手机号码', '商品名称', '售出数量', '单价(RMB)', '日期']
header = [x.decode('utf8') for x in header]
for i in range(len(header)):
    ws.write(0, i, header[i])
wb.save()

在django中提供下载:
from pyExcelerator import *

xlsname = 'test.xls'
w = Workbook()
ws = w.add_sheet('Sheet1')
ws.set_show_headers = 0
header = ['姓名', '手机号码', '商品名称', '售出数量', '单价(RMB)', '日期']
header = [x.decode('utf8') for x in header]
for i in range(len(header)):
    ws.write(0, i, header[i])
w.save(xlsname)

response = HttpResponse(mimetype='application/vnd.ms-excel')
response['Content-Disposition'] = 'attachment;filename=%s' %xlsname
response.write(w.savestream())
return response

注意,Workbook类中是没有savestream方法的,参考http://blog.csdn.net/kernelspirit/archive/2008/10/26/3147888.aspx

修改pyExcelerator代码

Workbook的savestream方法:
def savestream(self):
    import CompoundDoc

    doc = CompoundDoc.XlsDoc()
    return doc.savestream(self.get_biff_data())

CompoundDoc.XlsDoc的savestream方法:
def savestream(self, stream):
    # 1. Align stream on 0x1000 boundary (and therefore on sector boundary)
    padding = '\x00' * (0x1000 - (len(stream) % 0x1000))
    self.book_stream_len = len(stream) + len(padding)

    self.__build_directory()
    self.__build_sat()
    self.__build_header()

    s = ""
    s = s + str(self.header)
    s = s + str(self.packed_MSAT_1st)
    s = s + str(stream)
    s = s + str(padding)
    s = s + str(self.packed_MSAT_2nd)
    s = s + str(self.packed_SAT)
    s = s + str(self.dir_stream)
    return s

Mysql 批量删除数据表

#!/usr/bin/env python
#coding: utf-8
import MySQLdb

def droptables(tablename):
    remainTable = []
    db = MySQLdb.connect(host = 'localhost',
                        user = 'test',
                        passwd = 'test',
                        db = 'test')
    cursor = db.cursor()
    while True:
        cursor.execute('show tables like "%s%%"' % tablename)
        tables = cursor.fetchall()
        if len(tables) == 0:
            break
        for x in tables:
            try:
                cursor.execute('drop table %s' %x)
                db.commit()
            except:
                #print x
                continue
    cursor.close()
    db.close()

if __name__ == '__main__':
    tablename = 'droptest_'
    droptables(tablename)

Dec 4, 2008

Windows下的Apache Php Mysql 环境搭建

使用软件:
Apache、Php、Mysql

配置:
1. Apache:
编辑httpd.conf
DocumentRoot "E:/Program Files/Apache Group/web"

# < 和 字母之间没有空格
< Directory "E:/Program Files/Apache Group/web" >

LoadModule php5_module "E:/Program Files/Apache Group/PHP/php5apache2.dll"

DirectoryIndex index.html index.html.var index.htm index.php

AddDefaultCharset GB2312

AddType application/x-httpd-php .php .phtml .php3 .php4


2. Php:
把Php目录下的 php.ini-dist 重命名为 php.ini,然后拷贝到 %systemRoot% 下
复制Php目录下的 php5ts.dll,libmysql.dll 到 %systemRoot%\system32下

extension_dir = "E:\Program Files\Apache Group\PHP\ext"

extension=php_dba.dll
extension=php_dbase.dll
extension=php_gd2.dll
extension=php_imap.dll
extension=php_mysql.dll
extension=php_mysqli.dll