Sublimetext (for windows)编译运行c出现Error 2错误的解决办法

 
错误描述大概如下:
[Error 2] 
[cmd:  [u’bash’, u’-c’, u”g++ ‘D:\codeblocks\project\test.c’ -o ‘D:\codeblocks\project/test’ && ‘D:\codeblocks\project/test'”]]
[dir:  D:codeblocksproject]
 
原因是运行需要bash.exe,但在环境变量path中找不到。
 
解决办法是把C:MinGWmsys1.0bin 添加到path中,重启Sublimetext, ok
发表在 技术, 未分类 | 留下评论

vim和tmux主题颜色不一致问题

    没开tmux时使用vim 以及 开了tmux后使用vim 主题颜色不一致。随便打开一个.py文件,发现着色较深,非常影响阅读。
 
开始在.tmux.conf 中设置set -g default-terminal “linux”  ,解决了颜色问题,但后来发现vim中自定义的快捷键F1-F12 都失效了,按键会打出一个大写的字母,而不是预定义的功能。
 
在.tmux.conf 中设置 set -g default-terminal “screen-256color”, 快捷键问题解决,但颜色又不一致。
 
最后解决方法:
在.tmux.conf 中设置 set -g default-terminal “screen-256color”
.bashrc 中设置 
export TERM=”linux”
 
.vimrc :
set term=screen
 
我的环境: fedora20 , vim7.4
 
 
发表在 vim, 技术, 未分类 | 标签为 | 留下评论

vim配置

set ts=4
set sw=4
“set fileencoding=cp936
“set fileencodings=cp936
set fileencodings=utf-8,gbk,utf-16,big5
set encoding=utf-8
set encoding=cp936
set autoindent
set showcmd
set nocompatible
set smartindent
set showmatch
set t_Co=8
set t_Sf=^[[1;3%p1%dm
set t_Sb=^[[1;4%p1%dm
set hls
set incsearch
set ffs=unix
“colorscheme evening
set backspace=indent,eol,start

发表在 vim, 技术, 未分类 | 标签为 | 留下评论

vim安装YouCompleteMe 插件

 

 

要安装YouCompleteMe ,vim须支持python。看是否支持,可以在vim中:version 查看, 如果python前有+号,就是支持,减号就是不支持。

如果不支持,需要以编译安装方式重新安装vim。

编译配置选项:

./configure –with-features=huge –enable-pythoninterp –enable-python3interp –enable-luainterp –enable-multibyte –enable-sniff –enable-fontset

 

在我的机器上装有python2.7.5 和 python3.3, 但加了enable-python3interp参数依然没有支持py3,不知何故,先不管,YouCompleteMe 只要求有py2.6以上。

安装vundle插件

git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle

 

在.vimrc中配置

 

set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" alternatively, pass a path where Vundle should install plugins
"let path = '~/some/path/here'
"call vundle#rc(path)

" let Vundle manage Vundle, required
Plugin 'gmarik/vundle'

" The following are examples of different formats supported.
" Keep Plugin commands between here and filetype plugin indent on.
" scripts on GitHub repos
Plugin 'tpope/vim-fugitive'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'tpope/vim-rails.git'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" scripts from http://vim-scripts.org/vim/scripts.html
Plugin 'L9'
Plugin 'FuzzyFinder'
" scripts not on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
Plugin 'file:///home/gmarik/path/to/plugin'
" ...

filetype plugin indent on     " required
Bundle 'Valloric/YouCompleteMe'

 

 

 

  保存退出,打开vim,输入 :BundleInstall 进行自动安装

 

进程如下,+号表示已经安装,>表示正在安装。

. Plugin 'gmarik/vundle' |~ 
+ Plugin 'tpope/vim-fugitive' |~ 
+ Plugin 'Lokaltog/vim-easymotion' |~ 
+ Plugin 'tpope/vim-rails.git' |~ 
+ Plugin 'rstacruz/sparkup' |~ 
+ Plugin 'L9' |~ 
+ Plugin 'FuzzyFinder' |~ 
> Plugin 'git://git.wincent.com/command-|~ 
t.git' |~ 
Plugin 'file:///home/gmarik/path/to/pl|~ 
ugin' |~ 
Plugin 'Valloric/YouCompleteMe' |~ 
Helptags

  

结束时有个错误,这是正常的,因为ycm需要手工编译出库文件

Done! With errors; press l to view log
ycm_client_support.[so|pyd|dll] and ycm_core.[so|pyd|dll] not detected; you need
to compile YCM before using it. Read the docs!

到 .vim/bundle/YouCompleteMe 下跑

 ./install.sh –clang-completer

参数是为了支持c/c++ 的补全。

安装完成后进行一些简单的配置就可以使用。

YouCompleteMe 的补全配置文件在/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py,这是个隐藏文件。

默认会使用这个文件,也可以把这个文件copy到工程的根目录中作修改,打开工程文件时会优先使用当前目录下的配置文件。

如果找不到,会根据配置中的ycm_global_ycm_extra_conf 进行查找。

 

在.vimrc 中添加

let mapleader = “,”  ” 这个leader就映射为逗号“,”

let g:ycm_global_ycm_extra_conf = ‘~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py’   “配置默认的ycm_extra_conf.py
nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR>   “按,jd 会跳转到定义
let g_ycm_confirm_extra_conf=0    “打开vim时不再询问是否加载ycm_extra_conf.py配置
let g:ycm_collect_identifiers_from_tag_files = 1 “使用ctags生成的tags文件

 

 

发表在 c++, vim, 技术, 未分类 | 标签为 , | 留下评论

hibernate date类型插入数据库时精度只到日期没有时间

 

由hibernate 的逆向工具从数据库表生成的*.hbm.xml ,对于数据库的date类型生成如下:
       <property name = “crttime” type= “date”>
            <column name = “CRTTIME” length = “7”  />
        </property >
 
程序中的类型:
private Date crttime 
但通过程序setCrttime(new Date()) 的时候,插入到数据库的日期只到天,没有小时以后的数据。
 
网上查了一下,有的说可以修改type类型为 java.util.Date, 但实验发现hibernate不能识别此类型,修改为timestamp则可以。
 
如下是最终修改:
        <property name =“crttime” type=“timestamp”>
            <column name =“CRTTIME”   />
        </property >
 
我把length = “7” 也去掉了
 
发表在 java, 技术, 未分类 | 留下评论

perl在命令行中打印单引号

 

perl -e ‘print “‘”;’
 
这样写是不行的,这里直接执行会当作这命令未结束。反斜杠对符号做了转义,这样的命令解释成:
perl -e ‘print ‘;’ (双引号内一个单引号,它被当作了括住命令的单引号了)
 
要这样写:
perl -e ‘print “”'”;
 
双引号内是 单引号 反斜杠 单引号 ,这样经过双引号代换后变成:
perl -e ‘print ‘ ‘

 

 

参考:http://mcshell.blog.51cto.com/803455/484603

发表在 perl, 技术, 未分类 | 标签为 | 留下评论

UTL_FILE建文件失败“ORA-29280: 目录路径无效”错误

 

存储过程写文件需要配置可写的目录,具体是utl_file_dir这个参数,把UTL_FILE输出的目录写到这个参数,如果不限制,可以令utl_file_dir=*
 
查看:
 
SQL> show parameter utl_file_dir
 
NAME                                 TYPE
———————————— ———————-
VALUE
——————————
utl_file_dir                         string
 
SQL>
 
该参数为空,导致
 
修改:
alter system set utl_file_dir=* scope=spfile;
重启数据库
 
 
发表在 技术, 未分类 | 留下评论

openVPN报错:All TAP-Windows adapters on this system are currently in use

 

     

      解决办法:

   1. 确定openVPN服务已打开。

   2. 控制面板网络和 Internet网络连接,确定TAP-Windows Adapter V9已经启动。

发表在 技术, 未分类 | 留下评论

xampp连接Admin界面报错

报错信息:

phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.

 

这个是由于修改了mysql密码导致的。

 

解决办法:

修改config.inc.php配置文件

/* Authentication type and info */
$cfg[‘Servers’][$i][‘auth_type’] = ‘config’;
$cfg[‘Servers’][$i][‘user’] = ‘root’;
$cfg[‘Servers’][$i][‘password’] = ”;   // 填上你的密码。
$cfg[‘Servers’][$i][‘extension’] = ‘mysql’;
$cfg[‘Servers’][$i][‘AllowNoPassword’] = true;
$cfg[‘Lang’] = ”;

 

完了可能要重启xampp服务,如果还是不行,尝试清空你的浏览器的缓存。

发表在 技术, 未分类 | 留下评论

一个换行符引发的问题

     今天收到邮件,说甲方的运维人员通过我们的门户系统导入一批数据,但有个别号码在下一个运行模块中出现异常,查原因是甲方导入的数据中,个别手机号码字段后存在不可见换行符。检查导入模块的代码,有做校验,逻辑大概如下(java):

 

 Pattern msisdn = Pattern
                     . compile("^((13[0-9])|(15[0-9])|(18[0-9]))\d{8}$"if (a == null || "".equals(a)) {
                System. out.println( "移动号码不能为空;<br/>"else if (!msisdn.matcher(a).find()) {
                System. out.println( "无效的移动号码;<br/>"else {
                System. out.println( "号码正确"

   直觉我也觉得它能仅匹配出11位数字字符,但经过实验发现,它居然忽视了换行符(有和没有,都一样)。 

这个情况在perl中也存在,查了一下资料,如果要匹配换行符,需要加特别标识,如perl中如何要用 ‘.’ 匹配换行符,需要使用/m /s , 也就是说,它默认就忽略换行符。

 

 

 

发表在 java, 技术, 未分类 | 留下评论