ããã®æ´æ°ããã
ãã£ã¡ãæ´æ°ãã¦ãããã¨ã«ãã
Go reflectã使ã£ã¦structã®å¤å ¨ã¦ã«å¦çãè¡ã
ä¾ãã°structã®fieldã« `null` ã¨ããæåãå«ã¾ãã¦ããã空æåã«å¤æããå¦ç
package main import ( "fmt" "reflect" ) func main() { h := Hoge{ Foo: "null", Bar: "aaa", Integer: 2, } fmt.Println("before:", h) ReplaceNullStringToEmpty(&h) fmt.Println("after :", h) } type Hoge struct { Foo string Bar string Integer int64 } func ReplaceNullStringToEmpty(s interface{}) { val := reflect.ValueOf(s).Elem() for i := 0; i < val.NumField(); i++ { if val.Field(i).Kind() == reflect.String { if val.Field(i).String() == "null" { val.Field(i).SetString("") } } } }
go run main.go before: {null aaa 2} after : { aaa 2}
curlã§cognito oauth2èªè¨¼
ä¹
ãã¶ãããã¤pythonã§å®è£
ãã¦è¶
ããã©ãããã£ãã®ã§ã¡ã¢ã
ã¯ã¾ããªããã°ããã§ããã¨æãã
Authorization Code Grantã®æµã
- cognito hosted uiã§ãã°ã¤ã³
- ãµã¼ãã¼ã®ã¢ããªã§redirectãåãä»ãã
- èªå¯ã³ã¼ããtoken endpoint(xxxx.amazoncognito.com/oauth2/token)ã«éã
- id_token, refresh_token, access_tokenãåå¾
- æå¹æéãåããã refresh_token ã使ç¨ã㦠token ãrefresh
ãã®è¾ºãè¦ãã°åãã
tokenåå¾
curl -X "POST" "https://{domain}.auth.us-east-1.amazoncognito.com/oauth2/token" \ -H 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode "grant_type=authorization_code" \ --data-urlencode "client_id=xxxxx" \ --data-urlencode "client_secret=xxx" \ --data-urlencode "code=xxxx" \ --data-urlencode "redirect_uri=https://{redirect_url}"
token refresh
curl -X "POST" "https://{domain}.auth.us-east-1.amazoncognito.com/oauth2/token" \ -H 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode "grant_type=refresh_token" \ --data-urlencode "client_id=xxxx" \ --data-urlencode "client_secret=xxxx" \ --data-urlencode "refresh_token=xxxx"
optionalã§nonceãéãã
Amazon SNS Mobile Pushã§PUSHéç¥
äºãAWSã§ãã£ã¦ãããã¨
- ã¢ããªã±ã¼ã·ã§ã³ãã©ãããã¼ã ãä½æãã¦ãããAPNsãFCMã®æ
å ±ãç»é²ããã
- ããã«ç«¯æ«ã®device tokenãç»é²ãããã¨ã§endpointãåå¾ã§ããã
- ãµã¼ãã¼ã§ã¯ãã®endpoint arnãDBã«ä¿åãã¦ããã
- ã¦ã¼ã¶ã¼(端æ«)ãæå®ãã¦åå¥ã«pushéç¥ãéãããã¨ãã«ä½¿ã
- å
¨ä½PUSHéç¥ç¨ã«TOPICãä½æ
- endpoint arnãä½æããããã®TOPICãsubscribeãã¦ãã
- TOPICã«messageãpublishãããsubscriberã«ä¼æãã¦å ¨ç«¯æ«ã«pushéç¥ãé£ã¶
- 端æ«åå¥ã«pushéç¥ãé£ã°ããã°ããã®ã§ããã°ä½ããªãã¦ãããã
ã³ã¼ããµã³ãã«
ã³ããã§åãã¯ã
<?php $client = new SnsClient([ 'profile' => 'dev_sns', 'region' => 'ap-northeast-1', 'version' => 'latest', ]); // ã¢ããªã±ã¼ã·ã§ã³ãã©ãããã¼ã ã®ã¨ã³ããã¤ã³ããä½æ // ãã®endpointã«publishãããã¨ã§ç«¯æ«æå®ã§pushéç¥ãå¯è½ $result = $client->createPlatformEndpoint([ 'Token' => $token, 'CustomUserData' => $studentId, 'PlatformApplicationArn' => 'arn:aws:sns:ap-northeast-1:xxxxxxxxxxxxxx:app-push-notification-dev' ]); $endpoint = $result['EndpointArn']; // å ¨ä½éç¥ç¨ã®ãããã¯ãsubscribeãã $client->subscribe([ 'Protocol' => 'application', 'Endpoint' => $endpoint, 'TopicArn' => 'arn:aws:sns:ap-northeast-1:xxxxxxxxxxxxxx:app/GCM/app-android-dev', 'Attributes' => [], // android/iosæå®ã§ãã£ã«ã¿ã§ããããã«è¨å®ãã¦ããããã ]); // endpointãæå®ãã¦åå¥ã«pushéç¥ $client->publish([ 'Subject' => 'title', 'Message' => 'message', 'TargetArn' => $endpoint, ]); // topicãæå®ãã¦å ¨ä½ã«pushéç¥ $client->publish([ 'Subject' => 'title', 'Message' => 'message', 'TargetArn' => 'arn:aws:sns:ap-northeast-1:xxxxxxxxxxxxxx:app/GCM/app-android-dev', ]);
CannotStartContainerError: Error response from daemon: failed to initialize logging driver: failed to create Cloudwatch log stream: ResourceNotFoundException: The specified log group does not exist. status code: 400, request id: xxx
- ã¿ã¹ã¯ãã¼ã« ecsTaskExecutionRole ã¯CloudwatchLogsã®ã°ã«ã¼ããä½æãã権éããªãã£ã½ã
- ããããã®ãåºã CannotStartContainerError: Error response from daemon: failed to initialize logging driver: failed to create Cloudwatch log stream: ResourceNotFoundException: The specified log group does not exist. status code: 400, request id:
- ååã ãæåã§ä½ãã°OK
- èµ·åã¿ã¤ããEC2ã«ããå ´åãèªåã§EC2ãèµ·åãã¦ã¯ã©ã¹ã¿ã«joinãããæé ãå¿ è¦
ããããç¥ããªãã¦ããã£ãã®ã§ã¡ã¢
hanami
hanamiã¨ããrubyã®ãã¬ã¼ã ã¯ã¼ã¯ããããããã
ã¯ãªã¼ã³ã¢ã¼ããã¯ãã£ã«å½±é¿ãåãã¦ãããããã
軽ãã°ã°ã£ãæãè¯ãããã
ç§å¯ã®ã°ãªã«ã¡ãã
åæã®ç·åãã£ã³ãã«åãã¦è²·ã£ã¦ã¿ãã
ãã£ã¡ã楽ãã¿ã
youtubeã§ã¬ãã¥ã¼åç»ãè¦ã¦ã¿ãã¨ãããæ¿ãã便å©ããã