Skip to content

Instantly share code, notes, and snippets.

View cent07にmysql-clientをインストール
rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
yum install mysql-community-client
@suganoo
suganoo / s3downloadwithproxy.go
Last active Feb 20, 2018
Go言語でs3からファイルダウンロード+プロキシ使う版
View s3downloadwithproxy.go
package main
import (
"net/http"
"net/url"
"os"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
@suganoo
suganoo / 01_get_username.py
Last active Nov 10, 2017
ユーザー名の取得
View 01_get_username.py
import os
import getpass
import pwd
print(os.getlogin())
print(getpass.getuser())
print(os.environ.get("USER"))
print(pwd.getpwuid(os.getuid())[0])
@suganoo
suganoo / ホスト名の確認.md
Last active Oct 27, 2017
ホスト名がどこから読んでいるか
View ホスト名の確認.md

01.何も変更しない状態(default)

/etc/hosts
127.0.0.1 samplehost localhost localhost.localdomain
# python -c 'import socket; print socket.getfqdn()'
localhost.localdomain
# python -c 'import socket; print socket.gethostname()'
samplehost
@suganoo
suganoo / 01 hostnamecheck.py
Last active Oct 26, 2017
ホスト名を取得
View 01 hostnamecheck.py
import socket
import os
import platform
print socket.getfqdn()
# 以降は同じみたい
print socket.gethostname()
print os.uname()[1]
print platform.uname()[1]
@suganoo
suganoo / 01 str_num_to_int_list.py
Last active Oct 22, 2017
文字列数字をint型リストにする
View 01 str_num_to_int_list.py
input_num="1,2,3,4"
print("### original ###")
print(input_num)
print("### result split ###")
print(input_num.split(","))
print("### result split map ###")
print(map(int,input_num.split(",")))
@suganoo
suganoo / 01 logging_formatter.conf
Last active Oct 17, 2017
ユーザー定義のLogRecord属性
View 01 logging_formatter.conf
# もちろん必要部分は書いてください
# 説明上formatだけ記述します。
......................
[formatter_hogehogeFormatter]
format=%(asctime)s%(tab)s%(hostname)s%(tab)s%(user)s%(tab)s%(message)s
@suganoo
suganoo / 01_file_list
Last active Oct 15, 2017
【globals()】文字列からクラス生成する
View 01_file_list
# ファイルが下記のように配置されてるとする
include_script_1.py
include_script_2.py
test_1.py
test_2.py
@suganoo
suganoo / 01_list_set_list.py
Created Sep 12, 2017
リストで重複除く
View 01_list_set_list.py
list_a = ["a","a","a","a","b","b","c","d","d","d"]
print "before: %s" % list_a
print "after: %s" % list(set(list_a))
@suganoo
suganoo / error_output.txt
Last active Jul 23, 2018
json パースでTypeError: string indices must be integers
View error_output.txt
self.filepath = self._get_value_from_messageattributes("filepath")
File "/xxxxxx/test.py", line 93, in _get_value_from_messageattributes
self.logger.debug("return value : %s", self.message["Message"][key]["Value"])
TypeError: string indices must be integers
You can’t perform that action at this time.