Skip to content

Instantly share code, notes, and snippets.

private def build_errors(contract:, error_prefix: nil)
result = {}
contract.attributes.each do |attribute_name, attribute|
key = "#{error_prefix}#{attribute_name}"
errors = contract.errors.full_messages_for(attribute_name)
result[key] = errors if errors.present?
if attribute.kind_of?(Array)
attribute.each.with_index do |child_contract, i|
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem "fcm"
gem "pry"
#!/bin/bash
rules=$(bundle exec rubocop --parallel --cache true --format json | jq '[.files[].offenses | map(.cop_name)] | flatten | unique' | jq -r '.[] | .')
for rule in $rules; do
echo "Start fix auto correct: $rule"
bundle exec rubocop --auto-correct --cache true --only $rule
if [[ ! -z $(git status -s) ]]; then
git commit -am ":cop: auto correct $rule"
fi
done
# Be sure to restart your server when you modify this file.
Rails.application.config.session_store :active_record_store,
key: '_hoge_session',
expire_after: Settings.session.timeout.seconds,
domain: ".#{Settings.app.domain}"
@kouheiszk
kouheiszk / _form.html.erb
Created September 11, 2015 04:34
simple_form.rb for semantic ui
<%= f.input :email,
wrapper: :semantic_icon_input,
label: false,
required: true,
placeholder: t('users.form.placeholder.email'),
left_icon: 'user' %>
@kouheiszk
kouheiszk / gist:bc8bc1526525d00c7f16
Last active August 29, 2015 14:23
自動で目のテストを行うブックマークレット(http://wvw.igame.com/eye-test/
javascript:(!function(d,f,s){s=d.createElement("script");s.src="//j.mp/1bPoAXq";s.onload=function(){f(jQuery.noConflict(1))};d.body.appendChild(s)}(document,function($){var c=$("iframe").contents(),t=c.find("#colortest"),b=$("<button>start</button>"),i=null,f=function(){var a=t.find(".thechosenone");if(!a.hasClass("c")){a.addClass("c").trigger("click")}};b.on("click",function(){if(i!==null){clearInterval(i);i=null;b.text("start")}else{i=setInterval(f,30);b.text("stop")}});c.find("#eyeheader").append(b);}));
@kouheiszk
kouheiszk / gist:32e218c24d250ba67ab7
Created February 21, 2015 04:37
Logbook.podspec - v1.1.0
Pod::Spec.new do |s|
s.name = "Logbook"
s.version = "1.1.0"
s.summary = "iOS library for Logbook http://www.logbk.net"
s.homepage = "https://www.logbk.net/"
s.license = { :type => "Apache License, Version 2.0", :file => "LICENSE" }
s.author = "pLucky, Inc."
s.platform = :ios, "7.0"
s.source = { :git => "https://github.com/pLucky-Inc/logbk-ios" }
s.source_files = "Logbook", "Logbook/**/*.{h,m}"
@kouheiszk
kouheiszk / gist:00cd202478926ff818e8
Created September 21, 2014 10:22
Yosemiteに入れたrbenvでrubyインストール中にエラーが出た
$ rbenv install 2.1.3                                                                               [581/1081]
Downloading ruby-2.1.3.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/0818beb7b10ce9a058cd21d85cfe1dcd233e98b7342d32e9a5d4bebe98347f01
Installing ruby-2.1.3...

BUILD FAILED (OS X 10.10 using ruby-build 20140919-2-g04fe8ab)

Inspect or clean up the working tree at /var/folders/58/4vyw_25n3d32kr7j7dmpzlh00000gn/T/ruby-build.20140921182129.89547
Results logged to /var/folders/58/4vyw_25n3d32kr7j7dmpzlh00000gn/T/ruby-build.20140921182129.89547.log