Jul 04
2008
matthewgong
|
未分类
|
将Tor,tsocks安装好后
编辑配置文件
sudo vim /etc/tsocks.conf
内容为:
server = 127.0.0.1
server_type = 5
server_port = 9050
然后可以使用了,方法有二:
1. 直接tsocks回车,得到一个新的shell
2. 用tsocks wget http://...包裹一个命令
参考:
http://blog.linux.org.tw/~jserv/archives/001486.html
TOR的推荐:/etc/TOR/TOR-tsocks.conf
# This is the configuration for libtsocks (transparent socks) for use
# with ×, which is providing a socks server on port 9050 by default.
#
# See tsocks.conf(5) and ×ify(1) manpages.
server = 127.0.0.1
server_port = 9050
# We specify local as 127.0.0.0 - 127.191.255.255 because the
# Tor MAPADDRESS virtual IP range is the rest of net 127.
local = 127.0.0.0/255.128.0.0
local = 127.128.0.0/255.192.0.0
Jul 01
2008
matthewgong
|
未分类
|
8.04安装后就一直发现有这个问题。搜索后有2种解决方案。
第一种,第二种
我觉得第二种有道理:
解决方法:将/etc/fonts/conf.d/49-sansserif.conf删除即可
sudo rm /etc/fonts/conf.d/49-sansserif.conf
这个其实就是Ubuntu7.10中的/etc/fonts/language-selec×.conf文件在8.04中将其分解成
/etc/fonts/conf.d/下的29-language-selec×-zh.conf、69-language-selec×-zh-cn.conf、99-language-selec×-zh.conf和CJK_aliases。所以,当我们发现系统字体显示不对,可以直接调整69-language-selec×-zh-cn.conf,按照自己喜欢的字体顺序调整好后,重启X后,系统的字体应该就恢复了。
/etc/fonts/conf.d/49-sansserif.conf 为在所有非sans-serif、serif字体中附加sans-serif,删除它后就flash里面的字体配置就和外部系统的字体一致了。如果还有乱码,试试调整下69-language-selec×-zh-cn.conf里面的中文字体顺序。
根据以上说明,觉得第一种有点误打误撞的感觉,test的语义不是去匹配吗?这样改就造成这个匹配无意义了,等于删掉了。
Visual C++ 9.0 2008 Express Edition现在除了IDE常有的缓慢臃肿外,可用性还算蛮好的。向离不开windows与IDE的同学推荐一下。
为了在多个开发平台上无障碍编译程序,CMake的学习与部署看来日益紧迫。CMake的学习曲线相比Autotools来说应该平坦很多。但是协调这么多的编译器也不是很容易的事情,不像Autotools只需要考虑GCC。所以也不是什么容易的事情啦。
现在,终于把wxWidgets的minimal的例子转化为Cmake工程,CMakeLists.txt文件如下:
PROJECT( MINIMAL )
SET(wxWidgets_CONFIGURATION mswu)
SET(wxWidgets_USE_LIBS base core)
FIND_PACKAGE(wxWidgets)
IF(wxWidgets_FOUND)
INCLUDE(${wxWidgets_USE_FILE})
ENDIF(wxWidgets_FOUND)
# Add binary called "minimal" that is built from the source file "minimal.cpp".
# The extension is automatically found.
ADD_EXECUTABLE(minimal WIN32 minimal)
# Link the executable to the wxWidgets library.
TARGET_LINK_LIBRARIES(minimal ${wxWidgets_LIBRARIES})
在VC2008Express下需要注意的是“ADD_EXECUTABLE(minimal WIN32 minimal)”中的WIN32关键字,这样工程链接代码时用的是“/SUBSYSTEM:WINDOWS”而不是默认的“/SUBSYSTEM:CONSOLE”。
CMake默认有findwxWidgets.cmake文件,通过“FIND_PACKAGE(wxWidgets)”指令,支持wxWidgets库的使用。通过学习findwxWidgets.cmake这样的.cmake文件是学习CMake的好方法之一哦。
Apr 04
2008
matthewgong
|
未分类
|
本来就知道gstreamer使用链式法则构建媒体流,但是具体是怎么干的一直没有深究。今天由一个需求带来了我对gstream的初次探索。
这个需求是这样的。我需要将一些飞行仿真的东西从屏幕上录下来。找了很久,终于找到了istanbul这个程序。恩,这个东西很简单、很方便。但是它默认的编码率好像设得很低,录出来动态的视频效果不好。
没关系,istanbul是python写的,可以很方便的看到其内部细节。我发现它是用gstream进行录像的。
final pipeline: istximagesrc name=videosource display-name=:0.0 screen-num=0 use-damage=false ! video/x-raw-rgb,framerate=30/1 ! videorate ! ffmpegcolorspace ! videoscale method=1 ! video/x-raw-yuv,width=1024,height=768,framerate=30/1 ! theoraenc ! oggmux name=mux ! filesink location=/tmp/tmpoNozkR
theoraenc插件使用的是默认的编码方式,太低了,我们升高它!
在/usr/share/python-support/istanbul/istanbul/main/screencast.py的102行,把
'! theoraenc' % (width, height, framerate)改为 '! theoraenc bitrate=1200 quality=63' % (width, height, framerate)
具体的可以查这里
这样最终的pipeline:
istximagesrc name=videosource display-name=:0.0 screen-num=0 use-damage=false ! video/x-raw-rgb,framerate=30/1 ! videorate ! ffmpegcolorspace ! videoscale method=1 ! video/x-raw-yuv,width=1024,height=768,framerate=30/1 ! theoraenc bitrate=1200 quality=63 ! oggmux name=mux ! filesink location=/tmp/tmpoNozkR
当然,这不是最佳的解决方法。应该把配置从gconf系统中读出来才是王道 :)
一般而言,开发一个wxWidgets程序,我们并不需要main函数。因为宏IMPLEMENT_APP(MyApp)已经将main函数封装于内。这个宏完成App的实例化,并调用main函数。将宏展开,它就是这么干的:
//IMPLEMENT_APP(MyApp)
wxAppConsole *wxCreateApp()
{
wxAppConsole::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE,
"your program");
return new MyApp;
}
wxAppInitializer
wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp);
extern MyApp& wxGetApp();
MyApp& wxGetApp() { return *wx_static_cast(MyApp*, wxApp::GetInstance()); }
int main(int argc, char ** argv) { ::wxEntry(argc, argv);}
但是,总有需求无法用这个宏满足的时候。我现在的需求是将FlightGear与wxWidgets联合起来。FlightGear是一个非常强大的飞行模拟程序,其内部视景系统使用OpenSceneGraph,而在与窗口的适配上并且其已经可以使用GLUT、SDL与OSGVIEWER作为后端。我只需要实现一系列的函数,如fgOSMainLoop等,就可以增加一种新的窗口。
要实现的函数是
void fgOSInit(int* argc, char** argv);
void fgOSOpenWindow(int w, int h, int bpp, bool alpha, bool stencil,
bool fullscreen);
void fgOSFullScreen();
void fgOSMainLoop();
void fgOSExit(int code);
void fgSetMouseCursor(int cursor);
int fgGetMouseCursor();
void fgWarpMouse(int x, int y);
int fgGetKeyModifiers();
void fgMakeCurrent();
bool fgOSIsMainCamera(const osg::Camera* camera);
bool fgOSIsMainContext(const osg::GraphicsContext* context);
可以发现,主函数不需要wxWidgets来实现,其需要通过实现fgOSInit来初始化App;通过fgOSOpenWindow来创建窗口;通过fgOSMainLoop来执行主循环。由于fgInit与fgMainLoop是分开实现的,IMPLEMENT_APP宏中的wxEntry函数还需要进一步展开。参考wxWidgets的源代码init.cpp,这两个函数可以这样实现:
- void fgOSInit(int* argc, char** argv)
- {
- // library initialization
- int argc_wx = 1;
- if ( !wxEntryStart(argc_wx, argv) )
- {
- #if wxUSE_LOG
- // flush any log messages explaining why we failed
- delete wxLog::SetActiveTarget(NULL);
- #endif
- exit(-1);
- }
-
- try
- {
- // app initialization
- if ( !wxTheApp->CallOnInit() )
- {
- exit(-1);
- }
- }
- catch(...)
- {
- wxTheApp->OnUnhandledException();
- exit(-1);
- }
- }
-
- void fgOSMainLoop()
- {
- // if wxEntryStart succeeded, we must call wxEntryCleanup even if the code
- // below returns or throws
- wxCleanupOnExit cleanupOnExit;
-
- try
- {
-
- // ensure that OnExit() is called if OnInit() had succeeded
- class CallOnExit
- {
- public:
- ~CallOnExit() { wxTheApp->OnExit(); }
- } callOnExit;
-
- // app execution
- wxTheApp->OnRun();
- }
- catch(...)
- {
- wxTheApp->OnUnhandledException();
- }
- }
void fgOSInit(int* argc, char** argv)
{
// library initialization
int argc_wx = 1;
if ( !wxEntryStart(argc_wx, argv) )
{
#if wxUSE_LOG
// flush any log messages explaining why we failed
delete wxLog::SetActiveTarget(NULL);
#endif
exit(-1);
}
try
{
// app initialization
if ( !wxTheApp->CallOnInit() )
{
exit(-1);
}
}
catch(...)
{
wxTheApp->OnUnhandledException();
exit(-1);
}
}
void fgOSMainLoop()
{
// if wxEntryStart succeeded, we must call wxEntryCleanup even if the code
// below returns or throws
wxCleanupOnExit cleanupOnExit;
try
{
// ensure that OnExit() is called if OnInit() had succeeded
class CallOnExit
{
public:
~CallOnExit() { wxTheApp->OnExit(); }
} callOnExit;
// app execution
wxTheApp->OnRun();
}
catch(...)
{
wxTheApp->OnUnhandledException();
}
}
P.S.
由于WP的编辑器与CoolCode的解释器固执的对'>'与'&'采取不同的态度,代码的显示很糟糕,大家凑合的看算了。
Feb 27
2008
matthewgong
|
未分类
|
一直想找到Ubuntu下通过预先载入技术加速启动的工具,如同Fedora下的readahead。
今天在Solidot上发现了一个——这就是preload软件包。
安装非常简单:sudo apt-get install preload
效果嘛,还没时间体会。具体的可以看这里
Feb 22
2008
matthewgong
|
未分类
|
通过XDMCP协议来登录远程桌面,在Windows下可以使用Xmanager、Cygwin/X等工具,而在linux下,最简单的方法莫过于直接使用X这个命令:
X :1 -query 192.168.0.2
X :2 -indirect 192.168.0.2
X :3 -broadcast
窗口的切换使用Ctrl+Alt+F8、Ctrl+Alt+F9、Ctrl+Alt+F10
我的感受是这个方式是最方便快捷,并且X的反应速度是最好的(与Xmanager等相比)
Yes, it's so easy.
Feb 01
2008
matthewgong
|
未分类
|
虽然早就耳闻Word Press的大名,但是要不是ubuntu.org.cn 的论坛转到了这个平台上,我还没有计划尝试一下。
Word Press给我的第一个印象不太好哦。为了粘贴一段Python的程序,让我费了不少心思。现在来看,主要是与这个编辑器tinymce八字不合,并且我要用的插件CoolCode也与它有点过不去。于是我在"My Profile"中去掉"Use the visual edi× when writing"选项,把它的visual功能关闭了。到此它还不放过我,我用尖括号来调用的CoolCode语法它都不认,非要把它们过滤掉。我现在先用方括号来应付一下先。
这篇文章好像可以进一步驯服tinymcs。
也许tinymcs默认是用来写一点心情小说的?
Jan 29
2008
matthewgong
|
N73
|
学习了一下如何在S60系统上开发简单的Python程序。
这是一个笔记本的小程序,根据smallfish的程序修改而来。
import appuifw
import e32
import os
import time
diary_root="e:/diary/"
title,content=u'', appuifw.Text()
def mbstr(msg):
return unicode(msg.decode('utf8'))
def info(msg):
appuifw.note(mbstr(msg),'info')
def error(msg):
appuifw.note(mbstr(msg),'error')
def conf(msg):
appuifw.note(mbstr(msg),'conf')
def quit():
if appuifw.query(mbstr('确认退出吗?'),'query'):
appuifw.app.set_exit()
def addtext():
t = appuifw.query(mbstr('输入文本行:'),'text')
if t :
content.add(unicode(t+'\n'))
def init():
global diary_root
if os.path.isdir(diary_root):
info("笔记已经初始化!")
else:
os.makedirs(diary_root)
info("笔记初始化成功!")
def home_ui():
global title,content
title = u'';
appuifw.app.title=mbstr('笔记本 v1.1')
content.set(mbstr('Name:\t 笔记本\nVersion:\t 1.1\nOriginal Author:\t smallfish\nAuthor:\t Matt'))
def about_ui():
info('Name: 笔记本\nVersion: 1.1\nOriginal Author: smallfish\nAuthor: Matt')
def view_ui():
global diary_root,content,title
appuifw.app.title=mbstr('View Diary')
try:
diary_list=map(unicode,os.listdir(diary_root))
index=appuifw.selection_list(choices=diary_list,search_field=1)
file=diary_root+diary_list[index]
try:
f=open(file,'r')
result=f.read()
f.close();
data=eval(result)
title=data.get("title","")
appuifw.app.title=title
content.set(data.get("content",""))
except:
info("无法打开文件!\n"+file)
except:
info("错误!请先初始化!")
def save_diary():
global diary_root,title,content
if title!="" and content.get()!="":
result={}
result['title']=title
result['content']=content.get()
try:
file=diary_root+time.strftime("%Y%m%d%H%S%M")+".txt"
f=open(file,'w')
f.write(repr(result))
f.close()
conf("保存成功!\n"+file)
home_ui()
except:
info("保存失败!\n"+file)
else:
info("无法保存数据!")
def write_ui():
global title,content
title_txt=appuifw.query(mbstr('输入笔记标签:'),'text')
if title_txt :
content.set(u'')
appuifw.app.title=title_txt
title=title_txt
app_lock = e32.Ao_lock()
home_ui()
appuifw.app.screen = 'normal'
appuifw.app.body = content
appuifw.app.exit_key_handler = quit
appuifw.app.menu = [(mbstr('添加行'),addtext),(mbstr('写笔记'),write_ui),(mbstr('保存'),save_diary),(mbstr('读笔记'),view_ui),(mbstr('初始化'),init),(mbstr('关于'),about_ui),(mbstr('退出'),quit)]
app_lock.wait()
Dec 12
2007
admin
|
未分类
|
AUTO工具包是我用来对飞行器大迎角特性进行分支分析的基础软件包。最近,我从AUTO2000版本更新到了AUTO07p版本。
这个版本有一下特点:
1. 计算核心程序是fortran编写的,而AUTO2000是使用f2c工具将AUTO97转换为C语言作为核心。可见经过多年实践,纯数学数值计算领域上,fortran还是有生命力的。
核心计算接口程序上提供了C、fortran、fortran90三种接口。当然,经过对源程序的修改,使用C++作为接口也是易如反掌的。
2. 使用PYTHON作为交互式运行接口,将脚本语言的灵活与方便、以及快速开发的优点展现出来。
3. 使用coin3D库新开发了plaut04,这是一个3D显示分支曲面的后处理程序。这个是C++开发的。
4. 核心程序支持OpenMP与MPI两种层次的并行开发技术。
程序默认支持OpenMP,而我原先编写的核心计算部分并不是线程安全的。当我意识到时,已经头疼了很久了。
最后,通过将程序改为线程安全,以及增加互斥锁的方式,终于可以成功运行!
现在,运行AUTO时,我的双核终于可以比翼齐飞了!
