路由器的一些配置命令

Posted on Wed 30 June 2010 in miscLeave a comment

//enter admin

enable

//begine configure

configure terminal

//interface  fast.. configure

-Interface F.. 0/0(0/1)

--ip address a.b.c.d ma.mb.mc.md

//tunnel configure

-Interface T.. number(数字)

--tunnel source ip

--tunnel dest.. ip

--ip address a.b.c.d ma.mb.mc.md

--ip ospf ...

Continue reading

读取jar文件中的资源

Posted on Wed 30 June 2010 in miscLeave a comment

在前面一篇文中,生成仪表盘时使用了背景图片和指针图片,如果将这些图片(资源)和代码打包到一个jar文件中,读取的时候需要注意一下路径问题。

打包后路径如下图所示:

ict\
--Dashboard.java\
image\
-bg.png\
-pointer.png

如需在Dashboard.java中读取bg.png和pointer.png资源,可以使用如下的代码:

this.getClass().getClassLoader().getResourceAsStream("images/bg.png");
this.getClass().getClassLoader().getResourceAsStream("images/pointer.png");
Continue reading

vlc中文字幕乱码(linux下)

Posted on Wed 30 June 2010 in miscLeave a comment

仅仅为了记录...

版本 :   vlc 1.0.5\ 设置:coding gb 选上\ format 去掉\ utf-8 auto detect 去掉\ 中文字体选择

Continue reading

wchar_t相关的一些

Posted on Wed 30 June 2010 in miscLeave a comment

1.单个宽字符的相关函数

wctomb 将wchar_t字符变成多字节表示

[codesyntax lang="cpp"]

wchar_t ch = L'中';
char mb[MB_CUR_MAX];
int len = wctomb(mb, ch);//成功则返回的值大于0

[/codesyntax]

与wctomb类似有int mbtowc ( wchar_t * pwc, const char * pmb, size_t max );

2.宽字符串的相关函数

wcstombs将一个wchar_t数组转为多字节表示

size_t wcstombs ( char * mbstr, const wchar_t * wcstr, size_t max );

其中max是mbstr的最大长度。\ 与mbstowcs相反的是size_t mbstowcs ( wchar_t * wcstr, const ...

Continue reading

java 生成图片(仪表盘)

Posted on Tue 29 June 2010 in miscLeave a comment

[codesyntax lang="java"]

package ict.dashboard;

import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import java.awt.font.FontRenderContext;
import java.awt.geom.Rectangle2D;

public class Dashboard{

    public static void generateImage(OutputStream os, double percent, int radius){

        //
        try{
            BufferedImage canvas = new BufferedImage(radius + radius, radius ...
Continue reading

路由器配置备份与恢复(转载)

Posted on Mon 28 June 2010 in miscLeave a comment

Introduction

Routers often get upgraded or swapped out for a number of reasons. This document provides the user with some basic steps to migrate the configuration from an existing router to a new router.\

Prerequisites

Requirements

Before you use the information in this document, make sure that you meet these ...

Continue reading

gdb的基本使用(持续更新)

Posted on Fri 23 April 2010 in miscLeave a comment

gcc -g test.c

通过-g参数,可以生成gdb所需要的debug信息。可能会生成一些只有gdb才能使用的debug信息,这对其他的debug程序会造成影响。要控制这些特殊的debug信息,可以通过-gstabs+, -gstabs, -gxcoff和-gvms参数。\

gdb a.out

通过上条命令,这会启动gdb。之后就可以对a.out进行debug了。

命令list(可以简写为字母"l"),列出代码。如果list后面没有参数,就是列出“上次列出代码”的后10行代码。"list -",列出“上次列出代码”的前10行代码. "list linenumber"列出linenumber附近的10行代码. "list start,end"列出行号从start到end的代码。

命令break, 设置断点。break linenumber,在linenumber处设置断点。break functionname,在函数functionname的入口处出设置断点。

命令run(可以简写为r),运行程序。

命令next ...

Continue reading

python中的import

Posted on Wed 21 April 2010 in miscLeave a comment

[codesyntax lang="python" lines="fancy"]

import test1
import pack1.pack2.test1
from test1 import fun, cla, mod_name
from .pack import test1

[/codesyntax]

第一行是python中导入module或者package的普通方式,通过这个语句,在接下来的代码中就可以使用test1 module中所定义的function, class, var等。这类似C语言中的#include,只是在使用module中的的内容时需要加上"test."前缀(相当于c++中的namespace)。

第二行同第一行,其中的pack1和pack2都是package,而test1只能是package或module(这与第三行有区别)。

第三行是从test1 module中导入fun(方法),cla(类),mod_name(子模块)。在使用这些被导入的内容时,可以不用使用前缀(不同于第一行内容)。

第四行是在python2 ...

Continue reading

web.py在cgi下的install

Posted on Mon 19 April 2010 in miscLeave a comment

由于ixwebhosting下无法安装web.py之类的程序,只能将web.py当作工程的一部分。这需要将web.py下的web目录拷贝到工程目录中,以后只需要import web就可以使用web.py了。

web.py可以和Lighttpd,Apache搭配使用。web.py的官网推荐的是使用lighttpd(fastcgi)。这里介绍的是Apache下的CGI方式(这种方式效率不高,不过在ixwebhosting下只能使用这种方式)。

在.htaccess下添加如下代码:

[codesyntax lang="apache"]

Options +ExecCGI
AddHandler cgi-script .py

[/codesyntax]

或者在http.conf(或apache2.conf)下添加如下代码:

[codesyntax lang="apache"]

Alias /foo/static/ /path/to/static
ScriptAlias /foo/ /path/to/code.py

[/codesyntax ...

Continue reading

apache url rewrite

Posted on Mon 19 April 2010 in miscLeave a comment

最近在ixwebhosting上安装了web.py(python下的一个full stack web framework),为了在路径中隐藏.py,需要使用url rewrite。apache中mod_rewrite可以实现这个功能。

在ixwebhosting下,可以修改网页根目录下的.htaccess,具体内容见下。

[codesyntax lang="apache"]

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/icons
RewriteCond %{REQUEST_URI} !^/favicon.ico$
RewriteCond %{REQUEST_URI} !^(/.*)+index.py/
RewriteRule ^(.*)$ index.py/$1 [PT]

[/codesyntax]

以后使用http://www.test.com/就相当于访问index.py,而且/*都由index.py来处理。\

mod_rewrite还有更多的内容,以后逐渐更新

Continue reading