Skip to content

Instantly share code, notes, and snippets.

View juno's full-sized avatar
💰
writing code (almost) every weekday

Junya Ogura juno

💰
writing code (almost) every weekday
View GitHub Profile
@juno
juno / fonts.md
Last active October 25, 2016 14:04
I need to install these fonts to my new mac.

“Content & Display Patterns,” an article by Dan Mall

  • A Content pattern describes the types of elements within and can be rendered in multiple forms
    • 要素のタイプを表現するパターン
    • 複数の形態で描画できる
  • A Display pattern describes a specific rendering and can be applied to multiple types of Content patterns
    • 固有のレンダリングについてのパターン
    • 色々なタイプのContentパターンに対して適用できる
  • あるコンテンツのアイデンティティを考えるのはContentパターンについての考察である
  • そのコンテンツをどのように描画するかのビジュアル的な選択について考えるのはDisplayパターンについての考察である
@juno
juno / a.scss
Created January 13, 2016 10:37
Linear gradient page header line.
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 December 16, 2015 15:48 — forked from jnicklas/wait_steps.rb
waiting async processing helper for Capybara 2.5.0
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 June 3, 2018 07:42
Preload ActiveRecord associations. (Rails 4.2.5)
# 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 November 17, 2015 13:39
carrierwave master (unreleased) reduced memory footprint.

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 April 17, 2024 12:23
AWS Lambda Function to call EC2 StartInstances/StopInstances API
/* 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 August 12, 2015 08:23
Custom log formatter which supprots severity and progname. This works well with Heroku's rails_12factor.gem
# 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 August 29, 2015 14:27
My own logger formatter for Rails dev env.
# 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' }