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
# $ python3 -m venv env | |
# $ source env/bin/activate | |
# $ mkdir mysql_test;cd mysql_test | |
# $ pip install mysqlclient -t ./ | |
# mysqlclient is needs "gcc, python-devel, libmysqlclient-devel" | |
# $ vi lambda_function.py | |
# $ zip -r9 lambda_mysql.zip . | |
# zipfile upload to aws. | |
# It may be necessary to set up vpc or subnet |
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 os | |
import urllib.request | |
import subprocess | |
def lambda_handler(event, context): | |
test = test_event_param(event) | |
#submit_url() | |
#cmd_exec() |
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 boto3 | |
def lambda_handler(event, context): | |
AWS_S3_BUCKET_NAME = 'bucket_name' | |
s3_resource = boto3.resource('s3') | |
bucket = s3_resource.Bucket(AWS_S3_BUCKET_NAME) | |
result = bucket.meta.client.list_objects_v2(Bucket=bucket.name, Prefix='bucket_dir') | |
files = [o.get('Key') for o in result.get('Contents') if not o.get('Key').endswith('/')] | |
print(files) | |
return files |
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
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Principal": "*", | |
"Action": "execute-api:Invoke", | |
"Resource": "arn:aws:execute-api:ap-northeast-1:*:*/test_stage/POST/*", | |
"Condition": { | |
"IpAddress": { |
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
function splitString (targetString,separator1,separator2) { | |
console.log('TargetString: "' + targetString + '"'); | |
console.log('Separator1: "' + separator1 + '"'); | |
console.log('Separator1: "' + separator2 + '"'); | |
var arrayOfStrings = targetString.split(separator1); | |
var tmpMap = new Map(); | |
//for (var i = 0; i < arrayOfStrings.length; i++) { | |
// var splitBycolon = arrayOfStrings[i].split(separator2); |
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
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>fetch_api</title> | |
</head> | |
<body> | |
<input type="button" value="GET" onclick=submitGetApi()> | |
<div id="getResult"></div> |
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
datetimeStart = "2018-01-01 00:00:00"; | |
datetimeEnd = "2018-01-01 23:59:59"; | |
function validation(datetimeStart, datetimeEnd) { | |
if (!/^\d{4}-\d{2}-\d{2}\ \d{2}:\d{2}:\d{2}$/.test(datetimeStart)) { | |
return false; | |
} else if (!/^\d{4}-\d{2}-\d{2}\ \d{2}:\d{2}:\d{2}$/.test(datetimeEnd)) { | |
return false; | |
} else if (datetimeStart >= datetimeEnd) { // 0埋めの場合、文字列のまま比較可能 | |
return false; |
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
package test; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.Optional; | |
public class OptionalTest { | |
public static void main(String[] args) { |
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 csv | |
data = [ | |
{ | |
"deta1":"111" | |
,"data2":"222" | |
}, | |
{ | |
"deta1":"333" | |
,"data2":"444" |
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
file_name = 'test.txt' | |
bucket_name= 'bucket-name' | |
bucket_dir = 'bucket-dir' | |
file_path = '/tmp/' + file_name | |
key = bucket_dir + file_name | |
s3bucket = boto3.resource('s3').Bucket(bucket_name) | |
s3bucket.upload_file(file_path, key) |
OlderNewer