Skip to content

Instantly share code, notes, and snippets.

View jacoyutorius's full-sized avatar
🏠
Working from home

jacoyutorius jacoyutorius

🏠
Working from home
View GitHub Profile
@jacoyutorius
jacoyutorius / file0.txt
Last active August 29, 2015 14:10
Paperclipでアップロードするファイルのcontent_typeの確認方法 ref: http://qiita.com/jacoyutorius/items/ce7902f8502d35818cf8
file -I sample-excel.xls
sample-excel.xls: application/vnd.ms-excel; charset=binary
@jacoyutorius
jacoyutorius / file0.txt
Last active August 29, 2015 14:09
Amazon S3 Event Notificationsを設定してみる ref: http://qiita.com/jacoyutorius/items/fb10b2d2134d9d37fdc2
"Condition": {
"ArnLike": {
"aws:SourceArn": "arn:aws:s3:*:*:s3-event-test"
}
@jacoyutorius
jacoyutorius / Gemfile
Last active August 29, 2015 14:07
Rails4.0から4.1に移行する。Rubyも2.0から2.1に上げる ref: http://qiita.com/jacoyutorius/items/1137129fb0242214cb99
ruby "2.1.2"
gem 'rails', '4.1'
@jacoyutorius
jacoyutorius / Gemifle
Last active August 29, 2015 14:07
ユーザーの行動履歴をMongoDBに保存する ref: http://qiita.com/jacoyutorius/items/c31305f9f577edd3ffa1
gem "mongoid"
gem "bson_ext"
@jacoyutorius
jacoyutorius / file0.txt
Last active August 29, 2015 14:07
CentOSにMongoDBをインストールして外部から接続できるようにする ref: http://qiita.com/jacoyutorius/items/3e2cf2c098029e8d4a06
cat /etc/redhat-release
Scientific Linux release 6.5 (Carbon)
@jacoyutorius
jacoyutorius / anonymous_controller.rb
Last active August 29, 2015 14:07
Controllerを作らずにViewを表示したい ref: http://qiita.com/jacoyutorius/items/97cf87d36807d00b883b
class AnonymousController < ApplicationController
def index
render "#{params[:directory]}/index"
end
end
@jacoyutorius
jacoyutorius / file0.rb
Created September 30, 2014 03:11
【Rails】Paperclipで保存した画像のサムネイルの取得方法 ref: http://qiita.com/jacoyutorius/items/6844e72ece23dcac8560
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.integer :name
t.attachment :icon
end
end
end
@jacoyutorius
jacoyutorius / file1.txt
Created September 26, 2014 03:04
Ransackで日付型のFrom-To検索をする ref: http://qiita.com/jacoyutorius/items/cf371bc449402a2676fa
Item.search(:created_at_gteq => "2014-09-10", :created_at_lteq => "2014-09-25").result.to_sql
=> "SELECT `items`.*
FROM `items`
WHERE ((`items`.`created_at` >= '2014-09-10 00:00:00'
AND `items`.`created_at` <= '2014-09-25 00:00:00'))"
@jacoyutorius
jacoyutorius / cli.rb
Created August 22, 2014 06:54
RubyでオレオレCLIツールを作って大人しめに公開する ref: http://qiita.com/jacoyutorius/items/7df32a1653b5572adbc0
require "oreore"
require "thor"
module Oreore
class CLI < Thor
desc "hello", "say 'hello world!'."
def hello
puts "Hello World!"
end
end
@jacoyutorius
jacoyutorius / index.html.erb
Created August 18, 2014 12:34
Rails4でSubmitボタンにFontAwesomeのアイコンを埋め込む ref: http://qiita.com/jacoyutorius/items/c73327f049ee5270d505
<%= button_tag :type => "submit", :class =>"btn btn-default btn-s-md" do %>
<i class="fa fa-search"></i>検索
<% end %>
<%= button_tag sanitize('<i class="fa fa-search"></i>検索'), :type => "submit",
:class =>"btn btn-default btn-s-md" %>
<%= button_tag '<i class="fa fa-search"></i>検索'.html_safe, :type => "submit",