Skip to content

Instantly share code, notes, and snippets.

:atom:
writing code everyday

Junya Ogura juno

:atom:
writing code everyday
Block or report user

Report or block juno

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@juno
juno / a.scss
Created Jan 13, 2016
Linear gradient page header line.
View a.scss
body {
background-color: #fff;
&:after {
content: '';
display: block;
background-image: linear-gradient(90deg, #a16eff 0%, #3dcebb 100%);
height: 4px;
position: absolute;
left: 0;
top: 0;
@juno
juno / usage.rb
Last active Dec 16, 2015 — forked from jnicklas/wait_steps.rb
waiting async processing helper for Capybara 2.5.0
View usage.rb
scenario 'User likes the post' do
visit post_path
click_button 'Like'
expect { page.has_css?('.liked-icon') }.to become_true
end
@juno
juno / preload.rb
Last active Jun 3, 2018
Preload ActiveRecord associations. (Rails 4.2.5)
View preload.rb
# You can preload associations explicitly.
# This method also can apply to polymorphic association.
#
# See also https://github.com/rails/rails/blob/master/activerecord/lib/active_record/associations/preloader.rb
#
def index
@comments = Comment.order(id: :desc).limit(10)
# This prevents N+1 query for user and commentable associations
ActiveRecord::Associations::Preloader.new.preload(@comments, [:user, :commentable])
@juno
juno / carrierwave-memory-footprint.md
Last active Nov 17, 2015
carrierwave master (unreleased) reduced memory footprint.
View carrierwave-memory-footprint.md
View css-workflow.md

CSS Workflow (WIP)

Steps

  • Define Color Palette
  • Reset Browser Default Styles
  • Define Scaffold Styles
  • Define Components by Atomic Design Methodology
    • Define Atoms
    • Define Molecules
    • Define Organisms
@juno
juno / ec2_start_instances.js
Last active Nov 5, 2017
AWS Lambda Function to call EC2 StartInstances/StopInstances API
View ec2_start_instances.js
/* Event Parameters
{
"accessKeyId": "...",
"secretAccessKey": "...",
"region": "ap-northeast-1",
"instanceId": "i-XXXXXXXX"
}
*/
exports.handler = function(event, context) {
console.log('instanceId =', event.instanceId);
@juno
juno / custom_log_formatter.rb
Created Aug 12, 2015
Custom log formatter which supprots severity and progname. This works well with Heroku's rails_12factor.gem
View custom_log_formatter.rb
# Custom log formatter module for rails_12factor
#
module CustomLogFormatter
# Custom formatter for development environment.
#
# Examples
#
# # in controller
# logger.error(self.class) { 'This is a error message' }
# logger.info { 'This is a info message' }
@juno
juno / development_logger_formatter.rb
Last active Aug 29, 2015
My own logger formatter for Rails dev env.
View development_logger_formatter.rb
# Custom logger formatter for development environment.
#
# Examples
#
# # in config/environments/development.rb
# config.log_formatter = ::DevelopmentLoggerFormatter.new
#
# # in controller
# logger.error(self.class) { 'This is a error message' }
# logger.info { 'This is a info message' }
@juno
juno / rails_helper.rb
Created Jun 25, 2015
Poltergeistを利用したfeature specにおいて、ブラウザの言語設定を明示的に行う
View rails_helper.rb
RSpec.configure do |config|
config.before(:each) do |example|
# Poltergeistの言語設定をja,enにする
if example.metadata[:type] == :feature && example.metadata[:js]
page.driver.headers = {
'Accept-Language' => 'ja,en',
}
end
end
end
@juno
juno / how-to-sunset-a-feature.md
Last active Aug 29, 2015
機能の提供を終了する手順 / Japanese summary of "How to Sunset a Feature - Inside Intercom" https://blog.intercom.io/how-to-sunset-a-feature/
View how-to-sunset-a-feature.md

機能の提供を終了する手順

1. 終了してもよいことを確認する

以下の問いに答えられるようにする。

  • その機能を利用できるのはユーザー何%か?(ユーザーのプランによって利用可否がある場合など)、頻繁に利用されているか?
  • それらのユーザーの生み出す収益は何%か?
You can’t perform that action at this time.