Skip to content

Instantly share code, notes, and snippets.

View isuke's full-sized avatar
🎵
Listening to music, and coding

FUJIYAMA Isuke isuke

🎵
Listening to music, and coding
View GitHub Profile
FROM ubuntu
#
# prepare
#
RUN apt-get update && \
apt-get upgrade -y
#
# utils
@isuke
isuke / file_new.html.slim
Created September 29, 2016 12:51
file post by vue.js
template#file_new
= file_field_tag :files, multiple: true, 'v-on:change' => 'fileInputChange'
= submit_tag 'Upload', 'v-on:click.prevent' => 'fileUpload'
@isuke
isuke / autonumeric.js.coffee
Created September 20, 2016 10:07
vue autoNumeric directive
Vue.directive 'numeric',
twoWay: true
bind: ->
$(@el)
.autoNumeric('init', aPad: false)
.on 'change', =>
@set $(@el).autoNumeric('get')
update: (value) ->
el = $(@el).autoNumeric('set', value)
el.trigger('change') if el?
@isuke
isuke / select2.js.coffee
Created September 20, 2016 10:02
vue select2 directice
$ ->
Vue.directive 'select',
twoWay: true
priority: 1000
params: ['options']
bind: ->
self = @
$(@el)
@mixin shadow($depth: 1) {
@if $depth == 0 {
box-shadow: none;
} @else if $depth == 1 {
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
} @else if $depth == 2 {
box-shadow: 0 8px 17px 0 rgba(0, 0, 0, 0.20), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
} @else if $depth == 3 {
box-shadow: 0 12px 15px 0 rgba(0, 0, 0, 0.24), 0 17px 50px 0 rgba(0, 0, 0, 0.19);
} @else if $depth == 4 {
module ScreenshotTaker
SCREENSHOT_ROOT_DIR = Rails.root.join('tmp', 'rspec_screenshots')
@screenshot_dir = ''
def self.setting!
@screenshot_dir = SCREENSHOT_ROOT_DIR.join(Time.zone.now.strftime('%Y%m%d-%H%M%S'))
FileUtils.mkdir_p(@screenshot_dir)
puts "\e[32mtake screenshot to `#{@screenshot_dir}`\e[0m"
end
Task.select(
Arel::Nodes::NamedFunction.new(
'to_char',
[
Task.arel_table[:created_at],
Arel::Nodes.build_quoted('YYYY')
]
).as('year')
)
# => SELECT to_char("tasks"."created_at", 'YYYY') AS year FROM "tasks"
class Api::ApiController < ApplicationController
rescue_from Exception , with: :handle_internal_server_error if Rails.env.production?
rescue_from ActiveRecord::RecordNotFound, with: :handle_not_found
def handle_internal_server_error(_ = nil)
render_internal_server_error_message
end
def handle_not_found(_ = nil)
render_not_found_message
Bundler.require(:development, :test, :qa)
namespace :db do
namespace :sample do
desc "Fill database with sample data"
task populate: :environment do
ActiveRecord::Base.transaction do
%w(projects attrs tasks).each { |table| populate(table) }
end
end
begin
require 'scss_lint/rake_task'
SCSSLint::RakeTask.new do |t|
t.config = '.scss_lint.yml'
t.files = %w(app/assets/stylesheets)
t.quiet = false
end
rescue LoadError
puts 'scss_lint load error'