This file contains 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
#!/bin/bash | |
raspistill -vf -hf -o /home/pi/raspberry_bot/scripts/wawawa.jpg | |
curl -F file=@/home/pi/raspberry_bot/scripts/wawawa.jpg -F channels=CHANNELID -F token=xoxb-000000000000-XXXXXXXXXXXXXXXXXXXXXXXX https://slack.com/api/files.upload |
This file contains 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
module.exports = (robot) -> | |
robot.respond /写真/, (msg) -> | |
@exec = require('child_process').exec | |
command = "raspistill -vf -hf -o /home/pi/raspberry_bot/scripts/wawawa.jpg; | |
curl -F file=@/home/pi/raspberry_bot/scripts/wawawa.jpg -F channels=C99999999 -F token=xoxb-9999999999999999-XXXXXXXXXXXXXXXXXXXXXXXX https://slack.com/api/files.upload" | |
#msg.send "Command: #{command}" | |
msg.send "しゃしんとってるよ。ちょっとまってね。" | |
@exec command, (error, stdout, stderr) -> | |
@msg.send error if error? | |
#msg.send stdout if stdout? |
This file contains 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
Resources: | |
Instance: | |
Type: "AWS::EC2::Instance" | |
Properties: | |
AvailabilityZone: "ap-northeast-1a" | |
ImageId: "ami-4af5022c" | |
InstanceType: "t2.micro" | |
KeyName: "キーペア名" | |
SecurityGroupIds: | |
- "sg-XXXXXXX" |
This file contains 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
Resources: | |
Instance: | |
Type: "AWS::EC2::Instance" | |
Properties: | |
AvailabilityZone: "ap-northeast-1a" | |
ImageId: "ami-4af5022c" | |
InstanceType: "t2.micro" | |
KeyName: "キーペア名" | |
PrivateIpAddress: "192.140.1.1" | |
SecurityGroupIds: |
This file contains 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
Resources: | |
Instance: | |
Type: AWS::EC2::Instance | |
Properties: | |
AvailabilityZone: ap-northeast-1a | |
ImageId: ami-XXXXXXXX | |
InstanceType: t2.micro | |
KeyName: キーペア名 | |
NetworkInterfaces: | |
- AssociatePublicIpAddress: "true" |
This file contains 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
Resources: | |
User1: | |
Type: "AWS::IAM::User" | |
Properties: | |
Groups: | |
- AdministratorGroup | |
LoginProfile: | |
Password: wawawa | |
PasswordResetRequired: True | |
ManagedPolicyArns: |
This file contains 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 json | |
import boto3 | |
def lambda_handler(event, context): | |
ec2 = boto3.client("ec2") | |
response = ec2.describe_instances() | |
for i in response["Reservations"]: | |
print("ID: ",i["Instances"][0]["InstanceId"]) | |
print("最終起動時刻: ",i["Instances"][0]["LaunchTime"]) |
This file contains 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
#!/bin/bash | |
# IPアドレスを2進数に変換する | |
# 実行例 | |
# $ ./address.sh 172.24.140.1/26 | |
# Netmask: 11111111 11111111 11111111 11000000 | |
# Address: 10101100 00011000 10001100 00000000 | |
address=${1} |
This file contains 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
#!/bin/bash | |
instanceid=`echo "${1}"` | |
output_type=`echo "${2}"` | |
if [ ${#} -ne 2 ] | |
then | |
echo "usage:${0} instanceid [json|table|text]" | |
exit 1 | |
fi |
This file contains 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
from datetime import datetime | |
time_format = '%H%M' | |
a_time = '1730' | |
b_time = '1700' | |
time_diff = datetime.strptime(a_time,time_format) - datetime.strptime(b_time,time_format) | |
print(time_diff) |