Skip to content

Instantly share code, notes, and snippets.

@okisanjp
okisanjp / file0.txt
Last active August 29, 2015 14:08
fluent-plugin-mackerelでhttpdのステータスコードを送信 ref: http://qiita.com/okisanjp/items/9da6220e2230b06eb76a
# /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-datacounter
@okisanjp
okisanjp / file0.rb
Last active August 29, 2015 14:08
Chef-solo:レシピの中でChef実行中のユーザー名を使う ref: http://qiita.com/okisanjp/items/b039e2da328b21836bdc
git "/home/#{node['current_user']}/dotfiles" do
repository "https://github.com/okisanjp/dotfiles.git"
revision "master"
user node['current_user']
group node['current_user']
action :sync
end
@okisanjp
okisanjp / gist:f2a3d97a62d0abb2052d
Created April 26, 2015 09:06
Amazon商品ページからアソシエイトタグ付きHTMLを生成
javascript:(function() {var m = "&tag=YOUR_ASSOCIATE_TAG";var u = location.href;prompt('Associate URL' ,'<a href="' + u + m + '" target="_blank">' + document.title + '</a>');})();
@okisanjp
okisanjp / gist:3e7a950c7f0c0af5fbf3
Created April 26, 2015 09:07
ブラウザ表示中ページからA8.netの商品リンクを生成
javascript:(function() {var m = "対象プログラムのA8MAT";var a = "http://px.a8.net/svt/ejp?a8mat=" + m + "&a8ejpredirect=";var u = location.href;prompt( 'Affiliate URL' , '<a href="' + a + encodeURIComponent(u) + '" target="_blank">' + document.title + '</a>' );})();
@okisanjp
okisanjp / file0.txt
Created May 22, 2015 11:57
GNU lsをファイル出力するときは標準出力と見た目が違うから気をつける ref: http://qiita.com/okisanjp/items/46086d5af38babd4e2a5
$ ls
Plugin Vendor app composer.json composer.lock composer.phar fabfile.py fabfile.pyc
@okisanjp
okisanjp / file0.txt
Last active December 22, 2016 09:24
bash:標準出力も標準エラーもログに出力 ref: http://qiita.com/okisanjp/items/4bdf009176ecae312f84
#!/bin/sh
echo "foo"
cat ./sonna_file_naiyo.txt
echo "bar"
$ aws ec2 describe-instances
{
"Reservations": [
{
"OwnerId": "xxxxxxxxxxx",
"ReservationId": "r-xxxxxxx",
"Groups": [],
"Instances": [
{
@okisanjp
okisanjp / file0.txt
Last active August 29, 2015 14:22
macのechoをシェルスクリプト内で使う時に -nオプションを使う方法 ref: http://qiita.com/okisanjp/items/7985ddb9b1b00f1617a9
# シェルスクリプト内で以下のように書くと
echo -n "Are you sure you want to exit the server? [y/n] > "
# 実行時
-n Are you sure you want to exit the server? [y/n] >
(´;ω;`)ウッ…
@okisanjp
okisanjp / file0.txt
Created May 29, 2015 06:39
readで入力待ちの時、whileと組み合わせて想定文字以外のときにエラーを表示する ref: http://qiita.com/okisanjp/items/47698db1de28b5836ca5
echo -n "Are you sure you want to exit the server? [y/n] > "
while :
do
read INPUT
case "$INPUT" in
"y" ) kill $SERVER_PID
echo "Stopped WEBRick"
break ;;
"n" ) echo "Canceled."
break ;;
@okisanjp
okisanjp / gist:158bc0498f751259ecd1
Last active March 6, 2017 14:24
awscli + jqで開発マシンの/etc/hosts用出力
### プライベートIPの場合
$ aws ec2 describe-instances | jq -r '.Reservations[].Instances[] | .PrivateIpAddress + "\t" + .Tags[].Value'
192.0.2.1 aws1.example
192.0.2.2 aws2.example
192.0.2.3 aws3.example
192.0.2.4 aws4.example
192.0.2.5 aws5.example
192.0.2.6 aws6.example
192.0.2.7 aws7.example