Skip to content

Instantly share code, notes, and snippets.

View maecha's full-sized avatar
🏠
Working from home

Maechan maecha

🏠
Working from home
View GitHub Profile
@maecha
maecha / Gemfille
Last active April 3, 2018 21:24
Post a message to 'alert' channel in Slack
gem 'json'
gem 'faye-websocket'
gem 'eventmachine'
gem 'slack-ruby-client'
@maecha
maecha / app|controllers|hoges_controller.rb
Last active April 3, 2018 09:47
Creating text-date, Convert Time Class to String Class
class HogesController < ApplicationController
private
def get_date_text
from = params[:from]
to = params[:to]
wave_dash_text = ' ~ '
get_converted_string_date(from) + wave_dash_text + get_converted_string_date(to)
@maecha
maecha / app|controllers|concerns|bool_castable.rb
Created April 3, 2018 07:44
Create the module for to cast boolean
module Concerns
module BoolCastable
extend ActiveSupport::Concern
private
def cast_to_boolean(value)
ActiveRecord::Type::Boolean.new.cast(value)
end
end
@maecha
maecha / app|assets|javascripts|application.js
Created April 3, 2018 07:24
How to use TimePicker in AdminLTE ver2 (with Bootstrap 3.3.6)
:
:
//= require admin-lte/plugins/timepicker/bootstrap-timepicker.min
@maecha
maecha / app|assets|javascripts|application.js
Last active April 3, 2018 07:15
How to use DatePicker in AdminLTE ver2 (with Bootstrap 3.3.6)
:
:
//= require admin-lte/plugins/datepicker/bootstrap-datepicker
//= require admin-lte/plugins/datepicker/locales/bootstrap-datepicker.ja
@maecha
maecha / Gemfile
Last active April 3, 2018 06:58
How to use 'Cocoon' | Ruby on Rails 5.1.4 | AdminLTE ver2 (with Bootstrap 3.3.6) | Model 'Hoge' and 'Model 'Fuga' are 'one-to-many relationship'
gem 'cocoon'
gem 'jquery-rails'
@maecha
maecha / app|assets|javascripts|hoge.coffee
Last active April 2, 2018 07:34
How to make the disabled-link with CoffeeScript / for Ruby on Rails 5.1.4
$(document).on 'turbolinks:load', ->
do ->
$('.disabled-link').click (e) ->
e.preventDefault()
return
@maecha
maecha / Gemfile
Last active March 31, 2018 03:29
Kaminari on 'Ruby on Rails 5.1.4'
gem 'kaminari'
@maecha
maecha / app|views|hoges|new.html.slim
Last active March 29, 2018 07:02
Open modal view on AdminLTE ver2 (with Bootstrap 3.3.6)
/ the way it uses font awesome
= link_to '#', data: { toggle: 'modal', target: '#hoge-modal' } do
i.fa.fa-question-circle
end
== render partial: 'layouts/shared/modals/hoge'
@maecha
maecha / CLI
Last active April 6, 2018 06:44
Update select box when another one is updated. / E.g. Hoge and Fuga are 'one-to-many relationship', and use a controller 'Piyo' without this association .
$ ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
$ bundle exec rails -v
Rails 5.1.4