Skip to content

Instantly share code, notes, and snippets.

@tkawa
tkawa / restful-towa-12.md
Created December 8, 2015 09:03
RESTful#とは勉強会12

RESTful#とは勉強会12 2015.12.08

質問はTwitterへ #RESTudy をつけてどうぞ。

「Webを支える技術」第10章 HTML

10.6 リンク (p.168)

第11章〜第13章

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tkawa
tkawa / _outline_buttons.scss
Created November 1, 2016 01:47
Bootstrap Outline Buttons
// Backports from Bootstrap 4
@mixin button-outline-variant($color, $color-hover: #fff) {
color: $color;
background-image: none;
background-color: white; // transparent is better?
border-color: $color;
&:hover {
color: $color-hover;
background-color: $color;
@tkawa
tkawa / i18n_exception_handler.rb
Created February 3, 2013 12:36
Railsでlocaleの翻訳が見つからなかったとき、“translation missing”はログに出して、viewにはhumanizeした文字列を出す
# config/initializers/i18n_exception_handler.rb
I18n.exception_handler = ->(exception, locale, key, options) do
if exception.is_a?(I18n::MissingTranslation)
Rails.logger.warn exception.message if Rails.env.development?
key.to_s.split('.').last.humanize
else
raise exception
end
end
@tkawa
tkawa / application_helper.rb
Created March 26, 2014 11:12
Railsのビューヘルパー内でHamlを使う
module ApplicationHelper
def render_thumbsup_button(options)
options[:url] ||= thumbsup_path
options[:method] ||= :put
options[:count] ||= 0
# ローカル変数を渡したいときのみ locals が必要
render inline: <<-HAML.strip_heredoc, type: :haml, locals: options
.thumbsup
= form_tag url, method: method do
%button.btn.btn-xs
@tkawa
tkawa / .rubocop.yml
Last active May 10, 2018 08:10
Rubocop settings
# cf.
# http://nttpc.now.tl/ac2014/?p=20#toc_4
# https://github.com/cookpad/styleguide/blob/master/ruby.ja.md
# https://gist.github.com/onk/38bfbd78899d892e0e83
# https://github.com/onk/onkcop/blob/master/config/rubocop.yml
AllCops:
DisplayCopNames: true
Exclude:
- db/schema.rb
@tkawa
tkawa / .eslintrc.yml
Created February 9, 2017 04:43
eslintrc for browser js
env:
browser: true
extends: 'eslint:recommended'
rules:
# http://eslint.org/docs/rules/
# ====================
# Possible Errors
# ====================
module ApplicationHelper
def google_tag_manager_head
return unless Rails.env.production?
<<-HTML.html_safe
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-WHX4V4D');</script>
@tkawa
tkawa / restful-towa-14.md
Last active April 5, 2016 09:58
RESTful#とは勉強会14

RESTful#とは勉強会14 2016-04-05

質問はTwitterへ #RESTudy をつけてどうぞ。

「Webを支える技術」読書会

第11章〜第13章は、考え方としては役立ちますが、現在ほとんど使われていない記述があるので、後回しにしてまず第14章から読んでいきましょう。14章を読み終わったら、グループで話し合って第11章〜第13章の興味のあるところに進んでもらってかまいません。

第14章 JSON

@tkawa
tkawa / restful-towa-13.md
Last active February 23, 2016 09:21
RESTful#とは勉強会13

RESTful#とは勉強会13 2016.02.23

https://rubychildren.doorkeeper.jp/events/39034

質問はTwitterへ #RESTudy をつけてどうぞ。

ワークショップ RESTfulなAPIとは

「駅すぱあとWebサービス」を題材に、どこがRESTfulか、どうしたらRESTの規約に近づけるかなどグループで話し合いましょう。