Skip to content

Instantly share code, notes, and snippets.

View upinetree's full-sized avatar

Takuya Matsumoto upinetree

View GitHub Profile
git diff master --name-only --diff-filter=ACMR "*.rb" | sed 's| |\\ |g' | xargs ./node_modules/.bin/prettier --write

WSL Ubuntu 上で chromedriver を使った System Spec を動かす

エラー別トラブルシューティング

Rails デフォルトの chromedriver-helper gem をそのまま利用するだけでは、エラーが出て実行できない場合がある。

以下、エラー別に対策を考察。

エラー1: cannot find Chrome binary

@upinetree
upinetree / genrbs
Created August 30, 2021 15:22
ディレクトリを指定して一括で rbs prototype rb を実行する便利ネタ
#!/usr/bin/env zsh
set -eu
test "$#" -ne 1 && echo "Usage: $0 ROOTDIR" && exit 1
root=$1
test ! -d $root && echo "$root is not a valid directory" && exit 1
for file in $(find $root -name '*.rb')

特定のテーブルのカラムにだけCOLLATIONを設定する方法

$ be bin/rails db
=# ALTER TABLE users ALTER COLUMN kana TYPE varchar COLLATE "ja_JP.utf8";
> 特定のカラムにだけ付与

=# \d staffs
> 付与したことを確認
# gem install qiita
require 'qiita'
items = Qiita::Client.new.list_user_items('username')
items.body.each { |item| File.open("items/#{item['title']}.md", 'w') { |f| f.write(item["body"]) } }
@upinetree
upinetree / README.md
Last active June 28, 2019 09:46
Electron Fiddle Gist

使い方

Electron Fiddle で読み込んでビルド。

打刻しないモックを使うコードになっているので、使うときは renderer.js の以下を変更してください。

- // const touchProcess = touchStrategy;
- const touchProcess = touchStrategyMock;
+ const touchProcess = touchStrategy;
module ApplicationHelper
# activated の条件が真のとき、.active クラス付きの <a> タグを生成
#
# 例:
# = activated_link_to params[:sort] == 'newly', hogehoge_path(sort: :newly) do
# %span 新着順
#
def activated_link_to(activated, name = nil, options = {}, html_options = {}, &block)
if block_given?
html_options = options
@upinetree
upinetree / Dockerfile
Created November 3, 2016 08:31
Use rbenv on ubuntu (memo for the case that could not use a ruby image for some reason)
FROM ubuntu
# prepare packages
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y git \
&& apt-get build-dep -y ruby
# set timezone
RUN echo "Asia/Tokyo" > /etc/timezone \
module SslRedirectable
extend ActiveSupport::Concern
included do
before_action :force_non_ssl, if: :force_non_ssl?
class_attribute :ssl_actions
SSL_ACTIONS_ALL = [:all]
@upinetree
upinetree / capybara_find.md
Created January 21, 2014 14:07
非表示要素はCapybaraのfindで検索対象になるのか

display: noneで非表示にしてあるものはcapybaraのfind対象なのか??

という疑問があるわけです。

ここは公式みてみますか。

Module: Capybara::Node::Finders

visible (Boolean) — Only find elements that are visible on the page. Setting this to false finds invisible andvisible elements.