Skip to content

Instantly share code, notes, and snippets.

@shiro01
shiro01 / count_result_pivot.sql
Created August 24, 2018 02:06
カウントした値を横に並べる
MariaDB [test]> SELECT * FROM goods_status;
+------+--------+----------+
| id_g | status | category |
+------+--------+----------+
| 1 | 1 | 101 |
| 2 | 1 | 120 |
| 3 | 2 | 120 |
| 4 | 2 | 101 |
| 5 | 3 | 101 |
| 6 | 3 | 120 |
@shiro01
shiro01 / QuickSight_ManifestFile_S3_CSV_File.json
Last active October 3, 2018 01:10
QuickSightのデータセット作成用Manifestファイルのサンプル
{
"fileLocations": [
{
"URIPrefixes": [
"https://s3-ap-northeast-1.amazonaws.com/your-bucket-name/dir/"
]
}
],
"globalUploadSettings": {
"format": "CSV",
@shiro01
shiro01 / elixir_study_memo.txt
Created August 24, 2018 10:04
Elixir 勉強メモ
iex(24)> 1 or true
** (BadBooleanError) expected a boolean on left-side of "or", got: 1
iex(19)> 1 and true
** (BadBooleanError) expected a boolean on left-side of "and", got: 1
iex(19)> true and 1
1
@shiro01
shiro01 / arrowSample.js
Created September 14, 2018 07:43
アロー関数サンプル
var materials = [
'test1',
'aaaa',
'hogehogheo',
'wwawawawawa'
];
materials.map(test);
// expected output: Array [8, 6, 7, 9]
function test(value) {
@shiro01
shiro01 / aws_policy_memo.json
Last active April 23, 2019 05:03
AWSのポリシーメモ
特定のS3バケットへのアクセス許可
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "S3ACCESS01",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:PutObjectAcl",
@shiro01
shiro01 / study_elixir.exs
Created September 19, 2018 10:20
WandboxでElixirを勉強した時のログ
defmodule Wandbox do
def hello() do
IO.write "Hello, "
IO.puts "World, Wandbox!"
IO.inspect "debug"
IO.inspect Foo.x
IO.puts Foo.x
IO.inspect("hoge")
IO.puts "-----"
@shiro01
shiro01 / athena_table_read_csv_file.sql
Created October 15, 2018 09:21
CSVファイル読み込むAthenaテーブル作成用CREATE文 (LazySimpleSerDe)
CREATE EXTERNAL TABLE IF NOT EXISTS test_db.test_table (
`test_date` date,
`test_id` string,
`test_num` int
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'serialization.format' = ',',
'field.delim' = ','
) LOCATION 's3://test-bucket/test-folder/'
@shiro01
shiro01 / s3_file_copy.py
Created October 17, 2018 05:33
S3のファイルをコピーする
# S3バケット内のファイルコピー
def athena_query_result_copy(target_bucket, target_key, output_bucket, output_key):
s3client = boto3.client('s3')
s3client.copy_object(
Bucket=output_bucket,
Key=output_key,
CopySource={
'Bucket': target_bucket,
'Key': target_key
@shiro01
shiro01 / athena_query_submit_and_copy_result_file.py
Last active December 17, 2021 04:20
Athenaにクエリを実行しS3に保存されたファイルを別のフォルダにファイル名を変更しつつ移動する。
import boto3
import os
import time
from datetime import datetime
from datetime import timedelta
def lambda_handler(event, context):
query = build_query()
target_db = os.environ['TARGET_DB']
@shiro01
shiro01 / aws_cli_memo.txt
Last active September 18, 2019 06:23
AWS CLIのサンプル。
centosへのインストール(Python3がインストールされていること)
https://docs.aws.amazon.com/ja_jp/cli/latest/userguide/cli-chap-install.html
$ pip3 install awscli --upgrade --user
コンフィグ設定
aws configure --profile dev
AWS Access Key ID [None]: hogehoge
AWS Secret Access Key [None]: hogehoge