wordpress代码高亮插件Crayon Syntax Highlighter使用教程

如何安装?

在wp后台安装插件处,搜索Crayon Syntax Highlighter插件,你会看到一个满分的该插件,直接安装即可,wp会帮你下载并解压安装的。

如何设置?

在wp后台右边菜单栏 设置->Crayon 中,又该插件的详细设置选项。不懂的选项大家可以多试试。

如何使用?

使用方法与SyntaxHighlighter 类似,同样是在html编辑模式下,使用该类语言的标签,比如你的代码是C++,

[C++]

your code

[/C++](只是个例子)

代码效果:

CMemPoolMgr::CMemPoolMgr(unsigned int poolsize         /* = DEFAULT_POOLSIZE */,   
        unsigned int poolunitsize     /* = DEFAULT_POOLUNITSIZE */,   
        unsigned int blockunitsize    /* = DEFAULT_BLOCKUNITSIZE */)   
    {   
        m_nPoolSize         = poolsize;   
        m_nPoolUnitSize     = poolunitsize;   
        m_nBlockUnitSize    = blockunitsize;   

        m_nTotalMemPool     = 0;   
        m_nUsingMemPool     = 0;   

        m_TimeTick          = GetTickCount();   

#ifdef _DEBUG   
        m_nCode             = 0;   
#endif   
    }

相信这种方式还是比较简单吧。

如果你还嫌麻烦,那么请使用可视化模式下的工具吧,安装完Crayon后,可视化编辑第一行菜单最后一个是该插件的选项,你可以点击它,直接拷贝你想高亮的代码进入就可以了,效果如下图所示,可视化编辑,更方便了。

Crayon

参考

http://www.cppfans.org/1224.html

使用Maven构建Web项目

参考 http://blog.csdn.net/yuguiyang1990/article/details/8796410

1.新建Maven项目

1.1 File -> New -> Other

1365863541_5385

1.2 选择Maven Project ,单击Next

1365863553_1351

1.3 保持默认即可,单击Next

1365863566_6467

1.4 选择Archetype为 web app,单击Next

1365863577_7171

1.5 输入一些必要信息,单击Finish

1365863587_8509

1.6 项目结构如下图:

1365863599_9491

或者如下图

在Mac下面的Eclipse Kepler中目录的位置有所变化

screenshot

2.配置项目(某些修改实际工作中用不到,以下仅供参考

现在开始修改一些配置

2.1 在项目上右键单击,添加Source Folder

Maven的项目有一些约定:src/main/java , src/main/resources , src/test/java , src/test/resources .那么,添加这些文件夹:(注意,创建文件夹有可能失败,比如Kepler 上面,此时,到目录下面直接创建文件夹然后刷新Eclipse项目就可以了

1365863613_2412

输入Source Folder 的名字

1365863628_6400

创建完之后的目录结构:

1365863640_6524

2.2 修改Build Path 配置

在项目上,右键单击,选择 Build Path ->Configure Build Path

1365863656_2376

选择 Source标签,会显示4个Source Folder ,修改他们的 OutPut folder :

1365863670_3566

双击每个文件夹的Output folder,选择路径

src/main/java,src/main/resources,选择target /classes;
src/test/java ,src/test/resources, 选择target/test-classes;

1365863682_6273

修改完成后如下图所示:

1365863693_6468

修改JDK版本:选择 libraries 标签,选中JRE library,单击Edit按钮

1365863704_4952

选择系统默认的就可以了,单击 Finish 按钮:

1365863729_2512

最后,单击OK即可:

1365863769_4461

完成后,项目结构如下图:

1365863781_4158

2.3 将项目转换为Dynamic Web Project

在项目上右键单击,选择 Properties:

1365863806_5537

在左侧选择 Project Facets,单击右侧的 ”Convert faceted from “链接:

1365863817_6166

修改Java为你当前项目的JDK,并添加Dynamic Web Module ,最后单击”Further Configuration available“ 链接:

1365863830_6294

修改Content directory 为 src/main/webapp ,单击OK:

1365863840_2584

在一次单击OK,完成操作:

1365863853_7859

2.4 设置部署程序集(Web Deployment Assembly)

在项目上右键单击,选择Properties,在左侧选择Deployment Assembly

1365863864_8268

此处列表是,部署项目时,文件发布的路径。
1,我们删除test的两项,因为test是测试使用,并不需要部署。
2,设置将Maven的jar包发布到lib下。
Add -> Java Build Path Entries -> Maven Dependencies -> Finish
设置完成效果图
1365863878_5803

单击OK

完成后,项目结构如下图所示:

1365863887_1279

就这样,使用Maven构建的一个Web项目就完成了。

Linux SVN提交时强制写日志

SVN默认可以不写注释提交,有时候可能忘记写注释,有的人也没有写注释的习惯,导致翻看history的时候都不知道做了哪些更改,可以依照以下步骤修改SVN配置,强制提交SVN前写注释

步骤:

1.进入svn/code/hooks目录,在svn版本库的hooks文件夹下面,复制模版pre-commit.tmpl

cp pre-commit.tmpl pre-commit
chmod +x pre-commit

2.编辑pre-commit文件:

$SVNLOOK log -t "$TXN" "$REPOS" | \
grep "[a-zA-Z0-9]" > /dev/null || exit 1

"$REPOS"/hooks/commit-access-control.pl "$REPOS" $TXN \
"$REPOS"/hooks/commit-access-control.cfg

上面这几行注释掉(前面加#符号),在此位置添加如下几行:

#必须填写注释且不少于5个字
# Make sure that the log message contains some text.
SVNLOOK=/usr/bin/svnlook #如果这句被注释掉,请打开注释
LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c`
if [ "$LOGMSG" -lt 5 ];#要求注释不能少于5个字符,您可自定义
then
echo -e "注释信息不能为空且不少于5个字!" 1>&2
exit 1
fi
exit 0

ubuntu支持exfat分区

对于Ubuntu 14.04.5之前的版本

  1. Add the repository:
    $ sudo add-apt-repository ppa:relan/exfat
  2. Update the package list:
    $ sudo apt-get update
  3. Install the exfat package:
    $ sudo apt-get install exfat-fuse

对于Ubuntu 14.04.5以及之后的版本

$ sudo apt-get install exfat-fuse

Eclipse debugger always blocks on ThreadPoolExecutor without any obvious exception

I'm working on my usual projects on Eclipse, it'a a J2EE app, made with Spring, Hibernate and so on. I'm using tomcat7 for this (no particular reason, I don't exploit any new feature, I just wanted to try that). Every time I debug my application, it happens that eclipse debugger pops out like it has reached a breakpoint, but it is not the case, in fact it stops on a Java Source File that is ThreadPoolExecutor. There is no stack trace on the console, it just stops. Then if I click on resume it goes on and the app works perfectly. This is what shows in the debugger window:

Daemon Thread ["http-bio-8080"-exec-2] (Suspended (exception RuntimeException))
ThreadPoolExecutor$Worker.run() line: 912
TaskThread(Thread).run() line: 619

I really can't explain this, because I'm not using ThreadPoolExecutor at all. Must be something from Tomcat, Hibernate or spring. It's very annoying because I always have to resume during debugging.

Any clues?

The posted stack trace indicates that a RuntimeException was encountered in a Daemon thread. This is typically uncaught at runtime, unless the original developer caught and handled the exception.

Typically, the debugger in Eclipse is configured to suspend execution at the location where the exception was thrown, on all uncaught exceptions. Note that the exception might be handled later, lower down in the stack frame and might not lead to the thread being terminated. This would be cause of the behavior observed.

Configuring the behavior of Eclipse is straightforward - in the Preferences Dialog, the Debug pane under Java in the tree hierarchy, has the option titled "Suspend execution on uncaught exceptions", which can be unchecked.

Ubuntu 13.10 aapt: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory

升级到Ubuntu 13.10 之后 Eclipse 中的Android adb 会报告  Android/android-sdk-linux/build-tools/19.0.0/aapt: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory

原因在于,在13.10 版本中,ia32_libs 被废弃了导致没有32位的lib库。

解决方法

sudo apt-get install lib32stdc++6
sudo apt-get install lib32z1

Android Support v4、v7、v13的区别和应用场景

google提供了Android Support Library package 系列的包来保证来高版本sdk开发的向下兼容性,即我们用4.x开发时,在1.6等版本上,可以使用高版本的有些特性,如fragement,ViewPager等,下面,简单说明下这几个版本间的区别:

Android Support v4 这个包是为了照顾1.6及更高版本而设计的,这个包是使用最广泛的,eclipse新建工程时,都默认带有了。

    Android Support v7:  这个包是为了考虑照顾2.1及以上版本而设计的,但不包含更低,故如果不考虑1.6,我们可以采用再加上这个包,另外注意,v7是要依赖v4这个包的,即,两个得同时被包含。

    Android Support v13  :这个包的设计是为了android 3.2及更高版本的,一般我们都不常用,平板开发中能用到。

WordPress”正在执行例行维护,请一分钟后回来”解决办法

今天在后台升级一个插件,页面显示“WordPress正在执行例行维护,请一分钟后回来”,一直停留在那儿。不是吧。多了一会还是这个页面,不太对劲,Google一下。有很多博主出现这种情况,说要改这个文件改 那个文件。最后一篇文章上的方法解决了此问题。

just delete .maintenance file

ftp登录网站空间,在blog根目录发现多出一个.maintenance文件,删除即可,再刷新。

wordpress迁移+更换域名

第一步:需要备份原来的wordpress根目录,比如,从原来的www.mobibrw.com上打包,拷贝到新服务器上,并解压。
第二步:备份数据库

mysqldump -u user --password=password -h localhost --opt dbname > dbname.sql

第三步:将备份数据库导入到新的数据库中(导入前需要新建数据库)。

mysql -u user -p  dbname < ~/dbname.sql

第四步:修改数据库表:
1.修改wp_options表的option_name列,将option_name为siteurl的值修改为新的blog地址

update wp_options set  option_value="http://127.0.0.1/wordpress" where option_name="siteurl";

2.修改wp_options表的option_name列,将option_name为home的值,修改为新的blog地址,如

update wp_options set  option_value="http://127.0.0.1/wordpress" where option_name="home";

第五步:修改wordpress的配置文件wp-config.php
主要是修改DB_NAME,DB_USER,DB_PASS,DB_HOST四个字段
将上面四个字段按照新的数据库配置进行修改
注:此外,需要注意在wordpress后台,修改默认上传路径为新的路径,如:
修改wordpress后台的默认上传路径
修改wordpress后台的默认上传路径

否则可能无法上传发布图片等
再注:如果迁移后,有些图片无法看到,那么肯定是文章中,图片的地址仍然是老地址,此时在phpmyadmin中登陆,执行以下sql:

update `wp_posts` set `post_content` = replace (`post_content`,"https://www.mobibrw.com/wp-content/uploads","http://127.0.0.1/wordpress/wp-content/uploads");

将文章中,存在的图片旧地址全部替换为新的地址。