Skip to content

Instantly share code, notes, and snippets.

@akira345
akira345 / rack_test.rb
Created November 29, 2012 01:05 — forked from eiel/rack_test.rb
rack と erb の sample 初期状態
require 'rubygems'
require 'rack'
require 'erb'
class RackApp
def call(env)
[200, {'Content-Type' => 'text/html'}, [<<END_HTML]
<html>
<head><title>Rack test</title></head>
@akira345
akira345 / create_and_rotate_image_of_myself.rb
Last active December 26, 2015 04:20 — forked from okochang/create_and_rotate_image_of_myself.rb
EC2インスタンスから実行して自分自身のAMI取得とAMIの世代管理をするスクリプト。実行する場合はEC2インスタンスのタグを指定した上で実行する事。
# -*- coding: utf-8 -*-
require 'net/http'
require 'aws-sdk'
instance_id = Net::HTTP.get('169.254.169.254', '/latest/meta-data/instance-id')
ec2_region = 'ec2.' + Net::HTTP.get('169.254.169.254', '/latest/meta-data/placement/availability-zone').chop + '.amazonaws.com'
image_name = instance_id + '-' + Time.now.strftime("%Y%m%d%H%M")
comment = "automatically generated image"
@ec2 = AWS::EC2.new(
@akira345
akira345 / clone-github.rb
Created May 20, 2017 09:09
GitHubから自分のリポジトリをまとめてcloneする。(公開リポジトリのみ)
# Use 'ruby clone-github.rb'
# ユーザー名とかdepthオプションは自分で書き換えてください。
require "json"
require "open-uri"
response = open("https://api.github.com/users/Hiroto-K/repos?per_page=100").read
JSON.parse(response).each do |info|
clone_url = info["ssh_url"]
to = info["name"]