自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 rails naming rule

记住rails的命名规则,只有table的命名是加S的。  

2014-08-01 15:45:08 133

原创 [crontab] 在bash中加载cron环境以进行debug

自动加载crontab的运行env,并在bash中加载crontab的环境,对script进行测试http://stackoverflow.com/questions/2135478/how-to-simulate-the-environment-cron-executes-a-script-withAdd this to your cron:30 08 * * * env >...

2013-09-18 16:59:44 260

原创 [CSS] 学习笔记float

float 属性定义元素在哪个方向浮动。  float主要的用途:1 图片周围包围文字 (类似于word编辑中得图片浮动效果,除了图片本身占据的位置用来显示,其他位置都被其他元素占据了)2 浮动可用于创建全部网页布局,例如sidebar    float造成的效果:1 自身向左(右)浮动2 因为自身的浮动,导致下面一行的元素跳到上面一行。3 要消除...

2013-09-02 15:56:47 163

原创 [HTML] Meta tag viewpoint

Meta tag viewpoint   简易的 cross-device layout 方法<meta name="viewport" content="width=device-width, initial-scale=1">

2013-09-02 15:55:31 129

原创 [HTML] Form method: Get and Post

Notes on GET: Appends form-data into the URL in name/value pairsThe length of a URL is limited (about 3000 characters)Never use GET to send sensitive data! (will be visible in the URL)Usefu...

2013-09-02 15:54:46 87

原创 [CSS] 伪元素after和属性position:absolute以及display:block之间的关系

为什么after伪元素之后content无法应用高度和宽度? 1) 想要给after的内容加上大于字体本身的宽度和高度,并给加上背景色<div class='test'></div> .test {width:100px;height:100px;background: green;} .test:after {cont...

2013-09-02 15:51:45 1165

原创 javascript/ jQuery Best Practise

 JS代码的良好的结构   https://tutsplus.com/lesson/slides-and-structure/             理解 JS 的 new 和 prototype     普通创建对象var person = new Object();person.firstName = "John";person...

2013-07-24 17:25:16 75

原创 nginx +unicorn + gollum 搭建 wiki

STEP 1 创建一个新用户,用户文件夹权限755 STEP 2 检查现有系统,关闭Apache的httpd服务,如果有 STEP 3 更新yum,安装gollum要求的gem      --->https://github.com/gollum/gollum STEP 4 新建一个wiki directory, 并 git init . & commi...

2013-05-24 17:29:01 281

原创 nginx配置

Nginx  Nginx如何处理一个请求   http://nginx.org/cn/docs/http/request_processing.html Nginx 配置文件  /etc/nginx/nginx.conf user nginx; # 使用该配置的用户,其他用户没有权限worker_pr...

2013-05-24 16:53:41 83

原创 Amazon Linux + Passenger + Nginx Module + Rails

版本信息:Amazon Linux    Paseenger   4.0.2Rails   3.2.13  STEP 1   新建一个rails用户,将用户权限改为755,以便于设置Nginx Root /app/public 不会产生permission deny的问题。public文件夹能够被所有用户访问是不够的,需要所有父文件夹都具有可执行权限。 sudo ...

2013-05-23 15:27:35 225

原创 Ruby进程(3) Process.fork 和 Ruby 1.9.2 中的新方法 Process.spawn的区别

简单来说:Process.spawn = Process.fork + exec  Process.fork allows you to run ruby code in another process. Process.spawn allows you to run another program in another process. Basically Process.spawn ...

2013-03-28 18:00:59 588

原创 Ruby线程

Thread.new([arg, ...]) { ... }Thread.start([arg, ...]) { ... }Thread.fork([arg, ...]) { ... }生成线程,并开始对块进行计算.参数会被原封不动地传递给块. 这就可以在启动线程的同时,将值传递给该线程所固有的局部变量.返回生成的线程. Thread.join 挂起当前线程,直到...

2013-03-28 17:55:32 85

原创 Ruby进程(2) Process创建和回收 --- Process.fork, Process.wait和Process.detach

 Process.fork{} 当block为空的时候,fork会返回2次结果,一次是在父进程中,返回子进程的pid,一次是在子进程中,返回nil。Creates a subprocess. If a block is specified, that block is run in the subprocess, and the subprocess terminates wi...

2013-03-28 17:47:13 900

原创 Ruby进程(1) Process.fork 和 Kernel#exec, Kernel#system and Backticks(%x) 比较(Linux)

1 同样都是创建子进程 Process.fork{ } 是非阻塞的执行,创建的子进程与父进程并发运行,需要使用Process.wait或者Process.detach来防止产生zommbie processKernel#exec, Kernel#system and Backticks(%x)阻塞的执行,调用者将等待被调用的返回 2 Kernel#exec, Kernel#...

2013-03-28 17:08:00 222

原创 require & require_relative

Ruby 1.9.x开始,require 同一文件夹中的文件提示 in `require': no such file to load 错误。 解决方式: 1、用 require_relative : require_relative 'xxx.rb' 2、往 $: 中加入目录路径: $:.unshift File.dirname __FILE__ ...

2013-03-19 10:31:20 242

原创 Reactor模式

  Reactor这个词译成汉语还真没有什么合适的,很多地方叫反应器模式,但更多好像就直接叫reactor模式了,其实我觉着叫应答者模式更好理解一些。通过了解,这个模式更像一个侍卫,一直在等待你的召唤,或者叫召唤兽。 并发系统常使用reactor模式,代替常用的多线程的处理方式,节省系统的资源,提高系统的吞吐量。 先用比较直观的方式来介绍一下这种方式的优点,通过和常用的多线程...

2013-03-14 13:19:43 77

原创 [Rails] Miniprofiler 性能检测

Step1    gem 'rack-mini-profiler' Step2    测量某一段代码 Rack::MiniProfiler.step("User Auth") do @users = User.all end Reference:http://railscasts.com/episodes/368-mini...

2013-03-13 17:38:46 106

原创 [rails] size, count 和length的区别

 #count方法总是会产生count(*)的SQL语句去查询数据库,而#length方法总是取查询出的集合的个数,它总是不会产生count(*)的查询,#size方法就比较好了,如果目标集合还没有取出来,它会像#count方法一样,产生count(*)的查询,如果记录已经取出来了,它就像#length方法一样,直接读取集合的个数了。  source:http://qichunren.i...

2013-03-13 16:35:40 319

原创 ruby $: 含义

http://kenbeit.com/posts/98/ruby小技巧之$:  一直能看到一些gem里面会有这样一句代码: $:.unshift File.expand_path('..', __FILE__)这句话是干什么用的呢$:就是ruby的一个全局变量,也叫$LOAD_PATH,功能就是java中的c...

2013-03-13 10:10:01 172

原创 Tell, don't ask 原则

Tell, don't ask 原则    Source:  http://www.aqee.net/tell-dont-ask/ 前些时间我曾经翻译过一篇叫做《这里我说了算!》的文章,里面作者讲述了关于“命令,不要去询问(Tell, Don’t Ask)”原则:我看到的最多被违反的原则是“命令,不要去询问(Tell, Don’t Ask)”原则。这个原则讲的是,一个对象应该...

2013-02-27 11:03:11 314

原创 Five Common Rails Mistakes

总结:1  数据库需要Validation,也就是给migration添加(t.integer "user_id", :null =>false),以保证即使在代码有错误的情况下,数据库也不被污染2  写面向对象的程序,而不仅仅是面向MVC的程序3  使用Content_tag  helper method,让html更加干净4  使用 find_each 代替 each ...

2013-02-25 17:25:17 147

原创 UIView画直线

http://2015.iteye.com/blog/1317567

2013-02-14 16:18:12 198

原创 Tableview 数据异步加载

1 LazyTableImages2 http://nsscreencast.com/episodes/6-afnetworking  AFNetworking 中的方法: [imageView setImageWithURL:[NSURL URLWithString:@"http://i.imgur.com/r4uwx.jpg"] placeholderImage:[UIIm...

2013-02-14 13:20:21 177

原创 Import csv file into CoreData

  - (void)importcsvintoCoreData{    //注意:文本内容需为UTF-8格式    //获取文件路径和文件内容    NSString *filePath = [[NSBundlemainBundle] pathForResource:@"Data"ofType:@"csv"];    NSLog( @"filePath: %@", f...

2013-02-08 13:45:20 78

原创 Crontab的使用方法

3种方式1 crobtab -e  当前用户环境下运行的cron2 sudo vi /etc/crontab    在系统环境下运行的cron,所有用户都可以使用3 /etc/cron.d/  将文件放在该目录下,系统则会自动运行 利用系统crontab来定时执行备份文件,按日期对备份结果进行保存,达到备份的目的。  1、创建保存备份文件的路径/mysqldata ...

2013-02-01 15:02:57 164

原创 shell之“>/dev/null 2>&1”

http://ppp1013.blog.51cto.com/927700/271043今天在自己的一个技术群中又被问道了这么一个问题,于是又通俗的解释了一下,做个记录,大家看看解释是否清楚!shell中可能经常能看到:>/dev/null 2>&1命令的结果可以通过%>的形式来定义输出分解这个组合:“>/dev/null 2>&1” ...

2013-02-01 14:22:06 57

原创 Rails form text_field

  <%= f.text_field :email , :value => session[:user_email], :readonly => true %>   可在params中传递email <%= f.text_field :email , :value => session[:user_email], :disabled=>t...

2013-01-30 18:30:05 280

原创 UIView(Transform)旋转后产生锯齿的问题

来源:http://blog.sina.com.cn/s/blog_796ffec50100y5ac.html UIView *view = [[UIView alloc]initWithFrame:CGRectMake(50, 50, 100, 100)]; CATiledLayer *tiled=(CATiledLayer *)[view layer]; ...

2013-01-22 13:57:49 496

原创 UIScrollView Paging Size 自定义每次ScrollView横向移动的距离

 http://stackoverflow.com/questions/6813270/uiscrollview-custom-paging-sizehttp://stackoverflow.com/questions/1220354/uiscrollview-horizontal-paging-like-mobile-safari-tabs/1373096#1373096

2013-01-22 13:21:09 393

原创 iOS记事本

Start with ios    http://www.appcoda.com/ios-programming-course/ Tableview中插入一行: http://blog.csdn.net/zhangkongzhongyun/article/details/7937062  在UITableView中动态的插入或删除行(或者节) 处理相机相片自动旋转问题h...

2013-01-22 13:16:34 179

原创 iOS与server交互

- (NSString *)loginConnection { NSString* returnValue = @""; //准备url NSString *host = [GlobalData getHostUrl]; NSString *urlstr = [host stringByAppendingString:@"login.json"]; ...

2013-01-22 13:16:17 99

原创 多线程GCD,UIActivityIndicatorView的等待画面

//在Login Lable上添加spinner UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; [spinner startAnimating];...

2013-01-17 11:18:34 97

原创 Customize UINavigationbar 和 改变图片大小

//加载NavigationBar的背景图片 UINavigationController *navController = [self navigationController]; UINavigationBar *navBar = [navController navigationBar]; CGSize navSize = CGSizeMake(nav...

2013-01-17 11:11:35 132

原创 Segue

[self performSegueWithIdentifier:@“AskAboutSnowboard” sender:self];- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@“DoAParticula...

2013-01-17 11:06:17 76

原创 delegate和Protocol

 Protocol 类似接口(interface), 但是由其他类实现 //定义Protocol@protocol UIScrollViewDelegate@optional- (UIView *)viewForZoomingInScrollView:(UIScrollView *)sender;- (void)scrollViewDidEndDragging:(U...

2013-01-17 10:43:45 48

原创 [iOS开发] TableView

 Dynamic TableView的使用方法1 设置TableView的delegate和dataSource(TableView has two important @propertys: its delegate and its dataSource. )2 声明实现这两个Delegate  <UITableViewDelegate, UITableViewDataSou...

2013-01-17 09:46:06 63

原创 Uploading images from an iPhone app to Rails

http://brainbowapps.com/articles/2010/uploading-files-from-iphone-to-rails.html

2012-12-26 18:07:55 65

原创 Ruby HTTP

Ruby 的标准 open-uri库仅支持get请求NET::HTTP 可以提供其他的方法 XML解析器ruby自带的标准xml解析器-REXML   具有一定严格性,能够拒绝一定的有错格式的xml,但不会严格到拒绝所有格式有错的xml如果只想接受良构的xml,得用libxml2如果希望处理有错得xml,最佳选择是 hpricot...

2012-11-30 17:40:19 68

原创 遇到困难的时候

不顺利的时候:1 忘记deadline,静下心,一行一行代码,一行一行文字,仔细阅读2 分解成最最细小的任务,一步一步完成

2012-11-19 14:58:05 99

原创 解决Jquery Mobile 不支持 file_field (上传文件)

Reason for file uploading problem with jQuery Mobile is that by default, form submits data using ajax. With Ajax, file input data is not submitted, and solution is very simple, just disable the ajax f...

2012-11-13 17:07:20 289

空空如也

空空如也

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

TA关注的人

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