Skip to content

Instantly share code, notes, and snippets.

View yoshitsugu's full-sized avatar
🐐
bleat

Kota Yoshitsugu yoshitsugu

🐐
bleat
View GitHub Profile
@yoshitsugu
yoshitsugu / file.rb
Last active December 19, 2015 04:39
ファイルに含まれる日本語文字数をカウント ref: http://qiita.com/yoshitsugu@github/items/24b29384539af4ad69e8
count = 0
japanese_char = /(?:\p{Hiragana}|\p{Katakana}|[一-龠々])/
# ファイルの指定
targets = Dir.glob(TARGET_FILES)
# このエンコーディング以外はとばす
target_encodings = %w(UTF-8 Shift_JIS CP932)
targets.each{|t|
encoding = %x(nkf -g #{t}).chomp
if target_encodings.include? encoding
page.driver.browser.agent.add_auth("https://example.com/" ,"usename","password")
@yoshitsugu
yoshitsugu / Gemfile
Created June 6, 2013 13:09
rspec + capybara で 非RailsのWebアプリをテスト ref: http://qiita.com/yoshitsugu/items/76e62ebff2ac244020a1
source "https://rubygems.org"
gem "rspec"
gem "capybara-mechanize" , "1.0.1"
@yoshitsugu
yoshitsugu / add_user_and_set_authrozed_keys.sh
Created June 6, 2013 05:51
add user and set authorized_keys
#! /bin/sh
USERNAME=<username>
ADMINGROUP='wheel'
AUTHKEYS=<authkeys>
useradd -m $USERNAME
usermod -G $ADMINGROUP $USERNAME
mkdir -p /home/$USERNAME/.ssh
echo $AUTHKEYS > /home/$USERNAME/.ssh/authorized_keys
chown -R $USERNAME:$USERNAME /home/$USERNAME
chmod 700 /home/$USERNAME/.ssh
@yoshitsugu
yoshitsugu / rsync_exclude_svn.sh
Last active December 15, 2015 05:29
rsync recursive
rsync -t -r --exclude='*.svn*' FROM_DIR/* TO_DIR/