Skip to content

Instantly share code, notes, and snippets.

View aileron's full-sized avatar

AILERON aileron

View GitHub Profile
@aileron
aileron / .vimrc
Created August 2, 2021 08:22
.vimrc
" vim-bootstrap b0a75e4
"*****************************************************************************
"" Vim-PLug core
"*****************************************************************************
if has('vim_starting')
set nocompatible " Be iMproved
endif
let vimplug_exists=expand('~/.vim/autoload/plug.vim')
@aileron
aileron / keyhac.py
Created April 7, 2021 03:01
keyhac を使って、SKKで間違って送られてしまうキーコードへの対応処理
import sys
import os
import datetime
import subprocess
from keyhac import *
def configure(keymap):
keymap_terminal = keymap.defineWindowKeymap( app_name="com.googlecode.iterm2" ) # iterm2だけのローカル設定
keymap_terminal["Ctrl-J"] = "104" # CTRL-Jを入力するとかなを送信。104はかなキーの仮想キーコード
@aileron
aileron / .gitconfig
Created October 16, 2020 01:26
よくつかう、git の エイリアス
[alias]
unstage = reset HEAD
delete-merged-branches = !git branch --merged | grep -v \\* | xargs git branch -d
delete-remote-branches = !git fetch --all --prune
delete-local-branches = !git branch | grep -v \\* | xargs git branch -D
delete-all-branches = !git delete-local-branches && git delete-remote-branches
@aileron
aileron / calc_time.rb
Created October 13, 2020 08:15
zsh の history を元にして、開始と終了から時間を出します
require 'time'
wd = ["日", "月", "火", "水", "木", "金", "土"]
result = {}
while line = gets
begin
time = Time.parse(line)
date = time.strftime '%Y-%m-%d'
result[date] ||= []
@aileron
aileron / active_storage_downloader.rb
Created June 16, 2020 02:12
ActiveStorageDownloader
# frozen_string_literal: true
module ActiveStorageDownloader
refine ActiveStorage::Blob do
def download_to(tempdir: nil, &block)
DownloadTo.new(self, tempdir: tempdir).download_blob_to_tempfile(&block)
end
end
using self
@aileron
aileron / has_many_prefetch.rb
Created February 27, 2019 05:14
HasManyPrefetch
class HasManyPrefetch
attr_reader :name
attr_reader :values
attr_reader :method_name
attr_reader :fetcher
def initialize(name:, method_name: nil, &fetcher)
@name = name
@method_name = method_name || "#{name}_id"
@fetcher = fetcher
@aileron
aileron / mirereba_iinen.rb
Created February 5, 2019 08:09
Validate for all routing
require 'rails_helper'
module ValidateForAllRouting
class << self
# Admin配下のpath名と、それに合致するcontroller名とaction名を取得
def admin_routes(actions)
routes = routes(actions)
routes.select { |route| route[:name].include?('admin') }
end
private
@aileron
aileron / git-wip
Created August 10, 2018 02:43
git-wip
#!/usr/bin/env zsh
if [ $# -eq 0 ]; then
echo "Usage:"
echo "git wip (branch-name) (issue-number)"
exit 2
fi
issue_number=''
issue_title=''
branch_name=$1
if [ $# -eq 2 ]; then
@aileron
aileron / .vimrc
Created July 27, 2018 07:44
minimum vimrc
if has('vim_starting')
set rtp+=~/.vim/plugged/vim-plug
if !isdirectory(expand('~/.vim/plugged/vim-plug'))
echo 'install vim-plug...'
call system('mkdir -p ~/.vim/plugged/vim-plug')
call system('git clone https://github.com/junegunn/vim-plug.git ~/.vim/plugged/vim-plug/autoload')
end
endif
call plug#begin('~/.vim/plugged')
@aileron
aileron / .zshrc.history
Created July 16, 2018 15:43
history file
HISTFILE=$HOME/.history # 履歴をファイルに保存する
HISTSIZE=10000000 # メモリ内の履歴の数
SAVEHIST=10000000 # 保存される履歴の数
setopt hist_ignore_dups # 重複を記録しない
setopt hist_ignore_all_dups
setopt hist_save_no_dups
setopt hist_reduce_blanks # スペース排除
setopt extended_history # 履歴ファイルに時刻を記録
setopt share_history # 端末間の履歴を共有
function history-all { history -E 1 } # 全履歴の一覧を出力する