Thursday, March 20, 2008

HOWTO Highlight C++/Java/TeX source code syntax in LaTeX

There is a greate package which supports syntax highlighting for a huge amount of programming languages (Fortran, C, C++, csh, HTML, Java, Matlab, Mathematica, Pascal, Perl, SQL, XML, Delphi, PHP, VBScript, SAS and even Latex itself - and many more). The usage is simple: 
Load the package: \usepackage{listings} 
Set the language: \lstset{language=TeX} 
Open a lstlisting environment: \begin{lstlisting} 
Include all your programming code 
Close the lstlisting environment: \end{lstlisting} 

If this does not seem to work for your language, even if the language is listed above, try upgrading to the lastest MiKTeX version. The listings package is being updated continuously. 

Here's a more advanced example on the source code highlight: 
 \usepackage{color}
 \usepackage{listings}
 \definecolor{Brown}{cmyk}{0,0.81,1,0.60}
 \definecolor{OliveGreen}{cmyk}{0.64,0,0.95,0.40}
 \definecolor{CadetBlue}{cmyk}{0.62,0.57,0.23,0}
 \begin{document}
 
 \lstset{language=R,frame=ltrb,framesep=5pt,basicstyle=\normalsize,
  keywordstyle=\ttfamily\color{OliveGreen},
 identifierstyle=\ttfamily\color{CadetBlue}\bfseries, 
 commentstyle=\color{Brown},
 stringstyle=\ttfamily,
 showstringspaces=ture}

\begin{lstlisting}
...
\end{lstlisting}

...
Read More

HOWTO Editing Gnome/KDE Menus

Introducion

You know the menu that's shown if you start the kde-menu, gnome-menu, xfce-menu or something else. There's no real name for this kind of menu (it's also often called "root-menu"), but the menu is saved in a Freedesktop-Standard. 

Where are the files saved?

The menus are made out of a "Main file" (.menu file). The file is written in XML, and it contains a kind of links to the Applications (.desktop files). 

The Main file detailing system-wide default menu structure might be located in one of the followings directorys: 
/etc/xdg/menus/ 
User-specific menu edits: ~/.config/menus/ 
If you have not found your file yet, search for it: find / -iname *.menu 

System-wide Menu entries (.desktop files) are stored in many places, for example: 
/usr/share/applications/ 
/usr/share/applink/
Gnome applications:
/usr/share/gnome/apps/
KDE applications: 
/usr/kde/3.5/share/applications/
User-specific applications: 
~/.local/share/applications/

Or search for the files: find / -iname *.desktop

...
Read More

Monday, March 17, 2008

HowTo: Mount Bin/Cue files in Linux

* Method 1: Use CDEmu.
cdemu 0 pro.cue
mount -t iso9660 /dev/cdemu/0 /mnt/temp

* Method 2: Convert to ISO.
Convert BIN/CUE to ISO:
bchunk -v acrobat6pro.bin pro.cue pro

* Just mount the ISO by executing as root.
mount -o loop,ro -t iso9660 .iso
mount -o loop pro01.iso /mnt/temp

* Method 3: Use AcetoneISO2.

...
Read More

Saturday, March 15, 2008

【转】JDK6中文乱码完美解决之雅黑版

JDK6在LINUX环境下不支持中文,以下是解决办法。

实验环境:Ubuntu7.04,JDK6
路径说明:1、字体文件路径/usr/share/fonts/yahei/msyh.ttf
2、JAVA_HOME=/usr/lib/jvm/jdk
(请根据你的实际路径修改变命令内容)

解决AWT外的乱码:
1、cd /usr/lib/jvm/jdk/jre/lib/fonts
(进入jre的fonts文件夹)
2、sudo mkdir fallback
(创建文件夹fallback,文件名必须是"fallback",这是设置文件中指定的)
3、cd fallback
(进入fallback文件夹)
4、sudo ln -s /usr/share/fonts/yahei/msyh.ttf
(建立msyh.ttf字体文件的软连接)
5、sudo mkfontscale
(建立fonts.scale文件)
6、sudo mkfontdir
(在fonts.scale的基础上建立fonts.dir文件)

如果使用中不涉及AWT中文显示,问题已解决,针对AWT的乱码问题,必须实施以下步骤:

1、cd /usr/lib/jvm/jdk/jre/lib/fonts
(进入jre的fonts文件夹)
2、sudo cat ./fallback/fonts.dir >> fonts.dir
(把/fallback/fonts.dir的内容添加到fonts.dir文件的结尾,可以手动复制,目的是把雅黑字体的相关内容添加进jre的fonts.dir里)
3、cd ..
(返回上一级目录,即/usr/lib/jvm/jdk/lib)
4、sudo mkdir fontconfigs
(建立fontconfigs文件夹,fontconfigs可以随便命名)
5、sudo mv fontconfig.* ./fontconfigs
(把lib文件夹内的fontconfig开头的文件剪切到fontconfigs文件夹下,因为这些设置文件是应用于不同系统的,按一定顺序查找,如果不把它们移走,不能保证执行我们将要建立的文件fontconfig.properties)
6、sudo gedit fontconfig.properties
(创建并打开文件fontconfig.properties,文件名必须是默认查找顺序列表中的一个,fontconfig.properties就是其中之一)
7、复制以下内容到fontconfig.properties,并保存:


# @(#)linux.fontconfig.Ubuntu.7.04.properties 1.2 07/10/02
#
# Copyright 2007 ganjinghong, Inc. All rights reserved.
#

# Version

version=1

# Component Font Mappings
serif.plain.chinese-cn=-microsoft-microsoft yahei-medium-r-normal--*-%d-*-*-p-*-gb2312.1980-0
serif.bold.chinese-cn=-microsoft-microsoft yahei-medium-r-normal--*-%d-*-*-p-*-gb2312.1980-0
serif.italic.chinese-cn=-microsoft-microsoft yahei-medium-r-normal--*-%d-*-*-p-*-gb2312.1980-0
serif.bolditalic.chinese-cn=-microsoft-microsoft yahei-medium-r-normal--*-%d-*-*-p-*-gb2312.1980-0
sansserif.plain.chinese-cn=-microsoft-microsoft yahei-medium-r-normal--*-%d-*-*-p-*-gb2312.1980-0
sansserif.bold.chinese-cn=-microsoft-microsoft yahei-medium-r-normal--*-%d-*-*-p-*-gb2312.1980-0
sansserif.italic.chinese-cn=-microsoft-microsoft yahei-medium-r-normal--*-%d-*-*-p-*-gb2312.1980-0
sansserif.bolditalic.chinese-cn=-microsoft-microsoft yahei-medium-r-normal--*-%d-*-*-p-*-gb2312.1980-0
monospaced.plain.chinese-cn=-microsoft-microsoft yahei-medium-r-normal--*-%d-*-*-p-*-gb2312.1980-0
monospaced.bold.chinese-cn=-microsoft-microsoft yahei-medium-r-normal--*-%d-*-*-p-*-gb2312.1980-0
monospaced.italic.chinese-cn=-microsoft-microsoft yahei-medium-r-normal--*-%d-*-*-p-*-gb2312.1980-0
monospaced.bolditalic.chinese-cn=-microsoft-microsoft yahei-medium-r-normal--*-%d-*-*-p-*-gb2312.1980-0
dialog.plain.chinese-cn=-microsoft-microsoft yahei-medium-r-normal--*-%d-*-*-p-*-gb2312.1980-0
dialog.bold.chinese-cn=-microsoft-microsoft yahei-medium-r-normal--*-%d-*-*-p-*-gb2312.1980-0
dialog.italic.chinese-cn=-microsoft-microsoft yahei-medium-r-normal--*-%d-*-*-p-*-gb2312.1980-0
dialog.bolditalic.chinese-cn=-microsoft-microsoft yahei-medium-r-normal--*-%d-*-*-p-*-gb2312.1980-0
dialoginput.plain.chinese-cn=-microsoft-microsoft yahei-medium-r-normal--*-%d-*-*-p-*-gb2312.1980-0
dialoginput.bold.chinese-cn=-microsoft-microsoft yahei-medium-r-normal--*-%d-*-*-p-*-gb2312.1980-0
dialoginput.italic.chinese-cn=-microsoft-microsoft yahei-medium-r-normal--*-%d-*-*-p-*-gb2312.1980-0
dialoginput.bolditalic.chinese-cn=-microsoft-microsoft yahei-medium-r-normal--*-%d-*-*-p-*-gb2312.1980-0
dialoginput.bolditalic.chinese-cn=-microsoft-microsoft yahei-medium-r-normal--*-%d-*-*-p-*-gb2312.1980-0

serif.plain.latin-1=-b&h-lucidabright-medium-r-normal--*-%d-*-*-p-*-iso8859-1
serif.bold.latin-1=-b&h-lucidabright-demibold-r-normal--*-%d-*-*-p-*-iso8859-1
serif.italic.latin-1=-b&h-lucidabright-medium-i-normal--*-%d-*-*-p-*-iso8859-1
serif.bolditalic.latin-1=-b&h-lucidabright-demibold-i-normal--*-%d-*-*-p-*-iso8859-1
sansserif.plain.latin-1=-b&h-lucidasans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1
sansserif.bold.latin-1=-b&h-lucidasans-bold-r-normal-sans-*-%d-*-*-p-*-iso8859-1
sansserif.italic.latin-1=-b&h-lucidasans-medium-i-normal-sans-*-%d-*-*-p-*-iso8859-1
sansserif.bolditalic.latin-1=-b&h-lucidasans-bold-i-normal-sans-*-%d-*-*-p-*-iso8859-1
monospaced.plain.latin-1=-b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1
monospaced.bold.latin-1=-b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1
monospaced.italic.latin-1=-b&h-lucidatypewriter-medium-i-normal-sans-*-%d-*-*-m-*-iso8859-1
monospaced.bolditalic.latin-1=-b&h-lucidatypewriter-bold-i-normal-sans-*-%d-*-*-m-*-iso8859-1
dialog.plain.latin-1=-b&h-lucidasans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1
dialog.bold.latin-1=-b&h-lucidasans-bold-r-normal-sans-*-%d-*-*-p-*-iso8859-1
dialog.italic.latin-1=-b&h-lucidasans-medium-i-normal-sans-*-%d-*-*-p-*-iso8859-1
dialog.bolditalic.latin-1=-b&h-lucidasans-bold-i-normal-sans-*-%d-*-*-p-*-iso8859-1
dialoginput.plain.latin-1=-b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1
dialoginput.bold.latin-1=-b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1
dialoginput.italic.latin-1=-b&h-lucidatypewriter-medium-i-normal-sans-*-%d-*-*-m-*-iso8859-1
dialoginput.bolditalic.latin-1=-b&h-lucidatypewriter-bold-i-normal-sans-*-%d-*-*-m-*-iso8859-1


# Search Sequences

sequence.allfonts=latin-1,chinese-cn

# Exclusion Ranges

# Font File Names

8、无需重启,问题已解决。

其他字体设置方法:
把fontconfig.properties文件中的microsoft-microsoft yahei替换为你所用字体的名称。
TIPS:
1、名称获取方法:可以在字体文件同级目录下执行:sudo mkfontscale,然后打开生成的fonts.scale,里面就有相关的名称。
2、必须把你所用中文字体的fonts.scale的相关内容添加到/lib/fonts/fonts.dir

...
Read More

Tuesday, June 19, 2007

blogspot又被盾掉了

已然好长时间不能网页浏览了。写个技术blog都能被盾,贵国也算是地球上的一道独特景观了。

看来做GFW的人果然是搞技术的,相信科学,不怕生孩子没屁眼。

...
Read More

“Skipped Build: Project: ×××”的解决办法

从MSDN上下载MFC的示例代码,无法编译,出现这种信息:

------ Skipped Build: Project: RowList ------

========== Build: 0 succeeded or up-to-date, 0 failed, 1 skipped ==========


解决办法:
Change "Solution Platforms" dropdown list, located at the top of the IDE (it's ghosted out if a project isn't open), from "Itanium" to "Win32."

...
Read More

Sunday, June 10, 2007

Gentoo下man c++标准库的方法

以前用ubuntu的时候装一个libstdc++-doc包就可以man std::iostream等标准库函数,用gentoo后不知道怎样装。现在发现,gentoo下大部分包的文档是用 USE=doc 标记的,于是在 /etc/portage/package.use 中添加
sys-devel/gcc doc
再重新emerge gcc
于是就有文档了。

...
Read More

eva版本号过低无法登陆QQ的解决办法

该死的腾讯总是喜欢封杀第三方QQ,不过他只是靠拒绝低版本号QQ登陆来实现的。
因为第三方QQ更新得比较慢(eva,luma),所以经常会出现登陆不上的情况,这时只好自己动手,丰衣足食了。

以eva为例:
emerge -f eva //下载eva的源码包
将 /usr/portage/distfiles/eva-0.4.1.tar.bz2 包解出来
修改 eva/src/libeva/evadefines.h 文件中的 QQ_CLIENT_VERSION 常量
改为 const int QQ_CLIENT_VERSION = 0x0E1B; 这个版本号可以想办法找到最新的(比如看看珊瑚虫的设置)
然后把修改过的源码重新打包,放回 /usr/portage/distfiles/ 目录
然后
cd /usr/portage/local/layman/gentoo-china/net-im/eva
ebuild eva-0.4.1.ebuild digest
否则emerge时会重新下载,做的修改就白费了。

然后就可以
emerge eva
安装修改过的eva了。装完了以后成功登陆QQ。

...
Read More

Wednesday, June 6, 2007

Opera字体终结解决方案

cd ~/.opera/styles/user/
touch user.css
vi ~/.opera/styles/user/user.css

加入如下内容:
html,body,*{
font-family:”simsun”!important;
}

注意:simsun这个地方的字体可以随便换成喜欢的。

打开opera浏览器,然后view—->style—–>manage modes—->display,然后在my style sheet那一栏选择刚才编辑的user.css文件即可。

...
Read More

Tuesday, June 5, 2007

终于装上显卡驱动了

在gentoo下装ATI的显卡驱动真不容易,前段时间xorg-server更新以后一直和ati-drivers冲突。这两天ati把linux驱动更新到了8.37.6,终于解决了这个冲突,我也顺利装上了驱动,进X终于是宽屏的了,顿时眼前一亮,不用再忍受拉长的桌面了。

安装方法参照gentoo wiki
http://gentoo-wiki.com/Ati

...
Read More
 
/* google analytics */