ITeye博客

2011 年文章归档

共 106 篇文章

2011年辞世的17位科技先驱

美国IT网站eWeek今天撰文,缅怀了今年辞世的17位科技行业先驱。其中,苹果联合创始人史蒂夫·乔布斯(Steve Jobs)位居首位。 以下为文章全文: 除了苹果联合创始人史蒂夫·乔布斯和C语言之父丹尼斯·里奇(Dennis Ritchie)之外,2011年还有许多科技行业的梦想家和技术先驱先后辞世。计算机行业从1950年代开始发展,期间曾有众多卓越的人才为现代化计 算、智能电子和互联网的发展奠定了基础。2011年辞世的很多先驱都曾是科技公司的创始人和CEO,并带领他们所在的企业充分利用了新兴技术的优势。还有 一些人则一直在从事光学、数学和密码学等领域的基础研究。他们很多人都彼此相识,并且…

2011-12-29 05:23 · IT生活

关于rails generate migrate 修改字段类型

有几种写法,最早就是add remove了 class AddSsl < ActiveRecord::Migration def up add_column :accounts, :ssl_enabled, :boolean, :default => 1 end def down remove_column :accounts, :ssl_enabled end end 这个有个显著问题,字段值没了。 那么 rails g migration change_date_format_in_my_table class ChangeDateFormatInMyTable < ActiveReco…

2011-12-21 00:11 · Ruby技巧 · Ruby On Rails

ruby 1.9 rails 3.1 ruby debug的问题

update(2015/05/12): for rbenv gem install debugger -- --with-ruby-include=/home/hlee/.rbenv/versions/1.9.2-p330/lib/ruby/gems/1.9.1 update (2012/11/13) : Update ruby to 1.9.3-p327 got the same problem of debugger-linecache and checking for vm_core.h... no checking for vm_core.h... no Makefile creat…

2011-12-20 23:06 · Ruby On Rails · Ruby 1.9

重写ActiveRecord的get set方法

def name=(name) write_attribute(:name, name.capitalize) end def name read_attribute(:name).downcase # 没有判断是否为nil end

2011-12-16 08:35 · Ruby On Rails

关闭rails 3.1 console的sql 输出

Rails 3.1的小改进,能在运行查询的时候,看执行的日志,大部分时候,很有用。有时就需要关闭,如下: old_logger = ActiveRecord::Base.logger ActiveRecord::Base.logger = nil 打开: ActiveRecord::Base.logger = old_logger

2011-12-14 12:32 · Ruby On Rails

ruby array中找出重复元素

#上文的inject现在用上了 module Enumerable def dups inject({}) {|h,v| h[v]=h[v].to_i+1; h}.reject{|k,v| v==1}.keys end end arr = %w{foo bar baz bar baz qux foo zub} puts arr.dups.inspect # => ["baz", "foo", "bar"] #替换一 inject(Hash.new(0)) {|h,v| h[v] += 1; h}.reject{|k,v| v==1}.keys 这个是比较好理解的 class Array de…

2011-12-14 12:28 · Ruby 1.9

也说说ruby inject

其实,没有什么太多说的,IE有的先链接过来 http://biyeah.iteye.com/blog/1286449 http://www.iteye.com/topic/56291 下面的总结的挺好, 完了来回顾一下inject方法两种用法: enum.inject(init_value) {|memo,obj| block} enum.inject{ |memo,obj| block } 第一种,memo以init_value为初始值 第二种,memo以enum里的第一个元素为初始值。 然后,inject可以这么写 (1..4).inject(&:+) 涵义是 {|memo, a| me…

2011-12-12 08:09 · Ruby On Rails · Ruby 1.9

ruby1.9 debug工具错误

ruby-debug-base19-0.11.25/lib/ruby_debug.so: undefined symbol: ruby_threadptr_data_type gem 'linecache19', :git => 'git://github.com/mark-moseley/linecache' gem 'ruby-debug-base19x', '~> 0.11.30.pre4' gem 'ruby-debug19', :require => 'ruby-debug'

2011-12-07 10:09

rails3 lib路径加载

config.autoload_paths += %W(#{config.root}/extras) #单个文件夹和所有文件目录 config.autoload_paths += Dir["#{config.root}/lib/**/"] config.autoload_paths += Dir["#{config.root}/lib", "#{config.root}/lib/**/"] rails 3默认不加载lib的文件,打开的话

2011-12-06 11:00

API service 安全问题

这是一个长期关注的课题 rest api Service的安全 比如jsonp怎么是安全的 算是阅读目录吧: http://hueniverse.com/2010/05/introducing-oauth-2-0/ http://guides.rubyonrails.org/security.html http://xaop.com/blog/2010/03/05/authentication-with-oauth-in-ruby-on-rails/ https://github.com/intridea/oauth2 https://github.com/songkick/oauth2-p…

2011-12-04 08:47 · RubyOnRails

登堂入室,初窥堂奥

在软件这个行业里晃荡了有些年了,我想自己还没有真正达到这个境界。 当然,最近是在找工作了,匆匆忙忙中,反而感觉有一颗躁动不安分的心,渐渐平复下来。对于,程序猿的路也有了新的看法,何去何从,职业上以后的路要怎么走,也渐渐清晰。或许,这便是登堂入室的边缘了吧。 如同,小说里的剑侠,或者刀客,修为的提升往往和心境相关。三流的刀客或者终其一生。 随便感慨一下,继续做三流刀客的码农,coding

2011-12-04 08:25 · IT生活

rails activerecord join查询 include 和 find_or_create find_or_initialize

Student.joins(:schools).where(:schools => { :category => 'public' }) Student.joins(:schools).where('schools.category' => 'public' ) # No 'Summer' tag exists Tag.find_or_create_by_name("Summer") # equal to Tag.create(:name => "Summer") # Now the 'Summer' tag does exist Tag.find_or_create_by_name("Su…

2011-12-02 23:45 · Ruby On Rails

按时间段分组

PostgreSQL: User.count(:order => 'DATE(created_at) DESC', :group => ["date(created_at)"]) User.count(:order => 'DATE(created_at) DESC', :group => ["date(created_at)"]).each {|u| puts "#{u[0]} -> #{u[1]}" } Foo.order("DATE(start_at)").group("DATE(start_at)").count Mysql在另一篇,heroku啊,让我学习postgresql se…

2011-12-02 23:44 · Ruby On Rails

带序号循环Hash

hash.keys.each_with_index do |key, index| value = hash[key] print "key: #{key}, value: #{value}, index: #{index}\n" # use key, value and index as desired end hash.each_with_index do |(key, value), index| print "key: #{key}, value: #{value}, index: #{index}\n" # use key, value and index as desired e…

2011-12-02 23:17 · Ruby 1.9

Rails 写migrate的时候支持的数据类型

Rails Migration Data Types – MySql – Postgresql – SQLite **Rails** **mysql** **postgresql** **sqlite** :binary blob bytea blob :boolean tinyint(1) boolean boolean :date date date date :datetime datetime timestamp datetime :decimal decimal decimal decimal :float float float float :integer int(11) in…

2011-12-01 05:11 · Ruby On Rails

RubyOnrails面试系列八

这次遇到的奇怪的比较多 数据库index有什么算法实现和时间复杂度 中间人攻击 和上面相关,从浏览器到服务器的交互过程, Session的实现原理 Set的数据结构 反而算法和rails的题做的还可以 算法问了,nlogn的从随即序列,存在两个数和是固定值 rails部分问的,partial优化和css布局,float后height问题和overfloat 当前我的弱项是算法,数据结构和模式 时间有限只能一点点来了,当前,还是先扎实Ruby Rails还有测试部分的基础,回头呢,在过一过算法和数据结构。 上面的问题吧,只能在面试和contract项目中积累了。

2011-11-29 12:36 · Ruby On Rails

10款原型设计工具

个人比较喜欢Axure和 原型草图工具Balsmiq Mockups介绍 MockFlow MockFlow allows you to design and collaborate (in real-time) user interface mockups for your software and websites. It comes with numerous built-in components & icons. Axure Axure enables application designers to create wireframes, flow diagrams, protot…

2011-11-29 07:52

关于watir selenium和webdriver soda cucumber

watir和selenium在自动化测试web测试领域强硬增长。这一趋势日渐强势,各种搭配和框架丛生。 简单的搜集,我看到了cucumber配合watir的框架,看到例教,和类似的测试集成框架,也看到分布式测试框架 简单使用: 安装 gem install watir-webdriver require 'watir-webdriver' b = Watir::Browser.new b.goto 'bit.ly/watir-webdriver-demo' b.text_field(:id => 'entry_0').set 'your name' b.select_list(:id => …

2011-11-29 01:34 · Ruby On Rails · Unit Test

Ruby On Rails 面试系列七,一个面试练习题

现在面试流行让你写代码放到github上,这是其中一个要求: Please create a todo-list application with the following capabilities: Login and account creation RSpec & Cucumber Tests Bonus points for incorporating Ajax(Drag & Drop to-do items) CSS Nice templates/layouts Updating THIS README See: Tom Preston Werner See: Matt Park…

2011-11-28 12:26 · Ruby 1.9 · rake

回馈开源社区赢IPAD-帮RailsCasts宣传

RailsCasts.com,致力于推广Rails知识,持续发布前沿的Rails技术展示和讲解视频,当前发布视频数量已经达到300部。从事Rails开发的程序员或多或少,或直接或间接的都从RailsCasts上受益过。 作为RailsCasts的制作者Ryan Bates ( rbates on Twitter and ryanb on GitHub),以“是时间回馈开源社区”组织活动,宣传RailsCasts,庆祝视频数量达到300部,以便有更多的人了解RailsCasts。 活动大致情况如下: 在github上,找一个你喜欢的项目,提交一个pull request,项目提交要有一定质量。…

2011-11-27 07:13 · Ruby On Rails