Skip to content

Instantly share code, notes, and snippets.

<!-- <div class="block block--modifier"></div> -->
<div class="block--modifier"></div>
class UploadForm
  include ActiveModel::Model

  attr_accessor :upload_file

  validates_each :upload_file do |record, attr, value|
    if value.present? && value.size > 1.megabytes
      record.errors.add(attr, 'ファイルサイズがビッグだね')
 end
@ruedap
ruedap / gist:9001131
Last active August 29, 2015 13:56
Sass variable name
@mixin hoge-fuga {
content: 'a';
}
@mixin hoge_fuga {
content: 'b';
}
.hoge {
@ruedap
ruedap / test.js.coffee
Created April 11, 2014 12:50
D3 example: basic bar chart
class D3Example
constructor: (@selector, width, height, @margin) ->
@el = @defineRootElement(@selector, +width, +height, @margin)
defineRootElement: (selector, width, height, margin) =>
@width = width - margin.left - margin.right
@height = height - margin.top - margin.bottom
d3.select(selector)
.append('svg')
.attr('width', width)
@ruedap
ruedap / test.js.coffee
Last active August 29, 2015 13:59
D3 example: basic bar chart with frame border
class D3Example
constructor: (@selector, width, height, @margin) ->
@el = @defineRootElement(@selector, +width, +height, @margin)
defineRootElement: (selector, width, height, margin) =>
@width = width - margin.left - margin.right
@height = height - margin.top - margin.bottom
d3.select(selector)
.append('svg')
.attr('width', width)
@ruedap
ruedap / untitled.rb
Last active August 29, 2015 13:59
Convert to .jpg from .png using RMagick
require 'pathname'
require 'rmagick'
images = Dir['*.png']
images.each {|image| i = Magick::Image.read(image).first; i.write(Pathname(image).sub_ext('.jpg')) { self.format='JPEG'; self.quality=80; }}
@ruedap
ruedap / D3Example.js.coffee
Created April 28, 2014 16:21
D3Example class
class D3Example
constructor: (@selector, width, height, @margin, hasBorder) ->
@margin = top: 20, right: 20, bottom: 20, left: 20 unless @margin
@el = @defineRootElement(@selector, +width, +height, @margin, hasBorder)
defineRootElement: (selector, width, height, margin, hasBorder) =>
@width = width - margin.left - margin.right
@height = height - margin.top - margin.bottom
d3.select(selector)
@ruedap
ruedap / gist:fb404d8cf8d2d4cc5775
Last active August 29, 2015 14:07
CSS3 custom radio button
input[type=radio] {
display: none;
& + label {
position: relative;
padding-left: 24px;
cursor: pointer;
&::before,
&::after {
@ruedap
ruedap / switch-button.png
Last active August 29, 2015 14:09
Switch Button CSS
.switch-button
.switch-button__button.is-active Type A
.switch-button__button Type B
.switch-button__button Type C
@ruedap
ruedap / SassMeister-input-HTML.haml
Last active August 29, 2015 14:10
Generated by SassMeister.com.
%ul.List
%li.List-item.List-item--active 1
%li.List-item 2
%li.List-item 3