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
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
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"
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
@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 {
@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)
@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 / 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'
FROM ubuntu
#
# prepare
#
RUN apt-get update && \
apt-get upgrade -y
#
# utils
namespace :seed_fu_gen do
desc 'generate seed-fu file for line.'
task dump: :environment do |_t|
j = ActiveSupport::JSON
%w(
Affiliation
AimCategory
AimScale
<template lang="pug">
.smart-calendar
.buttons
button.prev(@click="subtractMonth") ◀
button.next(@click="addMonth") ▶
p.title {{currentYear}}年 {{currentMonth}}月
table.table
thead.head
tr.row
td.col(v-for="dayOfWeek in weekIndexes", :class="headClass(dayOfWeek)") {{$_calendarable_weekNames[dayOfWeek]}}