Skip to content

Instantly share code, notes, and snippets.

@na0AaooQ
na0AaooQ / UserData
Last active March 1, 2024 04:49
Amazon LinuxにRuby Sinatra環境構築(rbenv + ruby-build + Ruby 2.3.1 + Sinatra 1.4.7インストール) ref: http://qiita.com/na0AaooQ/items/d7f814b184c6c1bd9d9c
#!/bin/sh
echo "User Data start"
yum -y update
unalias cp
cp -f -p /usr/share/zoneinfo/Japan /etc/localtime
cat << _EOT_ > /etc/sysconfig/clock
@na0AaooQ
na0AaooQ / example_playbook.yml
Last active March 1, 2024 04:49
Anshible を使って Amazon EC2 にyumで指定したパッケージをインストールする ref: http://qiita.com/na0AaooQ/items/4beea16dbe6a73f6f21e
---
- hosts:
- localhost
connection: local
tasks:
- name: update all packages
yum: name=* state=latest
become: yes
@na0AaooQ
na0AaooQ / file0.txt
Created January 19, 2015 18:54
AWS EC2インスタンス CloudWatch Logs(awslogs)インストールとCloudWatch保存対象ログの追加 ref: http://qiita.com/na0AaooQ/items/a3b0e5384399b66b742b
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"logs:*"
],
"Effect": "Allow",
"Resource": "*"
}
@na0AaooQ
na0AaooQ / confirm.html.erb
Last active January 11, 2020 22:33
Ruby on Rails 5 で問い合わせフォーム作成 (問い合わせ内容をメールで送信 + ChatWorkで通知する) ref: https://qiita.com/na0AaooQ/items/19d9fb4bfd22dba3e55f
<div class="page-header">
<h1>問い合わせ確認画面</h1>
</div>
<%= form_for @inquiry, :url => inquiry_thanks_path do |f| %>
<table class="table">
<tr>
<th>名前</th>
<td>
<%= f.hidden_field :name %>
@na0AaooQ
na0AaooQ / example.js
Last active September 19, 2019 13:43
AWS LambdaでAmazon RDS for MySQLへ接続する(Node.js 4.3 + KMSで暗号化したMySQL接続パスワードをkms.decryptで復号化してMySQLヘ接続 + バッチ実行をSNS通知する) ref: http://qiita.com/na0AaooQ/items/ff9ab6ce9831236b3ea6
var AWS = require('aws-sdk');
var mysql = require('mysql');
// KMSにより暗号化したMySQL接続用のパスワード文字列
var kmsEncyptedToken = "CiC*********(KMSで暗号化したMySQL接続用のパスワード文字列)***********UI=";
// 接続先のMySQLサーバ情報
var mysql_host = "example-rds-mysql-server.carvmoii2uds.ap-northeast-1.rds.amazonaws.com";
var mysql_user = "example_user";
var mysql_dbname = "exampledb";
[ec2-user@example-server ~]$ mysql -u example_user -p -h example-rds-mysql-server.carvmoii2uds.ap-northeast-1.rds.amazonaws.com
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.6.27-log MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
@na0AaooQ
na0AaooQ / file0.txt
Last active February 13, 2019 14:05
AWS S3上に保存されているファイルの更新タイムスタンプチェック ref: https://qiita.com/na0AaooQ/items/a6a209742bbe073ed12e
$ aws s3 sync s3://test-web-data-store/test/ /home/ec2-user/
download: s3://test-web-data-store/test/test2.txt to ./test2.txt
download: s3://test-web-data-store/test/test.txt to ./test.txt
$
@na0AaooQ
na0AaooQ / file0.txt
Last active January 14, 2019 02:20
cURLコマンドとシェルスクリプトでSalesforce Chatter REST APIを実行してChatterメッセージを投稿する ref: https://qiita.com/na0AaooQ/items/037434830b69e9b45ffd
$ vi push_salesforce_chatter_message.sh
@na0AaooQ
na0AaooQ / file0.txt
Last active December 24, 2018 17:51
cURLコマンドでSalesforce REST APIを実行する ref: https://qiita.com/na0AaooQ/items/a6f733f13a79658da956
[ec2-user@salesforce-api-test ~]$ rpm -qa | grep openssl
openssl-1.0.1k-15.93.amzn1.x86_64
[ec2-user@salesforce-api-test ~]$
@na0AaooQ
na0AaooQ / c2ptcli.go
Last active December 24, 2018 17:06
Go言語でSlack,Chatwork,LINEへチャットメッセージを投稿するコマンド作成 (Windows,Linux,Macに対応したコマンドを作成する) ref: https://qiita.com/na0AaooQ/items/7f937ff1fd938eb89b6a
package main
import (
"fmt"
"os"
"net/http" // チャットAPIコール用
"net/url" // チャットAPIコール用
"strings" // チャットAPIコール用
"bytes" // LINE Messaging APIコール用
"encoding/json" // JSONパース用