This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
def lambda_handler(event, context): | |
command = event.get('command') | |
if command in ['start', 'stop', 'status']: | |
try: | |
instance = boto3.resource('ec2').Instance(event.get('target')) | |
state = instance.state['Name'] | |
if command == 'start' and state == 'stopped': | |
instance.start() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding: UTF-8 | |
import os | |
import smtplib | |
from email.mime.text import MIMEText | |
# Gmailアカウント | |
FROM_ADDR = os.environ['mail_from_addr'] | |
# アプリパスワード | |
PASSWD = os.environ['mail_passwd'] | |
# 送信先メールアドレス |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding: UTF-8 | |
import os | |
import json | |
import urllib.request, urllib.parse | |
SEND_URL = 'https://fcm.googleapis.com/fcm/send' | |
def lambda_handler(event, context): | |
headers = { | |
'Content-Type': 'application/json', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- ../html.bak/index.html 2019-07-04 03:46:11.000000000 +0900 | |
+++ index.html 2019-07-04 11:45:24.008447808 +0900 | |
@@ -75,9 +75,22 @@ | |
<!-- Import and configure the Firebase SDK --> | |
<!-- These scripts are made available when the app is served or deployed on Firebase Hosting --> | |
<!-- If you do not serve/host your project using Firebase Hosting see https://firebase.google.com/docs/web/setup --> | |
-<script src="/__/firebase/6.2.4/firebase-app.js"></script> | |
-<script src="/__/firebase/6.2.4/firebase-messaging.js"></script> | |
-<script src="/__/firebase/init.js"></script> | |
+<script src="https://www.gstatic.com/firebasejs/6.2.4/firebase-app.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- ../html.bak/firebase-messaging-sw.js 2019-07-04 03:46:11.000000000 +0900 | |
+++ firebase-messaging-sw.js 2019-07-04 11:41:01.940048485 +0900 | |
@@ -1,9 +1,19 @@ | |
// Import and configure the Firebase SDK | |
// These scripts are made available when the app is served or deployed on Firebase Hosting | |
// If you do not serve/host your project using Firebase Hosting see https://firebase.google.com/docs/web/setup | |
-importScripts('/__/firebase/5.5.6/firebase-app.js'); | |
-importScripts('/__/firebase/5.5.6/firebase-messaging.js'); | |
-importScripts('/__/firebase/init.js'); | |
+importScripts('https://www.gstatic.com/firebasejs/6.2.4/firebase-app.js'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd /usr/share/nginx/html/ | |
svn export --force https://github.com/firebase/quickstart-js/trunk/messaging . | |
cp -pr . ../html.bak | |
vi firebase-messaging-sw.js | |
diff -u ../html.bak/firebase-messaging-sw.js firebase-messaging-sw.js > ../firebase-messaging-sw.js.patch | |
vi index.html | |
diff -u ../html.bak/index.html index.html > ../index.html.patch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export AUTH_KEY=ここにクラウドメッセージングタブのサーバーキーを入力 | |
export SEND_TO=ここにブラウザで取得したInstance ID Tokenを入力 | |
curl -X POST -H "Authorization: key=$AUTH_KEY" -H "Content-Type: application/json" -d '{ "notification": { "title": "This is Title!!!", "body": "Body Body Body.", "icon": "firebase-logo.png" }, "to": "'$SEND_TO'" }' "https://fcm.googleapis.com/fcm/send" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<meta charset="utf-8"> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> | |
</head> | |
<body> | |
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import json | |
import urllib.request, urllib.parse | |
URL = 'https://api.line.me/v2/bot/message/push' | |
def lambda_handler(event, context): | |
to = event['to'] if 'to' in event.keys() else os.environ['SEND_TO'] | |
token = event['token'] if 'token' in event.keys() else os.environ['CHANNEL_TOKEN'] | |
headers = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding: UTF-8 | |
import os | |
import boto3 | |
import json | |
import copy | |
import urllib.request, urllib.parse | |
from datetime import datetime, timedelta | |
URL = 'https://api.line.me/v2/bot/message/push' |