This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# require https://github.com/ichord/Caret.js | |
$target = $('#post_body') | |
insertText = "Hello World" | |
text = $target.val() | |
position = $target.caret('pos') | |
newText = text.substring(0, position) + insertText + text.substring(position) | |
$target.val(newText) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( 5/60): |vimshell| Error | |
/Users/takuyan/.vim/bundle/vimshell | |
/usr/local/Cellar/git/2.1.2/libexec/git-core/git-pull: line 11: git-sh-setup: No such file or directory | |
(37/60): |unite.vim| Error | |
/Users/takuyan/.vim/bundle/unite.vim | |
/usr/local/Cellar/git/2.1.2/libexec/git-core/git-pull: line 11: git-sh-setup: No such file or directory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ gem install spork | |
Building native extensions. This could take a while... | |
ERROR: Error installing spork: | |
ERROR: Failed to build gem native extension. | |
c:/ruby187/bin/ruby.exe mkrf_conf.rb | |
Actually, there aren't any native extensions. I'm just dynamically installing de | |
pendencies based off of your operating system | |
installing windows dependencies | |
Failed to install necessary dependency gem win32-process: ERROR: Failed to build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyClass | |
after_create :check_parent | |
def check_parent | |
self.parent.do_something | |
end | |
end | |
# spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#config/initializers/aws.rb | |
AWS::S3::DEFAULT_HOST.replace "s3-ap-northeast-1.amazonaws.com" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/s3.yml | |
development: | |
bucket: sample-dev | |
access_key_id: xxxxxxxxxxxxxxxx | |
secret_access_key: yyyyyyyyyyyyyyyyy | |
region: tokyo | |
production: | |
bucket: sample-production | |
access_key_id: iiiiiiiiiiiiiiiii | |
secret_access_key: jjjjjjjjjjjjjjjjj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/figure.rb | |
class Figure < ActiveRecord::Base | |
has_attached_file :image, | |
:styles => { :medium => "300x300>", :thumb => "100x100>" }, | |
:storage => :s3, | |
:s3_host_name => "s3-us-west-1.amazonaws.com", | |
:s3_credentials => "#{Rails.root}/config/s3.yml", | |
:path => ":attachment/:id/:style/:filename" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Paperclip | |
module Storage | |
module S3 | |
# | |
# ... | |
# | |
@s3_host_name = @options[:s3_host_name] || @s3_credentials[:s3_host_name] | |
# | |
# ... | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/s3.yml | |
development: | |
bucket: sample-dev | |
access_key_id: xxxxxxxxxxxxxxxx | |
secret_access_key: yyyyyyyyyyyyyyyyy | |
s3_host_name: s3-ap-northeast-1.amazonaws.com | |
production: | |
bucket: sample-production | |
access_key_id: iiiiiiiiiiiiiiiii | |
secret_access_key: jjjjjjjjjjjjjjjjj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/medium.rb | |
has_many :stories | |
# app/models/stories.rb | |
belongs_to :medium | |
scope :newer, order("created_at desc") | |
scope :entries, where("entry = ?", true) |
OlderNewer