Skip to content

Instantly share code, notes, and snippets.

View bluerabbit's full-sized avatar
🤠
spark joy

Akira Kusumoto bluerabbit

🤠
spark joy
View GitHub Profile
@bluerabbit
bluerabbit / gist:2786657
Created May 25, 2012 08:37
Rubyでmoduleを作る場合はActiveSupport::Concernをextendする
module M
extend ActiveSupport::Concern
module ClassMethods
def cm; puts 'I am a class method'; end
end
module InstanceMethods
def im; puts 'I am an instance method'; end
@bluerabbit
bluerabbit / gist:2995714
Created June 26, 2012 13:10
youRoomの書き込むテキストエリアが動的に変わればいいのに
$('.entry_content').scroll(function () {
var self = $(this);
self.css('height', (parseInt(self.css('height').slice(0,-2)) + 10) + 'px');
});
@bluerabbit
bluerabbit / gist:4212095
Created December 5, 2012 04:01
String.true?欲しい
class String
def true?
self == 'true' || self == '1'
end
def false?
self == 'false' || self == '0'
end
end
@bluerabbit
bluerabbit / gist:4257941
Created December 11, 2012 11:37
fogを使ってS3にファイルをアップロードする
require 'rubygems'
require 'fog'
# https://aws-portal.amazon.com/gp/aws/developer/account/index.html?action=access-key
YOUR_AWS_ACCESS_KEY_ID='your_key'
YOUR_AWS_SECRET_ACCESS_KEY='your_key'
connection = Fog::Storage.new({
:provider => 'AWS',
:aws_access_key_id => YOUR_AWS_ACCESS_KEY_ID,
@bluerabbit
bluerabbit / gist:4316542
Created December 17, 2012 08:03
AWS IAMで特定のbucketにのみアクセス可能なPermissions Policy https://console.aws.amazon.com/iam/home 参考) http://blog.dateofrock.com/2011/04/s3iam.html
{
"Statement": [
{
"Sid": "Stmt1355727169912",
"Action": [
"s3:ListAllMyBuckets"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::*"
},
@bluerabbit
bluerabbit / gist:4381079
Created December 26, 2012 16:02
一行づつゆっくり順にli spanを表示していくアニメーションをfor文で実行できるように
function animationPipe(queue, element) {
return $.when(queue).pipe(function(){
return $(element).fadeIn(800);
});
};
var spanList = $('li span').hide();
var queue = $.Deferred().resolve();
for (var i = 0; i < spanList.length; i++) {
@bluerabbit
bluerabbit / gist:4441029
Created January 3, 2013 05:19
A Solution to AJAX errors with Capybara against a jQuery site
def wait_for_ajax(timeout = Capybara.default_wait_time)
page.wait_until(timeout) do
page.evaluate_script 'jQuery.active == 0'
end
end
@bluerabbit
bluerabbit / gist:4584817
Created January 21, 2013 09:22
rspecで実行中かを判定する方法
def rspec?
__FILE__ != $0
end
@bluerabbit
bluerabbit / gist:4618333
Created January 24, 2013 07:27
RDSで誰もが一度ハマるcharacter_set_database latin1をutf8にする
>show variables like 'character_set_database';
+--------------------------+-------------------------------------------------------+
| Variable_name | Value |
+--------------------------+-------------------------------------------------------+
| character_set_database | latin1 |
+--------------------------+-------------------------------------------------------+
>alter database {database_name} default character set utf8;
@bluerabbit
bluerabbit / gist:4680876
Created January 31, 2013 06:55
homebrewでtomcat6をインストール
% brew tap homebrew/versions
% brew install tomcat6