Share Code Quickly

What is Harigami?

Harigami is a simple source code sharing service. You can share source code by an URL which is issued after submission.
You can also run your source code online such as Python, Ruby, JavaScript and so on.
For free.Use for code review.
Preferences
anonymous No title
Ruby
class Post < ApplicationRecord
	mount_uploader :image, ImageUploader
	validates :body, presence: true
	validates :title, presence: true
	belongs_to :user
	has_many :likes,dependent: :destroy
	has_many :liked_users, through: :likes, source: :user,dependent: :destroy
	is_impressionable counter_cache: true
	has_many :comments,dependent: :destroy
	has_many :star, dependent: :destroy

	 #ratyrate_rateable "title"
# def self.search(search)
# 	 if search
#        where(['username LIKE ?', "%#{search}%"]) #検索とuseanameの部分一致を表示。
#      else
#        all #全て表示させる
#     end
#  end

end
anonymous No title
Ruby
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2019_11_06_084855) do

  create_table "average_caches", force: :cascade do |t|
    t.integer "rater_id"
    t.string "rateable_type"
    t.integer "rateable_id"
    t.float "avg", null: false
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.index ["rateable_type", "rateable_id"], name: "index_average_caches_on_rateable_type_and_rateable_id"
    t.index ["rater_id"], name: "index_average_caches_on_rater_id"
  end

  create_table "comments", force: :cascade do |t|
    t.string "content"
    t.integer "user_id"
    t.integer "post_id"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.integer "star"
    t.index ["post_id"], name: "index_comments_on_post_id"
    t.index ["user_id"], name: "index_comments_on_user_id"
  end

  create_table "impressions", force: :cascade do |t|
    t.string "impressionable_type"
    t.integer "impressionable_id"
    t.integer "user_id"
    t.string "controller_name"
    t.string "action_name"
    t.string "view_name"
    t.string "request_hash"
    t.string "ip_address"
    t.string "session_hash"
    t.text "message"
    t.text "referrer"
    t.text "params"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.index ["controller_name", "action_name", "ip_address"], name: "controlleraction_ip_index"
    t.index ["controller_name", "action_name", "request_hash"], name: "controlleraction_request_index"
    t.index ["controller_name", "action_name", "session_hash"], name: "controlleraction_session_index"
    t.index ["impressionable_type", "impressionable_id", "ip_address"], name: "poly_ip_index"
    t.index ["impressionable_type", "impressionable_id", "params"], name: "poly_params_request_index"
    t.index ["impressionable_type", "impressionable_id", "request_hash"], name: "poly_request_index"
    t.index ["impressionable_type", "impressionable_id", "session_hash"], name: "poly_session_index"
    t.index ["impressionable_type", "message", "impressionable_id"], name: "impressionable_type_message_index"
    t.index ["user_id"], name: "index_impressions_on_user_id"
  end

  create_table "likes", force: :cascade do |t|
    t.integer "post_id"
    t.integer "user_id"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.index ["post_id"], name: "index_likes_on_post_id"
    t.index ["user_id"], name: "index_likes_on_user_id"
  end

  create_table "mypages", force: :cascade do |t|
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.string "image"
  end

  create_table "overall_averages", force: :cascade do |t|
    t.string "rateable_type"
    t.integer "rateable_id"
    t.float "overall_avg", null: false
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.index ["rateable_type", "rateable_id"], name: "index_overall_averages_on_rateable_type_and_rateable_id"
  end

  create_table "posts", force: :cascade do |t|
    t.string "title"
    t.text "body"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.integer "user_id"
    t.string "image"
    t.integer "impressions_count"
  end

  create_table "rating_caches", force: :cascade do |t|
    t.string "cacheable_type"
    t.integer "cacheable_id"
    t.float "avg", null: false
    t.integer "qty", null: false
    t.string "dimension"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.index ["cacheable_type", "cacheable_id"], name: "index_rating_caches_on_cacheable_type_and_cacheable_id"
  end

  create_table "users", force: :cascade do |t|
    t.string "email", default: "", null: false
    t.string "encrypted_password", default: "", null: false
    t.string "reset_password_token"
    t.datetime "reset_password_sent_at"
    t.datetime "remember_created_at"
    t.string "confirmation_token"
    t.datetime "confirmed_at"
    t.datetime "confirmation_sent_at"
    t.string "unconfirmed_email"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.boolean "admin", default: false
    t.string "name"
    t.boolean "accepted", default: false, null: false
    t.index ["email"], name: "index_users_on_email", unique: true
    t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
  end

end
anonymous No title
JavaScript
const number = numbers.filter((number)
anonymous No title
HTML
<!-- SAMPLE 01 -->
<div class="p-dropdown">
  <button class="p-dropdown__button js-dropdown-button" type="button" aria-controls="drop_contents_01" aria-expanded="false">〇〇のコンテンツについて見る</button>
  <div id="drop_contents_01" class="p-dropdown__contents js-dropdown-content" aria-hidden="true">
    〇〇のコンテンツ
  </div>
</div>

<!-- SAMPLE 02 -->
<div class="p-dropdown" aria-expanded="false">
  <button class="p-dropdown__button js-dropdown-button" type="button">△△のコンテンツについて見る</button>
  <div id="drop_contents_02" class="p-dropdown__contents js-dropdown-content" aria-hidden="true">
    △△のコンテンツ
  </div>
</div>
anonymous No title
HTML
<div class="p-dropdown">
  <button class="p-dropdown__button" type="button" aria-controls="drop_contents" aria-expanded="false">タブ</button>
  <div id="drop_contents" class="p-dropdown__contents" aria-hidden="true">
    コンテンツ内容
  </div>
</div>
anonymous No title
HTML
<div class="p-dropdown">
  <button class="p-dropdown__button" type="button" aria-controls="drop_contents" aria-expanded="false">タブ</button>
  <div id="drop_contents" class="p-dropdown__contents" aria-hidden="true">
    コンテンツ内容
  </div>
</div>
anonymous No title
Ruby
class CommentsController < ApplicationController
	def create
		@comment = Comment.new(comment_params)
		@comment.user_id = current_user.id
		if @comment.save!
			redirect_back(fallback_location: root_path)
		else
			redirect_back(fallback_location: root_path)

		end
	end

	private
	def comment_params
		params.require(:comment).permit(:content)
	end
end
anonymous No title
HTML
class CommentsController < ApplicationController
	def create
		@comment = Comment.new(comment_params)
		@comment.user_id = current_user.id
		if @comment.save!
			redirect_back(fallback_location: root_path)
		else
			redirect_back(fallback_location: root_path)

		end
	end

	private
	def comment_params
		params.require(:comment).permit(:content)
	end
end
ガンマ@駆け出しエンジニア MTF-RSI-MACROSS
Python
//@version=4
study("MTF-RSI-MACROSS", overlay=false)
src = close
RMA = input(20, minval=1, title="MA期間")
RMA2 = input(20, minval=1, title="MA期間2")
RMA3 = input(20, minval=1, title="MA期間3")
len = input(title='時間軸', type=input.resolution, defval="5")
len2 = input(title='時間軸2', type=input.resolution, defval="15")
len3 = input(title='時間軸3', type=input.resolution, defval="60")
res = input(defval=true, title="チェック=MTF表示")
res3 = input(defval=true, title="チェック=MTF表示2")
res5 = input(defval=true, title="チェック=MTF表示3")
res2 = res ? len : timeframe.period
res4 = res3 ? len2 : timeframe.period
res6 = res5 ? len3 : timeframe.period
length = input(14, minval=1, title="RSI期間")
length2 = input(14, minval=1, title="RSI期間2")
length3 = input(14, minval=1, title="RSI期間3")
price = close
rsi=rsi(price, length)
vrsi = security(syminfo.tickerid, res2, rsi)
smaRSI = sma(vrsi, RMA)
emaRSI = ema(vrsi, RMA)
vrsi2 = security(syminfo.tickerid, res4, rsi(price, length2))
smaRSI2 = sma(vrsi2, RMA2)
emaRSI2 = ema(vrsi2, RMA2)
vrsi3 = security(syminfo.tickerid, res6, rsi(price, length3))
smaRSI3 = sma(vrsi3, RMA3)
emaRSI3 = ema(vrsi3, RMA3)
sig1 = crossover(emaRSI , smaRSI)
sig2 = crossover(emaRSI2 , smaRSI2)
sig3 = crossover(emaRSI3 , smaRSI3)
sig4 = crossunder(emaRSI , smaRSI)
sig5 = crossunder(emaRSI2 , smaRSI2)
sig6 = crossunder(emaRSI3 , smaRSI3)
sig7 = emaRSI > smaRSI
sig8 = emaRSI2 > smaRSI2
sig9 = emaRSI3  > smaRSI3
p1 = plot(4, color=color.black, editable=false, trackprice=false)
p2 = plot(3, color=color.black, editable=false, trackprice=false)
p3 = plot(2, color=color.black, editable=false, trackprice=false)
p4 = plot(1, color=color.black, editable=false, trackprice=false)
fill(p1, p2, color=sig1 ? color.lime : na , title="短期GC", transp=20)
fill(p2, p3, color=sig2 ? color.lime : na, title="中期GC", transp=20)
fill(p3, p4, color=sig3 ? color.lime : na, title="長期GC", transp=20)
fill(p1, p2, color=sig4 ? color.red : na , title="短期DC", transp=20)
fill(p2, p3, color=sig5 ? color.red : na, title="中期DC", transp=20)
fill(p3, p4, color=sig6 ? color.red : na, title="長期DC", transp=20)
fill(p1, p2, color=sig7 ? color.lime : color.red , title="短期BG", transp=80)
fill(p2, p3, color=sig8 ? color.lime : color.red, title="中期BG", transp=80)
fill(p3, p4, color=sig9 ? color.lime : color.red, title="si長期BG", transp=80)
alertcondition(sig1, title="短LONG", message="短期L")
alertcondition(sig4, title="短SHORT", message="短期S")
alertcondition(sig2, title="中LONG", message="中期L")
alertcondition(sig5, title="中SHORT", message="中期S")
alertcondition(sig3, title="長LONG", message="長期L")
alertcondition(sig6, title="長SHORT", message="長期S")
pk-hangjing No title
Python
//@version=3
study('Moving Average 4Line', overlay=true)
emaOrSma = input(title="EMA or SMA?", defval="EMA", options=["EMA", "SMA"])
maPeriodFast_1 = input(title="MA Period Fast 1", type=integer, defval=25, minval=1, maxval=10000)
maPeriodFast_2 = input(title="MA Period Fast 2", type=integer, defval=75, minval=1, maxval=10000)
maPeriodSlow_1 = input(title="MA Period Slow 1", type=integer, defval=100, minval=1, maxval=10000)
maPeriodSlow_2 = input(title="MA Period Slow 2", type=integer, defval=200, minval=1, maxval=10000)
showPerfectOrder = input(title="Show Perfect Order?", type=bool, defval=true)
fast_1 = emaOrSma == "EMA" ? ema(close, maPeriodFast_1) : sma(close, maPeriodFast_1)
fast_2 = emaOrSma == "EMA" ? ema(close, maPeriodFast_2) : sma(close, maPeriodFast_2)
slow_1 = emaOrSma == "EMA" ? ema(close, maPeriodSlow_1) : sma(close, maPeriodSlow_1)
slow_2 = emaOrSma == "EMA" ? ema(close, maPeriodSlow_2) : sma(close, maPeriodSlow_2)
perfectOrderByUpTrend = fast_1[1] > fast_2[1] and fast_2[1] > slow_1[1] and slow_1[1] > slow_2[1] ? true : false
perfectOrderByDownTrend = fast_1[1] < fast_2[1] and fast_2[1] < slow_1[1] and slow_1[1] < slow_2[1] ? true : false
plot(fast_1, color=orange)
plot(fast_2, color=red)
plot(slow_1, color=blue)
plot(slow_2, color=green)
bgcolor(perfectOrderByUpTrend and showPerfectOrder ? green : white, transp=90, offset=-1)
bgcolor(perfectOrderByDownTrend and showPerfectOrder ? orange : white, transp=90, offset=-1)