Skip to content

Instantly share code, notes, and snippets.

@hashimotor
hashimotor / .bashrc
Created April 15, 2020 03:02
Execute venv/bin/activate etc. when entering specific directory
exec-venv(){
case "$PWD" in
*/some-dir-with-venv)
if [ -z "${VIRTUAL_ENV}" ]; then
. ./venv/bin/activate
## Some other commands here
fi
;;
*/some-dir-with-venv/*)
## won't do anything
@hashimotor
hashimotor / gist:00a873e88be02db5e28799f55e91cbc6
Created May 31, 2016 00:45
Pythonでエスケープされたユニコード文字をデコードする
repr(string).decode('raw_unicode_escape')
@hashimotor
hashimotor / gist:52dc73f0778182dbc88d
Created October 27, 2014 04:22
vi に sudo つけ忘れた
:w !sudo tee % > /dev/null
defbce on
escape ^tt
defscrollback 10000
startup_message off
verbose on
logfile 'screen.log.%H.%Y%m%d-%02c:%s-%n.%t.log'
logtstamp on
logtstamp string "\n-- SCREEN [%Y/%m/%d %02c:%s] %n:%t --\n"
deflog on
bind w windowlist -b
@hashimotor
hashimotor / diag.sh
Created June 29, 2014 03:40
XFSトラシュ
#!/bin/sh
# http://xfs.org/index.php/XFS_FAQ#Q:_What_information_should_I_include_when_reporting_a_problem.3F
# 1. Hardware and storage configuration
uname -a
xfs_repair -V
cat /proc/cpuinfo
cat /proc/meminfo
cat /proc/partitions
# RAID layout
@hashimotor
hashimotor / skeleton.sh
Last active August 29, 2015 14:00
シェルスクリプトのテンプレート
#!/bin/bash
# http://rrreeeyyy.com/blog/2014/04/21/set-euo-pipefail/
# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
# https://fumiyas.github.io/2013/12/24/initialize.sh-advent-calendar.html
set -euo pipefail
umask 0750
export PATH="/bin:/usr/bin"
export LANG="C"
# ここからスタート
@hashimotor
hashimotor / postinstall.sh
Last active August 29, 2015 14:00
Vagrant Virtualbox のインストール後スクリプト
# **postinstall.sh** is a script executed after Debian/Ubuntu has been
# installed and restarted. There is no user interaction so all commands must
# be able to run in a non-interactive mode.
#
# If any package install time questions need to be set, you can use
# `preeseed.cfg` to populate the settings.
### Setup Variables
# The version of Ruby to be installed supporting the Chef and Puppet gems
@hashimotor
hashimotor / prepare.sh
Created April 16, 2014 12:52
作業準備
#!/bin/bash
# http://d.hatena.ne.jp/CortYuming/20120430/p1
sudo yum -y install git
git config --global user.name admin
git config --global user.email admin@domain.com
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto
git config --global core.excludesfile ~/.gitignore
git config --global core.shared true
@hashimotor
hashimotor / system.sh
Last active August 29, 2015 13:59
SOSreportとかohaiを使わずにがんばる
# Print OS version
cat /etc/lsb-release # or lsb_release -a
cat /etc/redhat-release
uname -a
cat /proc/version_signature
# Collect system logs
# /var/log/messages 一般的なシステムに関する情報
# /var/log/syslog
# /var/log/cron 定期的に実行される処理の結果に関する情報
@hashimotor
hashimotor / install.sh
Last active August 29, 2015 13:56
Find IP addresses on Swift rings.
#!/bin/sh
# assume swift library, python-pip, rubygems, rspec, rake and serverspec is installed.
# assume PATH contains /usr/local/bin
cp swift_ring_spec.rb /usr/local/bin
chmod +x /usr/local/bin/swift_ring_spec.rb
sudo pip install netifaces