自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(93)
  • 收藏
  • 关注

使用rails和mongoid删除MongoDB重复的项

手上有一个表,本来是不重复的,但是因为 field 没有明确指定为 String 还是Int,结果导致,存储的 c_num 有 123 和 "123" 这两条结果;无奈之极,只好 将所有的 数字 变成了 字符串。Car.where(:c_num.with_type => 16).each {|car| car.update_attribute(:c_num, car.c_num.t...

2013-08-23 15:24:57 162

原创 unescape编码错误

javascript 的 escape 中文 编码成 utf-8格式的ruby 的 unescape 中文 解析为 gbk编码的,所以ruby无法解析javascript的escape什么情况下ruby可以解析:还是中文的问题,在?传递中文参数时请使用encodeURIComponent.document.write(encodeURICompone...

2013-08-21 12:55:13 445

原创 mysql2安装错误

administrator@ubuntu:~/store$ gem install mysql2 Fetching: mysql2-0.3.13.gem (100%)Building native extensions. This could take a while...ERROR: Error installing mysql2: ERROR: Failed to b...

2013-08-08 13:22:49 262

原创 nokogiri安装错误处理

administrator@ubuntu:~/store$ gem source*** CURRENT SOURCES ***http://ruby.taobao.orgadministrator@ubuntu:~/store$ gem install nokogiriBuilding native extensions. This could take a while......

2013-08-08 13:14:50 863

原创 ruby-nokogiri -xpath 用法说明

//div[@xxx = "sss"]/table[2]/tr[1]/td[1]/a/@href上面那段代码的意思说清楚,基本上可以用xpath 解析html了。xpath()at_xpath()做个记录先参考资料:http://stackoverflow.com/questions/2683298/xpath-matching-attribute-a...

2012-08-01 14:14:56 232

原创 看哪个目录占的空间比较大

看哪个目录占的空间比较大能排序不?闪的快呀这 看毛啊。。。或者只显示 统计结果吧 du -sh * | sort -hk1如果没有h的话就两边都去掉hdu -s * | sort -k1...

2012-07-27 17:09:23 132

原创 ssh 显示中文

设置FB的字集字集 utf-8# setenv LANG zh_CN.UTF-8PUTTY设置里Window->Appearance : 字体选择宋体Window->Translation : 字符集选择 UTF-8.

2012-07-26 16:07:26 333

原创 apt-key是Debian软件包的安全管理工具

apt-key是Debian软件包的安全管理工具。每个发布的deb包,都是通过密钥认证的,apt-key用来管理密钥。1> apt-key list 列出已保存在系统中key。Example:chao@gardenia:/etc/apt$ sudo apt-key list[sudo] password for chao:/etc/apt/trusted.gpg----...

2012-07-18 16:34:59 215

原创 ruby-(%Q-%q-%W-%w-%r-%s-%x)说明

%QThis is an alternative for double-quoted strings, when you have more quote characters in a string.Instead of putting backslashes in front of them, you can easily write:[code="java"]>> %Q(Joe sai...

2012-07-17 09:27:42 109

原创 windows7的telnet

笔者有一次需要telnet到客户的刀片光纤交换机模块上进行配置,但是当我打开windows7自带的CMD输入telnet命令之后,系统却提示我“不是内部或外部命令也不是可运行的程序或批处理”。 我的第一感觉是CMD功能失效了,于是又尝试了ping的命令,奇怪的是ping功能可以正常使用。这时候我想到了可能是在windows7上telnet这个功能没有被开启。 于是打开“控制面板”,...

2012-07-14 10:24:48 73

gem install mysql sqlite3-ruby nokogiri 错误

$ gem install mysql2 Building native extensions. This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. =============8

2012-07-13 21:22:17 99

原创 Capistrano deploy ** Host key verification failed

Known Hosts bugIf you are not using agent forwarding, the first time you deploy may fail due to Capistrano not prompting with this message:# The authenticity of host 'github.com (207.97.227.23...

2012-07-13 20:44:03 102

原创 It seems the user clicked on the 'Stop' button in his browser.

Reported by pierre.b...@gmail.com, Sep 8, 2009What steps will reproduce the problem?1. Nginx 6.712. Passenger 2.2.43. Random page show a 502 Gateway errors with this message[ pid=2398 file...

2012-07-12 08:37:28 181

原创 git - remote add origin 的使用

Global setup: Set up git git config --global user.name "Your Name" git config --global user.email huang.gadela@gmail.com Next steps: mkdir test cd test git init touch READ...

2012-07-02 12:57:03 4841

原创 ruby 中puts和print和p,pp

共同点:都是用来屏幕输出的。不同点:puts 输出内容后,会自动换行(如果内容参数为空,则仅输出一个换行符号);另外如果内容参数中有转义符,输出时将先处理转义再输出,puts传递的参数不知一个,可以有多个参数() puts 将puts("this is ge num=",a,"this is b=",b) 用逗号隔开的当做几个字符串来处理而print 把print("this ...

2012-06-16 18:23:59 763

原创 Rspec的get和visit

get 'pages/home'返回的是 状态visit '/pages/home'返回的是网页html

2012-06-13 11:16:43 160

原创 gem命令

ruby -v #查看ruby 版本ruby -e ''require"watir"; puts Watir::IE::VERSION'' #查看watir版本gem -v #gem版本gem update #更新所有包gem update --system #更新RubyGems软件gem install rake #安装rake,从本地或远程服务器gem install...

2012-06-12 23:11:31 92

原创 生产环境下 production.rb 样式和js不自动编译

application.rb config.generators.stylesheet_engine = :sass在 production.rb里面加上 config.assets.js_compressor = :uglifier config.assets.css_compressor = :scss

2012-06-12 14:25:24 127

原创 open-uri------open()

一个带异常处理的open...Ruby代码 def safe_open(url, retries = 5, sleeep = 0.42, headers = {}) begin open(url, headers).read rescue StandardError,Timeout::Error, SystemCallError, Err...

2012-06-08 10:48:37 185

原创 git 放弃当前对文件 的修改

git checkout master //取出master版本的head。git checkout tag_name //在当前分支上 取出 tag_name 的版本git checkout master file_name //放弃当前对文件file_name的修改 git checkout commit_id file_name //取文件f...

2012-06-07 17:05:56 550

原创 关于新建一个应用程序

要做的有很多。一下子全部都往身上压,我们就被压死了。看看敏捷怎么做吧。要敏捷,就要轻快,不能有那么多压力。1.你今天要做什么,(要做什么?今天就那么几个小时给你用,你能做的很有限吧。不要安排太多了,要不然,你可就不敏捷了。)2.好好的把那一点事情干好。3.保持这个进度,每天积累。4.大家讨论任务,自己去领任务吧,别强硬的压任务下去了。无论是压给自己还...

2012-06-03 16:32:56 74

原创 ubuntu安装nokogiri错误

gem install nokogiri 提示错误,冒失一些 依赖的包没有找到....libxslt is missing....让去 http://nokogiri.org/tutorials/installing_nokogiri.html 查看,打不开呀。好像:这样就可以搞定sudo apt-get install libxslt-dev libxml...

2012-05-30 19:34:48 239

原创 mysql2安装失败in ubuntu

> gem install mysql2Building native extensions. This could take a while...ERROR: Error installing mysql2: ERROR: Failed to build gem native extension.============8sudo apt-get install...

2012-05-27 16:39:12 81

原创 Adding users to sudoers through shell script

You could simply echo (with elevated privileges, of course) directly to the /etc/sudoers file:nickw444@laptop ~ $ sudo -inickw444@laptop ~ $ echo 'nickw444 ALL=(ALL:ALL) ALL' >> /etc/sudoers(...

2012-05-27 15:24:48 75

原创 ubuntu安装mysql-server

[size=large]一。mysql安装[/size]>sudo apt-get install mysql-server安装过程中 设定 root 的 密码。。输入两次。。[size=large]二。mysql的配置[/size]vim /etc/mysql/my.cnf去掉注释的 最大连接60,改为:max_connections=1024[client]...

2012-05-26 15:46:20 70

原创 phusion passenger standalone

为了测试这个 passenger 先 放个项目 上去。。。建了个项目,配置了 capistrano 的 deploy.rbcap deploy:setupcap deploy:cold在项目目录下 运行: passenger start 提示安装: apt-get install libcrul4-openssl-dev or 。。。安装...

2012-05-26 13:04:15 125

原创 Ubuntu putty 的复制与粘贴

  在Ubuntu下经常用putty,老是为这个复制粘贴的事情搞得很郁闷,今天有空,网上搜了一下,原来gnome还有这种贴心的功能:  Linux users:  In Gnome,  you can paste text without previously copying it to the clipboard.  How does this work? First, high...

2012-05-26 12:48:31 410

原创 ubuntu下普通用户app 下的rvm安装

[size=x-large]准备:[/size]安装 curl :[i]sudo apt-get install curl[/i][size=x-large]开始安装[/size]curl -L get.rvm.io | bash -s stable[size=x-large]配置[/size][i]source ~/.bashrc[/i]...

2012-05-26 11:01:32 108

原创 ubuntu下root用户下的rvm安装

[b]声明:我是使用root 帐户安装的。。安装的是 多用户,所以直接安装在 /usr/local/rvm下面[/b]Ubuntu 的 Shell语言用的是Bash Shell[size=x-large]1.参考:rvm.io 官网[/size]直接使用 curl -L get.rvm.io | bash -s stable 命令 是不行的。来自: https://r...

2012-05-26 10:49:38 208

原创 使用Unicorn替代Mongrel作为Ruby on Rails的服务器

先前的开发的Ruby on Rails网站使用的服务程序是Mongrel + Nginx, 现在用了Rails 3, 发现Mongrel对它有兼容问题, 所以要换一个。 虽然现在Phusion Passenger大行其道, 但使用前要重新编译Nginx。 为了避免重新安装nginx,我找到mongrel的替代品Unicorn。 没想到unicorn的设置非常方便。 我记录在这里供大家参考:...

2012-05-25 22:13:42 179

原创 sqlite3-ruby gem can't find sqlite3.h on ubuntu

sqlite3-ruby gem can't find sqlite3.h on ubuntuIn my case I had to install libsqlite3-devsudo apt-get install libsqlite3-dev

2012-05-25 18:34:43 77

原创 net-ssh

NameError: uninitialized constant Net::SSH::KnownHosts::SUPPORTED_TYPE===============add in Gemfilegem 'net-ssh', :git => 'git://github.com/nessche/net-ssh.git'bundel exec deploy:setu...

2012-05-25 18:12:32 123

原创 Dragonfly::ImageMagickUtils::ShellCommandFailed in ...

I'm really new to refinery and fairly new to rails overall. I've succesfully installed refinery and it's working great, except when I want to add an image. I get the following error: Dragonfly::...

2012-05-23 15:08:07 114

原创 ImageMagick in ubuntu

ImageMagick is a powerful suite of tools in Ubuntu for scripting batch manipulations of images. Conversion between formats, resizing and hundreds of sophisticated filters can all be automated with onl...

2012-05-23 15:04:30 120

原创 refinery bread_crumb

I just made a breadcrumb for my site and put it in _content_page.html: true) %> > ...

2012-05-23 14:32:35 115

原创 Rake

[b]Rake[/b]Rake lets you define a dependency tree of tasks to be executedRake tasks are loaded from the file RakefileRails rake tasks are under railties/lib/tasksPut your custom tasks under ...

2012-05-21 17:32:19 114

原创 Constraint

get '/mobile' => 'posts#index' , :constraint => { :use_agent => /iPhone/}, :default => { :mobile => true }

2012-05-21 17:31:34 111

原创 named_scope or scope 是什么?lambda 怎么用

rails2.* 里面的写法 named_scope rails3.* 里面 去掉 named_ 就直接 scope 如:rails 2.class Item named_scope :red, :conditions => { :colour => 'red' } named_scope :since, lambda {|time| {:condition...

2012-05-21 11:19:51 100

原创 find_or_initialize_by 和 find_or_create_by

Hash 和相等性ActiveRecord 的 hash 值是根据主键的值计算出来的,这就意味着未保存对象的 hash 值是不可靠的。同样两个 model 对象的相等比较(即==操作符)也是基于主键的,所以两个 model 对象即使它们的其他属性不一样,仍有可能被当作相等。查找find_by_attribute 方法后面加个 ! 号,即使用 find_by_attribut...

2012-05-21 11:11:17 328

原创 parameterize

parameterize :替换掉特殊字符,让它看起来像个漂亮的url,主要是根据正则表达式 ,替换掉非字母、数字及下划线的字符。。中文也将被替换掉。。。。那就没的搞了。中文的 url 还是要自己去定义了。================parameterize(string, sep = '-')Replaces special characters in a string ...

2012-05-21 10:52:18 320

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除