Skip to content

Instantly share code, notes, and snippets.

View YoshihitoAso's full-sized avatar
🐼

Yoshihito Aso YoshihitoAso

🐼
  • BOOSTRY Co., Ltd.
  • Tokyo
  • X @y_asoh
View GitHub Profile
@YoshihitoAso
YoshihitoAso / elbfailover.sh
Last active December 14, 2015 13:48
ELBフェイルオーバー用のShell
#! /bin/bash
SORRY_INSTANCE=`curl -s http://169.254.169.254/latest/meta-data/instance-id`
ELB_NAME=elbfailover
SLEEPTIME=2
while :; do
TIMESTAMP=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
ELB_STATUS=`aws elb describe-instance-health --load-balancer-name $ELB_NAME`
HEALTHY_HOST_COUNT=`echo $ELB_STATUS | jq "[ .InstanceStates[] | select(.InstanceId != \"$SORRY_INSTANCE\" and .State == \"InService\") ] | length"`
@YoshihitoAso
YoshihitoAso / QueueWorker.java
Last active December 14, 2015 16:09
[AWS][SQS]AWS SQSのサンプルプログラム
public class QueueWorker {
private static final String QUEUE_URL="...";
public static void main(String[] args) {
QueueWorker main = new QueueWorker();
ClasspathPropertiesFileCredentialsProvider provider = new ClasspathPropertiesFileCredentialsProvider("aws.properties");
AmazonSQSClient amazonSQSClient = new AmazonSQSClient(provider);
main.sqs = amazonSQSClient;
@YoshihitoAso
YoshihitoAso / QueueWorker2.java
Last active December 14, 2015 16:09
[AWS][SQS]AWS SQSのサンプルプログラム(Spring版)
public class QueueWorker2 {
private static final String QUEUE_URL="...";
public static void main(String[] args) {
try (ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml")) {
SpringQueueWorker main = context.getBean(SpringQueueWorker.class);
main.sqs = context.getBean(AmazonSQS.class);
main.mailSender = context.getBean(MailSender.class);
main.mailTemplate = context.getBean(SimpleMailMessage.class);
@YoshihitoAso
YoshihitoAso / applicationContext.xml
Created March 8, 2013 00:42
[AWS][SQS]AWS SQSのサンプルプログラム(Spring版)のapplicarionContext
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="worker" class="jp.classmethod.sample.spring.start.SpringQueueWorker" />
<bean id="amazonSQSClient" class="com.amazonaws.services.sqs.AmazonSQSClient">
<constructor-arg>
<bean class="com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider">
@YoshihitoAso
YoshihitoAso / gist:5127358
Last active December 14, 2015 18:09
[JBoss]twiddleに関するメモ
#reference
http://www.mastertheboss.com/jboss-script/twiddle-reference-guide
#clear exception count
#restart
twiddle.sh -s XX.XX.XX.XX:XXXX invoke "SA-Schedulers:class=jp.ossc.tstruts2.service.scheduler.SchedulerService,name=SaBunsanBatchSeigyoFuncSchedulerService**" restart
#stop
twiddle.sh -s XX.XX.XX.XX:XXXX invoke "SA-Schedulers:class=jp.ossc.tstruts2.service.scheduler.SchedulerService,name=SaBunsanBatShoriErrCheckFuncSchedulerService**" stop
@YoshihitoAso
YoshihitoAso / gist:5131314
Last active December 14, 2015 18:39
[AWS][RDS]RDS Cli のインストール
$wget http://s3.amazonaws.com/rds-downloads/RDSCli.zip
$unzip RDSCli.zip
$export AWS_RDS_HOME=/home/ec2-user/RDSCli-1.13.002
$export PATH=$PATH:$AWS_RDS_HOME/bin
$export EC2_REGION=ap-northeast-1
$vi cred.txt
# Enter the AWS Keys without the < or >
# These can be found at http://aws.amazon.com under Account->Security Credentials
@YoshihitoAso
YoshihitoAso / hello.js
Created March 13, 2013 08:25
[Node.js]最も簡単なサンプル
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337);
console.log('Server is running');
@YoshihitoAso
YoshihitoAso / hello2.js
Created March 13, 2013 08:26
[Node.js]最も簡単なサンプル2
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write("Hello\n");
setTimeout(function(){
res.end('This is the Node World !!!!\n');
}, 10000);
}).listen(1337);
console.log('Server running');
@YoshihitoAso
YoshihitoAso / socketio_sample.js
Created March 13, 2013 09:53
[Node.js]Socket.ioのサンプルプログラム(server)
require.paths.push('/usr/local/lib/node_modules');
var server = require('http').createServer(function(req, res){
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('server connected');
});
server.listen(1337);
var io = require('socket.io').listen(server);
io.sockets.on('connection', function (socket) {
@YoshihitoAso
YoshihitoAso / index.html
Created March 13, 2013 09:54
[Node.js]Socket.ioのサンプルプログラム(client)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="http://xxx.xxx.xxx.xxx:1337/socket.io/socket.io.js"></script>
<script type="text/javascript">
$(function(){
var socket = io.connect('http://xxx.xxx.xxx.xxx:1337/');
socket.on('connect', function() {