2011年12月8日

ruby 正则 的陷阱

摘要: 众所周知,正则表达式中 ^匹配字符串的 开始, $ 匹配字符串的 结束。而ruby 正则中的,^ 匹配的是行开始, $匹配的是行结尾, 字符串的开始和 结束 应该 用\A \z.下面看个例子吧:str = "string\n&@*"str.match(/^\w+$/) #=> #<MatchData "string">str.match(/\A\w+$\z/) #=> nil 阅读全文

posted @ 2011-12-08 11:23 Eric812048774 阅读(237) 评论(0) 推荐(1) 编辑

2011年10月25日

ruby 在 windows 中 新建进程 打开其他程序

摘要: 引入win32ole即可调用ShellExecute 方法require 'win32ole'shell = WIN32OLE.new('Shell.Application')shell.ShellExecute(FILE, ARGUMENTS, DIRECTORY, OPERATION, SHOW)详细见:http://rubyonwindows.blogspot.com/2007/05/launching-apps-and-printing-docs-with.html 阅读全文

posted @ 2011-10-25 10:17 Eric812048774 阅读(265) 评论(0) 推荐(0) 编辑

2011年9月26日

rails try方法

摘要: 在rails中,常常要做 是否存在的判断。例如:@person && @person.nameor@person ? @person.name : nil其实可以使用更简洁的写法@person.try(:name)如果@person是 nil 也有 try 这个方法,返回值为 nil。try 是Object 类 和 Nil 类的方法。 阅读全文

posted @ 2011-09-26 14:15 Eric812048774 阅读(269) 评论(0) 推荐(0) 编辑

2011年9月18日

ruby1.9.2 String中的 encode, encode!, force_encoding.

摘要: 根据http://yugui.jp/articles/850这上面说的。ForaString,String#encodekeepsthecharactersbutchangestheencodinginwhichthecharactersareencoded.#encodeisnotdestructivebut#encode!isthedestructiveversion.Thebyterepresentationofacharacterisdependonencoding.So#encodeand#encode!generallychangethebyterepresentationofth 阅读全文

posted @ 2011-09-18 17:07 Eric812048774 阅读(772) 评论(0) 推荐(1) 编辑

ubuntu下 安装vim的ruby 自动补全插件 ---Rsense

摘要: 今天在ruby官网documentation中的时候发现了个好东西 --Rsense主要功能有以下:代码自动补全(看到这条就亮了), 类型检查,方法跳转。同鞋们,注意这个代码补全可不是普通的上下文补全哦, 是根据ruby语法自动补全哦。官方文档:http://cx4a.org/software/rsense/manual.html#Installation废话不多说,下面就开始安装吧:1。首先需要安装ruby(这步就不多说了)2。安装java虚拟机$ sudo apt-get install openjdk-6-jdtip:可以先坐下来喝杯茶。3。接下来进入主题了Install RSense下 阅读全文

posted @ 2011-09-18 13:45 Eric812048774 阅读(2477) 评论(5) 推荐(2) 编辑

2011年9月13日

mongodb gui 的安装

摘要: 官方网站推荐的gui工具http://www.mongodb.org/display/DOCS/Admin+UIs执行以下命令:sudo aptitude install python-setuptools mongodb python-django python-pymongogit clonehttp://github.com/Fiedzia/Fang-of-Mongo.gitcd fangofmongopython ./manage.py runserverOK了,现在打开你的浏览器输入http://localhost:8000/fangofmongo/大功告成了可惜这只是理想状态。。。 阅读全文

posted @ 2011-09-13 00:41 Eric812048774 阅读(483) 评论(0) 推荐(0) 编辑

2011年9月3日

rails3学习视频

摘要: http://www.verycd.com/topics/2889837/ 阅读全文

posted @ 2011-09-03 16:31 Eric812048774 阅读(109) 评论(0) 推荐(0) 编辑

C++ 发送HTTP请求

摘要: #include <iostream>#include <string>#include <stdlib.h>#include <winsock.h>//dont forget to add wsock32.lib to linker dependenciesusing namespace std;#define BUFFERSIZE 1024void die_with_error(char *errorMessage);void die_with_wserror(char *errorMessage);int main(int argc, ch 阅读全文

posted @ 2011-09-03 16:01 Eric812048774 阅读(1497) 评论(2) 推荐(1) 编辑

C++ 遍历文件夹

摘要: BOOL IsRoot(LPCTSTR lpszPath){ TCHAR szRoot[4]; wsprintf(szRoot, "%c:\\", lpszPath[0]); return (lstrcmp(szRoot, lpszPath) == 0);}void FindInAll(::LPCTSTR lpszPath){ TCHAR szFind[MAX_PATH]; lstrcpy(szFind, lpszPath); if (!IsRoot(szFind)) lstrcat(szFind, "\\"); lstrcat(szFind, &quo 阅读全文

posted @ 2011-09-03 15:56 Eric812048774 阅读(390) 评论(0) 推荐(0) 编辑

win 系统函数大全

摘要: ASSOC 显示或修改文件扩展名关联。 ATTRIB 显示或更改文件属性。 BREAK 设置或清除扩展式 CTRL+C 检查。 BCDEDIT 设置启动数据库中的属性以控制启动加载。 CACLS 显示或修改文件的访问控制列表(ACL)。 CALL 从另一个批处理程序调用这一个。 CD 显示当前目录的名称或将其更改。 CHCP 显示或设置活动代码页数。 CHDIR 显示当前目录的名称或将其更改。 CHKDSK 检查磁盘并显示状态报告。 CHKNTFS 显示或修改启动时间磁盘检查。 CLS 清除屏幕。 CMD 打开另一个 Windows 命令解释程序窗口。 COLOR 设置默认控制台前景和背景颜色 阅读全文

posted @ 2011-09-03 15:53 Eric812048774 阅读(314) 评论(0) 推荐(0) 编辑

导航