Skip to content

Instantly share code, notes, and snippets.

View nakaearth's full-sized avatar

Nakamura shinichirou nakaearth

View GitHub Profile
@nakaearth
nakaearth / Stamp.rb
Last active December 14, 2015 13:58
Stamp.rbのPaperclipのサンプル抜粋
class Stamp < ActiveRecord::Base
####途中省略####
if Rails.env.production?
S3_CREDENTIALS={access_key_id:ENV['S3_ACCESS_KEY_ID'], secret_access_key:ENV['S3_SECRET_KEY'], bucket:"hoge-bucket"}
end
if Rails.env.production?
has_attached_file :stamp, storage: :s3, s3_credentials: S3_CREDENTIALS,
styles: {stamps_s:"100x100&gt;",stamps:"350x350&gt;"},url:":s3_domain_url",path:"stamps/:style/:filename"
else
has_attached_file :stamp, url: "/:style/:img_dir_num/:filename" , styles: {stamps_s:"100x100&gt;",stamps:"350x350&gt;"}
class Stamp < ActiveRecord::Base
Paperclip.interpolates :img_dir_num do |attachment, style|
(attachment.instance.id * 0.01).to_i
end
Paperclip.interpolates :filename do |attachment, style|
attachment.instance.id.to_s + ".png"
end
if Rails.env.production?
S3_CREDENTIALS = {access_key_id: ENV['S3_ACCESS_KEY_ID'], secret_access_key: ENV['S3_SECRET_KEY'], bucket: "hoge-bucket"}
end
@nakaearth
nakaearth / access.yml
Last active December 15, 2015 03:09
アクセス制限を書ける時に使うymlファイルの例
localhost: &localnet
/admin/user:
- 192.168.111.22
development:
<<: *localnet
test:
<<: *localnet
production:
/admin/point:
- 56.2.107.111
private
def update_params
params.require(:hoge).permit(:title, :description, :priority, :status)
end
one:
id: 1
title: 'MyString'
stamp_aws_id: 1
usertokenid: 'testaaaa1111'
downloadcount: 10
category: 'words'
rank_display_flag: 0
stamp_file_name: 'test.jpg'
stamp_content_type: 'jpg'
var testCtrl = function($scope) {
$scope.users = [
{"name": "nakamura", "point": "10"},
{"name": "hoge", "point": "20"},
{"name": "ugaugo", "point": "200"},
];
}
@nakaearth
nakaearth / index.html
Last active December 30, 2015 18:38
ブログ用のサンプルコード
<!DOCTYPE HTML>
<html ng-app>
<head>
<script src="assets/application.js"></script>
<script src="js/testScript.js"></script>
</head>
<body>
<div>
<label>Name:</label>
<input type="text" ng-model="yourName" placeholder="Enter a name here">
@nakaearth
nakaearth / events_controller.rb
Last active December 30, 2015 21:09
ブログのサンプル
class EventsController < ApplicationController
def index
@events = Event.all
render json: @events
end
end
@nakaearth
nakaearth / seeds.rb
Last active December 30, 2015 21:09
ブログネタ初期データ投入
#coding: utf-8
Event.create(title: '忘年会', description: '会社の忘年会をします')
Event.create(title: 'クリスマス会', description: '家族でクリスマス会をします。')
Event.create(title: '子供と出かける日', description: '子供を連れて、買い物に行きます')
@nakaearth
nakaearth / events.js.coffee
Last active December 30, 2015 21:09
ブログのサンプルコード
App.factory 'Events', ['$resource', ($resource) ->
$resource '/events/index'
]