Skip to content

Instantly share code, notes, and snippets.

View tanakaworld's full-sized avatar
👾
No Pixel No Life

tanakaworld tanakaworld

👾
No Pixel No Life
View GitHub Profile
@tanakaworld
tanakaworld / hexo-posts-to-hugo.bash
Created January 17, 2021 12:49
Convert posts of hexo to hugo.
# Dependencies
# - brew install gnu-sed
FILES='content/posts/*.md'
prefix='[[:digit:]][[:digit:]][[:digit:]][[:digit:]]-[[:digit:]][[:digit:]]-[[:digit:]][[:digit:]]-'
suffix='.md'
for f in $FILES
do
# Insert slug from file name
@tanakaworld
tanakaworld / file0.txt
Last active December 3, 2018 01:32
Sentry で Nuxt.js のエラー検知 + 環境変数の扱いに関する Tips ref: https://qiita.com/tanakaworld/items/910d766361d398f43254
$ npm i -S @nuxtjs/sentry
@tanakaworld
tanakaworld / file0.rb
Created September 19, 2018 08:35
RSpec + capybara で SessionStorage クリアする ref: https://qiita.com/tanakaworld/items/a1a49be73c4cfe9e0dd4
RSpec.configure do |config|
config.prepend_after(:each, type: :feature) do
Capybara.execute_script 'localStorage.clear()'
end
end
@tanakaworld
tanakaworld / file1.txt
Created June 27, 2018 11:03
Rails Devise で DB カラムに依存しない項目を追加する acceptance ref: https://qiita.com/tanakaworld/items/2efe9a4213859dc9c239
$ bundle exec rails g devise:controllers users
@tanakaworld
tanakaworld / application.sass
Last active April 19, 2018 02:23
wicked_pdf で カスタムフォントを使う ref: https://qiita.com/tanakaworld/items/18ec7ff7c7a9fadcf0ae
/*
*= require_self
*/
@import fonts
@tanakaworld
tanakaworld / pdf.html.erb
Created January 10, 2018 09:09
wicked_pdf で chartkick のグラフを表示する ref: https://qiita.com/tanakaworld/items/1bbb18df438f9a6c39a2
<!DOCTYPE html>
<html>
<head>
<%= csrf_meta_tags %>
<%= wicked_pdf_stylesheet_link_tag 'application' %>
   <!-- 本番環境で動作しなくなる -->
<!-- <%= wicked_pdf_javascript_include_tag 'pdf' %> -->
<%= javascript_include_tag wicked_pdf_asset_base64('pdf') %>
</head>
@tanakaworld
tanakaworld / dirty-forms.js
Last active November 29, 2017 05:37
【Rails】FormのDirtyCheckをする(with Turbolinks, CKEditor) ref: https://qiita.com/tanakaworld/items/12dc2fc31fd3192e01a3
$(window)
•••
.on("page:before-change turbolinks:before-visit", function () {
if (window.appName.formDirty || CKEDITOR.hasDirtyForm()) {
return confirm(window.appName.dirtyMessage);
}
})
.bind("beforeunload", function (event) {
if (!window.appName.formSubmit && (window.appName.formDirty || CKEDITOR.hasDirtyForm()) {
event.returnValue = window.appName.dirtyMessage;
@tanakaworld
tanakaworld / sample_model.rb
Created September 6, 2017 14:34
has_secure_passwordのバリデーションの有無を特定条件によって切り替える ref: http://qiita.com/tanakaworld/items/e8d8cb64304857ea5200
class SampleModel < ApplicationRecord
before_validation :clear_password
•••
private
•••
def clear_password
unless self.open_with_pw?
@tanakaworld
tanakaworld / API.js
Created July 24, 2017 04:11
カスタムエラークラスを定義して、FetchAPIのエラーハンドリングをする ref: http://qiita.com/tanakaworld/items/9abbc343551af3330108
// 追記
import APIError from './APIError'
export function send (url, method, body) {
const headers = new Headers({
'Content-Type': 'application/json'
})
const options = {
method: method,
@tanakaworld
tanakaworld / Gemfile
Last active July 19, 2017 01:02
【Rails】Carrierwave で音声ファイルをアップロード&変換する ref: http://qiita.com/tanakaworld/items/fbcd08eeccf826332f89
gem 'carrierwave-audio', git: 'git@github.com:tanakaworld/carrierwave-audio.git'