Skip to content

Instantly share code, notes, and snippets.

@ecpplus
ecpplus / production.rb
Created November 21, 2010 17:56
Nginx X-Accel-Redirect with Rails
# Only for Rails3
# config.action_dispatch.x_sendfile_header = 'X-Sendfile'
config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
@ecpplus
ecpplus / gist:713124
Created November 24, 2010 04:42
Cocos2d(0.99.4) - CCRepeatForever having interval.
id delaying = [CCDelayTime actionWithDuration:1.5f]; // duration is second, not millsecond.
id sequence = [CCSequence actions:someAction, delaying, nil];
CCRepeatForever *repeatAction = [CCRepeatForever actionWithAction:sequence];
[aSprite runAction:repeatAction];
@ecpplus
ecpplus / gist:713131
Created November 24, 2010 04:51
Cocos2d(0.99.4) create animation by CCSpriteSheet
CCSpriteSheet *animationSheet = [CCSpriteSheet spriteSheetWithFile:@"animation_sheet.png"];
[self addChild:animationSheet];
CCSprite *animationSprite = [CCSprite spriteWithTexture:animationSheet.texture
rect:CGRectMake(0, 0, 256, 290)];
animationSprite.position = ccp(self.contentSize.width / 2, self.contentSize.height / 2);
[animationSheet addChild:animationSprite];
CCAnimation *animation = [CCAnimation animationWithName:@"an_animation" delay:0.04f];
@ecpplus
ecpplus / gist:861577
Created March 9, 2011 02:30
will_paginateで出力されるページネーションの日本語化
# -*- coding:utf-8 -*-
# will_paginateで出力されるページネーションの日本語化
WillPaginate::ViewHelpers.pagination_options = {
:class => 'pagination',
:previous_label => '«前へ',
:next_label => '次へ»',
:inner_window => 4, # links around the current page
:outer_window => 1, # links around beginning and end
:separator => ' ', # single space is friendly to spiders and non-graphic browsers
:param_name => :page,
@ecpplus
ecpplus / Rakefile
Created August 3, 2011 09:52
uninitialized constant Rake::DSL error
require File.expand_path('../config/application', __FILE__)
require 'rake/dsl_definition' # add this
require 'rake'
@ecpplus
ecpplus / gist:1122324
Created August 3, 2011 10:13
Google+ button doesn't work on IE
<!-- this doesn't work on IE (Google default) -->
<g:plusone size="medium"></g:plusone>
<!-- this works -->
<div class="g-plusone" data-size="small" data-count="true"></div>
<!-- without plus count -->
<div class="g-plusone" data-size="small" data-count="false"></div>
@ecpplus
ecpplus / new.html.erb
Created September 13, 2011 17:36
Railsで1つのformで複数のインスタンスを処理する時
<%= form_for :users, :url => {:action => :create_multi}, :html => {:method => :post} do |f| %>
<% 0.upto(3) do |i| %>
<%= f.text_field :name, :index => i + 1 %>
<% end %>
<%= f.submit 'upload' %>
<% end %>
@ecpplus
ecpplus / new.html.erb
Created September 13, 2011 17:39
Railsでファイルアップロードするとき
<%= form_for :user, :url => {:action => :create}, :html => {:method => :post, :multipart => true} do |f| %>
<%= f.text_filed :name %>
<%= f.file_filed :image %>
<% end %>
@ecpplus
ecpplus / Gemfile
Created September 13, 2011 17:47
Rails3.0.x to Rails3.1.0
gem 'rails', '3.1.0'
...
# add for assets
gem 'sass'
gem 'coffee-script'
gem 'uglifier'
gem 'jquery-rails'
@ecpplus
ecpplus / Gemfile
Created September 14, 2011 07:52
[Rails] fix `autodetect': Could not find a JavaScript runtime. error
gem 'therubyracer' # add this