ITeye博客

Persevere

小嗷喏 · 共 28 篇文章

Mongoose 之 Population

mongoose 使用 population 填充`关联表`数据 博文已迁至 http://aikin.github.io/2014/11/02/mongoose-population

2014-12-01 21:14 · DB · 评论(0)

gulp-nodemon gulp-livereload 配置

gulp-nodemon 和 gulp-livereload 配置 迁移 Gulp API 初探和 gulp-nodemon gulp-livereload 配置 一、gulp 安装 1. 全局安装: npm install -g gulp 2. 安装在项目开发环境: npm install gulp --save-dev 二、gulp-nodemon 和 gulp-livereload 安装 gulp-nodemon 是重启服务器的插件。 gulp-livereload 后端控制前端同步刷新,不过需要依赖 chrome 插件 LiveReload 安装: npm install gulp-…

2014-11-09 20:58 · gulp · 评论(0)

IE 重载 iframe

迁移 http://aikin.me/2014/06/16/ie-iframe-cache/ 最近“致力于”调 IE9 、IE10 、 firefox 、 chrome 浏览器对 iframe刷新。 发现在IE浏览器中,有些刷新 iframe 的方法会加载缓存。以下就对一些方法在 IE9 、IE10(以下简称IE)的产生效果介绍一下: 1、对 iframe 的 src 属性重新赋值来实现刷新 $("#iframeId").attr("src", $("#iframeId").attr("src")); 在 IE 中,使用这个方法后 iframe 没有刷新的效果。iframe反应很平静。 2、…

2014-06-16 22:44 · JS · 评论(0)

cocos2d-html5 Sprite 注册点击事件

在 cocos2d-html5, 发现 Sprite 类没有点击事件,需要注册点击的代理, 才能接受点击事件。下面一段代码写了一个可以接受点击事件的 DemoSprite 类。 var DemoSprite = cc.Sprite.extend({ _touchBegan: false, _touchEnabled: true, ctor: function (image) { this._super(); this.init(image); }, onEnter: function () { cc.Director.getInstance().getTouchDispatcher()._a…

2014-06-16 17:55 · JS · 评论(0)

Rails 使用 zh-CN.yml

当使用 Rails 的 validates 对 User Model 的属性添加限制条件; 用户注册时,提示的信息将出现英文。 下面介绍如何将这些英文翻译成中文。 1. 请在 User Model中加入下面代码: validates :name, :presence => true, :uniqueness => {:case_sensitive => false} has_secure_password validates_length_of :password, :in => 6..12, :on => :create validates_length_of :password, :in…

2014-03-29 15:45 · Ruby \ Rails · 评论(0)

iOS 7 使用 UINavigationController 后导致 UIScollView尺寸变化

迁移 http://aikin.me/2014/03/16/ios7-uinavigationcontroller-uiview/ 在 iOS 7 中,如果某个 UIViewController 的 self.view 第一个子视图是 UIScollView, 同时当这个 UIViewController 被 push 或 initWithRootController 成为 UINavigationController控制的Controller时,这个 UIViewController的 view 的子视图 UIScollView 的所有子视图, 都会被下移 64px。 这个下移 64px …

2014-03-16 22:22 · iOS · 评论(0)

MongoDB GUI 之 RockMogo

转移 http://aikin.me/2014/03/15/mongodb-gui-rockmongo/ RockMongo 是一个PHP5写的,开源的 MongoDB 管理工具。 官网: http://rockmongo.com/wiki/introduction?lang=zh_cn github: https://github.com/iwind/rockmongo 1. 安装 php: 在终端输入: sudo apt-get install apache2 php5 php5-dev dh-make-php 终端最后几行显示: ...... 正在设置 php5 (5.4.9-4ubu…

2014-03-15 18:53 · DB · 评论(0)

rails 在Terminal新建用户

Rails 在后台新建用户。 user = User.new({:name=>'admin', :password=>'admin', :password_confirmation => 'admin', :is_amdin => true, :token=>'kajdlioew%^%hjks'}) user.save 或者: user = User.create({:name=>'admin', :password=>'admin', :password_confirmation => 'admin', :is_amdin => true, :token=>'kajdlioew%^%hjk…

2014-03-08 22:18 · Ruby \ Rails · 评论(0)

Ruby Array

1. 数组的创建: array = [1, 2, "3", "4"] 或者 array = Array.new array = Array.new(6) #创建[nil, nil, nil, nil, nil, nil] array = Array.new(6, "a") #创建["a", "a", "a", "a", "a", "a"] 也可以使用"%w"方法专门用来创建字符串数组: array = %w(a b c d) #使用空格作为元素的分隔符。返回值["a", "b", "c", "d"] 2.通过索引存取数组的值, 在Ruby中,数组索引可以是正整数(从前到后,从0开始)也可以是…

2014-03-08 20:40 · Ruby \ Rails · 评论(0)

Rails 根据 user_agent 判断请求端

要根据请求端的不同而返回不同的页面,首先就得判断出请求端是pc还是mobile。在http请求时,user_agent这个字段会记录用户所用的设备和浏览器。所以就得对user_agent进行解析,来获取是什么设备。 (1)在Rails项目中,要用到useragent 这个gem 包( https://github.com/josh/useragent )。输入终端命令: gem install useragent (2)在rails项目的 Gemfile 中写入: gem 'useragent' (3) 输入终端命令: bundle install (4)获取user_agent : use…

2014-03-05 19:56 · Ruby \ Rails · 评论(0)

Paperclip 删除上传的图片 和 NotIdentifiedByImageMagickError

1.在成功安装ImageMagick了后对图片处理是出现下面错误: An error was received while processing: #<Paperclip::Errors::NotIdentifiedBy ImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError> 错误解决:在Rails项目的config/environments/development.rb文件加入: Paperclip.options[:command_path] = '/opt/local/bin/' #Mac OS 下 然…

2014-03-01 16:07 · Ruby \ Rails · 评论(0)

Rails 使用 Paperclip 上传图片

转移 http://aikin.me/2014/02/20/rails-paperclip/ Paperclip是 Rails 的一个上传图片插件,它和ImageMagick联合使用,可以很方便的实现图片上传并切割指定大小的功能,使整个图片上传过程非常简单,还会将上传的图片保存在public文件夹下。 1.下载paperclip gem包 (1)在Gemfile中写上 gem 'paperclip' (2)在终端运行 bundle install 2.使用paperclip (1)在终端输入: rails g paperclip image_news image 这样就会在原先的 image…

2014-02-20 15:42 · Ruby \ Rails · 评论(0)

View从加载到显示调用方法的顺序

- (id)init { self = [super init]; if (self) { NSLog(@"0"); } return self; } - (void)viewDidLoad { [superviewDidLoad]; NSLog(@"1"); } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; NSLog(@"2"); } - (void)viewWillLayoutSubviews { [superviewWillLayoutSubviews]; NSLog(@"3"); }…

2014-02-19 21:46 · iOS · 评论(0)

Cocoapods error Could not read from remote repository.

在终端运行 pod install 出现下面error [!] Pod::Executable pull Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 解决方法,在终端输入: gem update --system 接着在输入: sudo gem install cocoapods

2014-02-12 20:37 · iOS · 评论(0)

ActiveModel::ForbiddenAttributesError 错误。

在用户点击注册按钮是 出现 错误 ActiveModel::ForbiddenAttributesError 解决方法一: def create @user = User.new(params[:user]) // 这是被提示有错误。 if @user.save cookies.permanent[:token] = @user.token redirect_to :user_welcome return end render :register end 解决方法, 首先在 user Model中 加入: attr_accessible :name, :password, :password…

2014-01-24 14:32 · Ruby \ Rails · 评论(0)