Skip to content

Instantly share code, notes, and snippets.

View yuta-imai's full-sized avatar

Yuta Imai yuta-imai

View GitHub Profile
@yuta-imai
yuta-imai / gist:4538237
Last active April 27, 2021 01:00
AWS CloudFormation sample template for redmine in single node.
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation Sample Template Redmine_Simple: Redmine is a flexible project management web application which includes a gantt chart, calendar, wiki, forums, multiple roles, and email notification. You can sign-in with the default account 'admin' and the default password 'admin'. This template installs a Redmine stack using a single EC2 instance with a local MySQL database for storage. It demonstrates using the AWS CloudFormation bootstrap scripts to install the packages and files necessary to deploy the Redmine, Rails, MySQL and all dependent packages at instance launch time. **WARNING** This template creates an Amazon EC2 instance. You will be billed for the AWS resources used if you create a stack from this template.",
"Parameters" : {
"KeyName" : {
"Description" : "Name of and existing EC2 KeyPair to enable SSH access to the instance",
"Type" : "String"
@yuta-imai
yuta-imai / gist:4538623
Created January 15, 2013 13:27
redmine Gemfile
source 'http://rubygems.org'
gem 'rails', '3.2.5'
gem 'prototype-rails', '3.2.1'
gem "i18n", "~> 0.6.0"
gem "coderay", "~> 1.0.6"
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
gem "builder"
# Optional gem for LDAP authentication
@yuta-imai
yuta-imai / sns.py
Last active December 15, 2015 04:39
import json
import time
import boto
import boto.sqs
import boto.sns
sns_cn = boto.sns.connect_to_region('ap-northeast-1')
sqs_cn = boto.sqs.connect_to_region('ap-northeast-1')
q = sqs_cn.get_queue('QUEUE_NAME')
@yuta-imai
yuta-imai / httpd
Last active December 17, 2015 00:48
#!/bin/bash
#
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: The Apache HTTP Server is an efficient and extensible \
# server implementing the current HTTP standards.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
@yuta-imai
yuta-imai / Cloud-init script
Created May 20, 2013 15:31
Cloud-init script to set up directories those are capistrano ready
#!/bin/sh
cd /var/www/html
mkdir shared
mkdir releases
cd releases
git clone https://github.com/imaifactory/howtodeploy.git
mv -f howtodeploy initial
cd ..
ln -s releases/initial current
@yuta-imai
yuta-imai / capistrano_sample_conf.rb
Last active December 17, 2015 12:58
capistrano cample config
set :application, "YOUR_APP_NAME"
set :repository, "https://github.com/YOUR_ACCOUNT/YOUR_APP.git"
set :scm, "git"
set :user, "ec2-user"
set :branch, "master"
set :deploy_via, :remote_cache
set :deploy_to, "YOUR_DOCUMENT_ROOT"
role :web, "YOUR_HOST_1", "YOUR_HOST_2", ...
@yuta-imai
yuta-imai / UserData script for setup CloudWatch
Last active March 13, 2022 01:28
With this user data script, you can set up cron job to put some custom metrics for CloudWatch at instance initiation.
#!/bin/sh
cd /home/ec2-user
wget http://ec2-downloads.s3.amazonaws.com/cloudwatch-samples/CloudWatchMonitoringScripts-v1.1.0.zip
unzip CloudWatchMonitoringScripts-v1.1.0.zip
rm CloudWatchMonitoringScripts-v1.1.0.zip
chown ec2-user:ec2-user aws-scripts-mon
echo "*/5 * * * * ec2-user /home/ec2-user/aws-scripts-mon/mon-put-instance-data.pl --mem-util --disk-space-util --disk-path=/ --from-cron" >> /etc/crontab
<?php
$client = DynamoDbClient::factory(array(
'region' => 'us-west-2',
'scheme' => 'http', #httpかhttpsを選ぶ デフォルトはhttp
"client.backoff" => false, #falseにするとエラーハンドリングしない
'client.backoff.logger' => 'debug' #debug指定するとエラーをdebugする
));
@yuta-imai
yuta-imai / read.php
Last active December 19, 2015 21:19
<?php
require 'vendor/autoload.php';
use Aws\DynamoDb\DynamoDbClient;
$client = DynamoDbClient::factory(array(
'region' => 'us-west-2',
'scheme' => 'http',
#"client.backoff" => false,
'client.backoff.logger' => 'debug',
require "aws-sdk"
AWS.config(
:access_key_id => 'YOUR_ACCESS_KEY',
:secret_access_key => 'YOUR_SECRET_KEY'
)
s3 = AWS::S3.new
bucket = s3.buckets['bucket']