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
@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')
# 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;

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

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

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

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

エラー1: cannot find Chrome binary

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]
# http://getbootstrap.com/migration/
patterns=(
"row-fluid"
"span[1-9]"
"offset[1-9]"
"brand"
"navbarnav"
"nav-collapse"
"btn-navbar"
out_filename_suffix = '.text'
conversions = [
{ from: ' ', to: ' ' },
{ from: /^## (.*)/, to: "\\1\n------------------------------" },
{ from: /^### /, to: '■ ' },
]
in_filename = ARGV.shift
out_filename = in_filename + out_filename_suffix
buf = ''