Skip to content

Instantly share code, notes, and snippets.

View y13i's full-sized avatar
☘️

Yoriki Yamaguchi y13i

☘️
View GitHub Profile
@y13i
y13i / cook_all.sh
Last active August 29, 2015 14:05
Chef repoのnode全台をknife solo cookする
ruby -e 'Dir.glob("#{Dir.pwd}/nodes/*").to_a.map {|path| path.match(/nodes\/(.+)\.json/)[1]}.each {|node| system "bundle exec knife solo cook #{node}"}'
@y13i
y13i / aws_config_example.rb
Last active August 29, 2015 14:05
AWS SDK利用時にcredentialsを指定する方法例
require "net/http"
require "aws-sdk"
require "aws_config"
def own_region
begin
timeout 3 do
Net::HTTP.get("169.254.169.254", "/latest/meta-data/placement/availability-zone").chop
end
rescue
@y13i
y13i / shibame.coffee
Created December 1, 2014 01:23
pug meに対抗してshiba meで柴犬画像を貼るhubot script
# Description:
# Shibame is the yet another important thing in your life
#
# Dependencies:
# None
#
# Configuration:
# Export your Flickr API key to environmental variable FLICKR_API_KEY
#
# Commands:
@y13i
y13i / gist:4c80843147227aec579a
Last active August 29, 2015 14:10
IaaSのOSに関する覚え書き

どのOSを使うべきか

何か特殊な要件などがなければ そのクラウドで第一にサポートされてるOS の最新版を選ぶべきなのでは?

単純にEC2なりGCEをLaunchするときに一番最初に選ばれているOSが安牌。

AWSであればAmazon Linuxだし、GCPであればDebian Backportsが第一候補。

ドライバなどのサポート

@y13i
y13i / gist:2a77c88516666f5bd2b2
Last active August 29, 2015 14:13
Backlog.jpをRubyでほげほげする

だいぶ前に作って放置していたRubygem backlog_jpBacklog.jp API V2 に対応する形でほぼ作り直した。使い方はREADMEを参照。

以前のバージョンではオブジェクト指向的に課題を操作したりできるようにしようと意気込んではいたものの途中で飽きてしまい、中途半端な状態で放置してしまったので今バージョンは本当に薄いラッパーという感じに。

実装例として、プロジェクト内の全課題とそれについているコメントをJSONにexportするツール backlog_jp-pj2json も作った。

テストコードも書いてなく粗末な出来ですが、物好きな方はご利用ください。

@y13i
y13i / thor_aws.rb
Last active August 29, 2015 14:14
ThorでAWSごにょごにょする時にいつも書いてる気がするやつ
require "thor"
require "aws-sdk-resources"
class OrenoAwsTool < Thor
class_option :profile,
desc: "Load credentials by profile name from shared credentials file (~/.aws/credentials).",
aliases: [:p]
class_option :access_key_id,
desc: "AWS access key id.",
@y13i
y13i / gist:ded292085162ecfa6fe0
Last active August 29, 2015 14:14
プロダクト名を正しく書こうのコーナー

ElastiCache

@y13i
y13i / scrape_rss_uris_from_aws_service_health_dashboard.rb
Created March 6, 2015 05:44
AWS Service Health Dashboardから全RSS FeedのURLを下載
require "nokogiri"
require "open-uri"
site_uri = "http://status.aws.amazon.com"
html = Nokogiri::HTML(open site_uri)
feed_uris = html.css("a[href$=rss]").map do |node|
site_uri + node.attributes["href"].value
end
@y13i
y13i / install_embulk.rb
Last active August 29, 2015 14:16
Embulkをシステムワイドにインストールするrecipe
attrs = {
embulk: {
install_path: "/opt/embulk",
download_url: "https://bintray.com/artifact/download/embulk/maven/embulk-0.5.2.jar",
path_export_script_path: "/etc/profile.d"
}
}
directory "#{attrs[:embulk][:install_path]}/bin" do
action :create
@y13i
y13i / ec2tag-hostname
Created March 30, 2015 14:01
EC2のName tagをOSのhostnameにするinit script
#!/bin/sh
# chkconfig: 345 98 20
# description: Change hostname to EC2 Name tag of the instance
# processname: ec2tag-hostname
. /etc/init.d/functions
start() {
sleep 15
REGION=`/usr/bin/curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | sed 's/.$//'`