Skip to content

Instantly share code, notes, and snippets.

@Koh0214
Koh0214 / file0.txt
Created August 29, 2018 03:47
美女が「励まして」「癒して」「優しく叱って」くれるLINE bot【励ますサン】を作った ref: https://qiita.com/Kohei_Kishimoto0214/items/590874dd0f782a22c6fe
function doGet() {
return ContentService.createTextOutput("success");
}
function doPost(e) {
var webhookData = JSON.parse(e.postData.contents).events[0];
var message,replyToken;
//送られてきた文言が変数messageに入る。(ボタンを押した時のテキスト)
message = webhookData.message.text;
replyToken = webhookData.replyToken;
@Koh0214
Koh0214 / file0.txt
Last active August 8, 2018 03:58
RailsでスマホとPCヘッダーを分ける方法 ref: https://qiita.com/Kohei_Kishimoto0214/items/cd79c3288b746049e87f
/* パソコンで見たとき*/
.pc-header { display: block !important; }
.sma-header { display: none !important; }
/* スマートフォンで見たとき*/
@media only screen and (max-width: 750px) {
.pc-header { display: none !important; }
.sma-header { display: block !important; }
}
@Koh0214
Koh0214 / file0.txt
Created August 1, 2018 03:41
jQueryで高さを固定長からautoアニメーションで変更させる方法 ref: https://qiita.com/Kohei_Kishimoto0214/items/237d17373074c6b74223
//現在のheight取得
curHeight = $(this).height();
//autoにした場合のheightを取得
autoHeight = $(this).css('height', 'auto').height();
//autoにした場合のheightへ向かってanimate
//数値なのでanimateが有効
$(this).height(curHeight).animate({height: autoHeight}, 150);
@Koh0214
Koh0214 / _card.html.haml
Last active July 30, 2018 05:09
【コメント欄】+-の比率でコメントの色・大きさが動的に変わるUIの実装 ref: https://qiita.com/Kohei_Kishimoto0214/items/74fcf88afc3f97d58bff
.card.my-2.mx-0.border-0
.text-muted.small.p-2
名前: #{comment.name}
-# up,downの比率を取得
- up_down_rate = ((comment.up.to_f) / (comment.up.to_f + comment.down.to_f)) * 100
-# 比率によりクラスを分ける
- if 90 <= up_down_rate
.p-2.comment.comment-level-5
#{comment.comment}
- elsif 70 <= up_down_rate && up_down_rate < 90
@Koh0214
Koh0214 / Gemfile
Last active June 4, 2018 07:53
railsで作ったアプリをとりあえず公開する方法。rails+GitHub(GitHub Desktop)+heroku ref: https://qiita.com/Kohei_Kishimoto0214/items/d4a4ca13d4a8ab11b3f8
# この2行を削除
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
#ここ1行追加
gem 'sqlite3', '1.3.13'
end
@Koh0214
Koh0214 / _note.html.haml
Last active February 16, 2017 04:52
railsの超短縮系partialの書き方【部分テンプレート】 ref: http://qiita.com/Kohei_Kishimoto0214/items/24d3f31c99a09b58dd9c
// 部分テンプレート内での変数名は note が勝手に指定されます。
// 変数noteにそれぞれの@noteが都度入ってくる感じです。
= link_to note_path(note) do
.notes__body__box
.notes__body__box__title
= note.title
%hr.notes__body__box__line/
.notes__body__box__body
@Koh0214
Koh0214 / messages.js
Last active November 26, 2017 08:11
javascriptのFormDataは、ajaxで飛ばすまで中身を見ることができないっぽい。 ref: https://qiita.com/Kohei_Kishimoto0214/items/5ac3ca643da8d636ce40
$('.message_form').on('submit', function(e) {
e.preventDefault();
var group_id = $('.group_id').val();
var fd = new FormData($('.message_form').get(0))
fd.append('body', $('.form').val())
// $('.form').val() => "aaa"
console.log(fd);
// ここではfdを見ると FormData = {} となり、一見何も入っていないように見える
$.ajax({
@Koh0214
Koh0214 / file2.java
Last active June 26, 2017 09:29
javascriptでhtml要素を複数追加するときの【ひと目で分かる】書き方 ref: http://qiita.com/Kohei_Kishimoto0214/items/da38e21efa4c5b8bd02c
'<input value"' + 変数 + '">'
@Koh0214
Koh0214 / file1.txt
Last active June 26, 2017 09:29
javaScript(jQuery)のインクリメンタルサーチで、全ての行に解説をつけてみた。 ref: http://qiita.com/Kohei_Kishimoto0214/items/2f08bf430a34023ef01d
var inputs = input.split(" ").filter(function(e) { return e; });
@Koh0214
Koh0214 / file0.rb
Last active June 26, 2017 09:28
rspecのテスト環境で多対多のアソシエーションを一括生成する方法 +α ref: http://qiita.com/Kohei_Kishimoto0214/items/425ecb56e8586e46354f
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'faker'