自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Eric的小屋

ruby guy & railser 热爱生活,热爱工作

  • 博客(60)
  • 收藏
  • 关注

原创 安装mongrel:ERROR: Failed to build gem native extension

安装mongrel替代webrick,遇到如下问题(ruby版本1.9.2  rails版本3.1.3)ERROR:  Error installing mongrel:ERROR: Failed to build gem native extension.原因在于Mongrel 1.1.5与Ruby 1.9.x 不兼容。可以通过安装另个版本gem install mo

2012-01-28 12:05:29 8011 1

安装mongrel:ERROR: Failed to build gem native extension

安装mongrel替代webrick,遇到如下问题(ruby版本1.9.2 rails版本3.1.3)ERROR: Error installing mongrel:ERROR: Failed to build gem native extension.原因在于Mongrel 1.1.5与Ruby 1.9.x 不兼容。可以通过安装另个版本gem install mongrel --...

2012-01-28 12:05:00 257

原创 Mac上安装oh-my-zsh

在mac上默认的bash定制不够多样,部分功能不够强大。网上有介绍其他shell。而zsh是其中相当不错的一款,具体可以参考作者robby的作品oh-my-zsh安装的方法也挺简单;我使用curl安装。安装之后在用户目录下会生成/.zsh文件夹,里面包括了zsh的所有配置。如果在install上有什么不懂,可以直接查看wiki当然zsh也包括不同的主题可以切换,我选择了nebi

2012-01-22 21:51:49 6807

Mac上安装oh-my-zsh

在mac上默认的bash定制不够多样,部分功能不够强大。网上有介绍其他shell。而zsh是其中相当不错的一款,具体可以参考作者robby的作品oh-my-zsh安装的方法也挺简单;我使用curl安装。安装之后在用户目录下会生成/.zsh文件夹,里面包括了zsh的所有配置。如果在install上有什么不懂,可以直接查看wiki当然zsh也包括不同的主题可以切换,我选择了nebirhos在配置好主题...

2012-01-22 21:51:00 141

转载 Ruby Metaclass详解

如果你是Ruby Metaprogramming的新手,那么下面的代码或许会帮你找到一点感觉:class Object  # The hidden singleton lurks behind everyone  def metaclass; class   def meta_eval &blk; metaclass.instance_eval &blk; end  #

2011-12-30 13:39:23 852

Ruby Metaclass详解

如果你是Ruby Metaprogramming的新手,那么下面的代码或许会帮你找到一点感觉:class Object# The hidden singleton lurks behind everyonedef metaclass; class << self; self; end; enddef meta_eval &blk; metacla...

2011-12-30 13:39:00 135

原创 Ruby实现Google Api天气查询

(查询 Google 所支持的所有国家的代码,并以 zh-cn 简体中文显示) http://www.google.com/ig/cities?output=json&hl=zh-cn&country=cn(查询 Google 的天气api,例如选择“惠州”,并以简体中文显示)http://www.google.com/ig/api?hl=zh-cn&weath

2011-12-28 10:28:25 707

Ruby实现Google Api天气查询

(查询 Google 所支持的所有国家的代码,并以 zh-cn 简体中文显示)http://www.google.com/ig/cities?output=json&hl=zh-cn&country=cn(查询 Google的天气api,例如选择“惠州”,并以简体中文显示)http://www.google.com/ig/api?hl=zh-...

2011-12-28 10:28:00 110

转载 12个很棒的学习 jQuery 的网站推荐(转)

jQuery是目前最流行的 JavaScript 库。对于初学者来说,有的时候很难找到一个好的学习jQuery的网站,今天本文收集了12个很棒的 jQuery 学习网站推荐给大家。1. jquery-mix.com2. jqueryfordesigners.com3. 15daysofjquery.com4. jqueryking.com

2011-12-23 09:36:02 627

12个很棒的学习 jQuery 的网站推荐(转)

  jQuery是目前最流行的 JavaScript 库。对于初学者来说,有的时候很难找到一个好的学习jQuery的网站,今天本文收集了12个很棒的 jQuery 学习网站推荐给大家。1.jquery-mix.com2.jqueryfordesigners.com3.15daysofjquery.com4.jqueryk...

2011-12-23 09:36:00 143

转载 Rails Digest认证实现和原理

优势Http Digest是一种Http(不仅限于Web页面)认证框架,相比通常使用的基本认证,Digest认证的优点是相对安全、基于网络标准和简单,它不需要编写登录表单页面,对登录信息进行加密,这样就可以很好的支持较安全的程序自动连接(非浏览器连接),可以广泛的应用到数据服务领域。 实现在Rails中实现Http Digest认证是非常简单的,有两个步骤:1. 在控制器中

2011-12-17 23:48:10 2021

Rails Digest认证实现和原理

优势Http Digest是一种Http(不仅限于Web页面)认证框架,相比通常使用的基本认证,Digest认证的优点是相对安全、基于网络标准和简单,它不需要编写登录表单页面,对登录信息进行加密,这样就可以很好的支持较安全的程序自动连接(非浏览器连接),可以广泛的应用到数据服务领域。实现在Rails中实现Http Digest认证是非常简单的,有两个步骤:1. 在控制器中配...

2011-12-17 23:48:00 272

原创 Rails3 session应用

开发时遇到需要带参数的页面跳转。可以使用http中get方法直接跟参数的形式去完成这个小问题,但是看着整个url很长很杂,所以想到了session来解决这个问题。在rails3中,session用法不难,难的是要控制session的有效使用时间、存储量大小等后续问题。1.使用范围  controller和view中可用2.保存的数据  ◇一般保存会话进行的必要数据,如保存登录用户的

2011-11-06 11:26:26 3155

Rails3 session应用

开发时遇到需要带参数的页面跳转。可以使用http中get方法直接跟参数的形式去完成这个小问题,但是看着整个url很长很杂,所以想到了session来解决这个问题。在rails3中,session用法不难,难的是要控制session的有效使用时间、存储量大小等后续问题。1.使用范围 controller和view中可用2.保存的数据 ◇一般保存会话进行的必要数据,如保存登录用户的的ID:...

2011-11-06 11:26:00 179

原创 从头到尾搭建ROR服务器

<!--@page {margin:2cm}p {margin-bottom:0.21cm}-->1.安装ubuntu10.04系统。分区方案如下:联网,分区(如果装11.04版本,耗费时间将很长,但是不需要分区)2.进入ubuntu系统,配置一下必要环境:gvim编辑器;git仓库;ssh;mysql数据库;apache服务器,gnome-do

2011-11-04 13:26:03 1101

从头到尾搭建ROR服务器

&lt;style type="text/css"&gt;&lt;!--@page {margin:2cm}p {margin-bottom:0.21cm}--&gt;&lt;/style&gt;1.安装ubuntu10.04系统。分区方案如下:联网,分区(如果装11.04版本,耗费时间将很长,但是不需要分区)2.进入ubuntu系统,配置一下必要环境:gvim编...

2011-11-04 13:26:00 182

原创 修改目录文件名-Ruby实现

require 'pathname'def change_name puts "------------" current_path = Pathname.new(File.dirname(__FILE__)).realpath current_file_name = __FILE__ begin Dir::foreach(current_path) do |file|

2011-11-04 12:47:03 2242

修改目录文件名-Ruby实现

require 'pathname'def change_name puts "------------" current_path = Pathname.new(File.dirname(__FILE__)).realpath current_file_name = __FILE__ begin Dir::foreach(current_path) do |file|...

2011-11-04 12:47:00 354

原创 ProjectRuler-10

#The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.#Find the sum of all the primes below two million.#require 'mathn'def sum_of_primes_below_two_million gen = Prime.new sum = 0 gen.each

2011-11-04 12:45:45 554

原创 ProjectRuler-9

#A Pythagorean triplet is a set of three natural numbers, a b c, for which,#a2 + b2 = c2#For example, 32 + 42 = 9 + 16 = 25 = 52.#There exists exactly one Pythagorean triplet for which a + b + c

2011-11-04 12:45:14 474

ProjectRuler-10

#The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.#Find the sum of all the primes below two million.#require 'mathn'def sum_of_primes_below_two_million gen = Prime.new sum = 0 gen.each...

2011-11-04 12:45:00 109

ProjectRuler-9

#A Pythagorean triplet is a set of three natural numbers, a b c, for which,#a2 + b2 = c2#For example, 32 + 42 = 9 + 16 = 25 = 52.#There exists exactly one Pythagorean triplet for which a + b + c ...

2011-11-04 12:45:00 142

原创 ProjectRuler-8

#ind the greatest product of five consecutive digits in the 1000-digit number.#73167176531330624919225119674426574742355349194934#96983520312774506326239578318016984801869478851843#8586156078911294

2011-11-04 12:44:32 482

ProjectRuler-8

#ind the greatest product of five consecutive digits in the 1000-digit number.#73167176531330624919225119674426574742355349194934#96983520312774506326239578318016984801869478851843#8586156078911294...

2011-11-04 12:44:00 152

原创 ProjectRuler-7

#By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.#What is the 10001st prime number?#answer : 104743#require "mathn"def order_of_prime number

2011-11-04 12:43:29 404

ProjectRuler-7

#By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.#What is the 10001st prime number?#answer : 104743#require "mathn"def order_of_prime number ...

2011-11-04 12:43:00 100

原创 ProjectRuler-6

#The sum of the squares of the first ten natural numbers is,#12 + 22 + ... + 102 = 385#The square of the sum of the first ten natural numbers is,#(1 + 2 + ... + 10)2 = 552 = 3025#Hence the diffe

2011-11-04 12:42:40 491

ProjectRuler-6

#The sum of the squares of the first ten natural numbers is,#12 + 22 + ... + 102 = 385#The square of the sum of the first ten natural numbers is,#(1 + 2 + ... + 10)2 = 552 = 3025#Hence the diffe...

2011-11-04 12:42:00 118

原创 ProjectRuler-5

#2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.#What is the smallest positive number that is evenly divisible by all of the numbers from 1

2011-11-04 12:41:54 465

原创 ProjectRuler-4

#A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99.#Find the largest palindrome made from the product of two 3-digit

2011-11-04 12:41:12 400

ProjectRuler-5

#2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.#What is the smallest positive number that is evenly divisible by all of the numbers from 1 ...

2011-11-04 12:41:00 121

ProjectRuler-4

#A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99.#Find the largest palindrome made from the product of two 3-digit...

2011-11-04 12:41:00 141

原创 ProjectRuler-3

#The prime factors of 13195 are 5, 7, 13 and 29.#What is the largest prime factor of the number 600851475143 ?require 'mathn'class Integer #这个解法是没有分解number,导致基数太大,效率极低 #def big_prime # lock =

2011-11-04 12:40:17 554

ProjectRuler-3

#The prime factors of 13195 are 5, 7, 13 and 29.#What is the largest prime factor of the number 600851475143 ?require 'mathn'class Integer #这个解法是没有分解number,导致基数太大,效率极低 #def big_prime # lock = ...

2011-11-04 12:40:00 132

原创 ProjectRuler-2

# Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:# 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...# By considering

2011-11-04 12:39:11 475

ProjectRuler-2

# Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:# 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...# By considering...

2011-11-04 12:39:00 92

原创 ProjectRuler-1

#If we list all the natural numbers below 10 #that are multiples of 3 or 5, we get 3, 5, 6 and 9.#The sum of these multiples is 23.#Find the sum of all the multiples of 3 or 5 below 1000. def sum

2011-11-04 12:38:21 456

ProjectRuler-1

#If we list all the natural numbers below 10 #that are multiples of 3 or 5, we get 3, 5, 6 and 9.#The sum of these multiples is 23.#Find the sum of all the multiples of 3 or 5 below 1000. def sum...

2011-11-04 12:38:00 115

转载 十五分钟介绍 Redis数据结构

本文装载自nosqlfan博客,具体链接 http://blog.nosqlfan.com/html/3202.html下面是一个对Redis官方文档《A fifteen minute introduction to Redis data types》一文的翻译,如其题目所言,此文目的在于让一个初学者能通过15分钟的简单学习对Redis的数据结构有一个了解。Redis是一种面向“键

2011-10-23 09:53:33 649

十五分钟介绍 Redis数据结构

本文装载自nosqlfan博客,具体链接 http://blog.nosqlfan.com/html/3202.html下面是一个对Redis官方文档《A fifteen minute introduction to Redis data types》一文的翻译,如其题目所言,此文目的在于让一个初学者能通过15分钟的简单学习对Redis的数据结构有一个了解。Redis是一种面向“键...

2011-10-23 09:53:00 82

空空如也

空空如也

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

TA关注的人

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