Skip to content

Instantly share code, notes, and snippets.

@fukasawah
fukasawah / LICENSE
Created June 8, 2023 18:18
(TypeScript+AWS SDK v3)DynamoDBテーブルから全レコードを削除する関数 (Delete all records from a DynamoDB table)
Copyright (c) 2023 fukasawah
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
@fukasawah
fukasawah / pull-request-comment.py
Created April 5, 2022 00:31
Azure PipelinesでPullRequestにコメントをつけるだけのスクリプト
#!/usr/bin/env python
# env:
# SYSTEM_ACCESSTOKEN: $(System.AccessToken)
# usage)
# echo hello | python pull-request-comment.py
# test)
# # https://gist.github.com/fukasawah/d8ecaea8ac2b73f440b7193cdb295e92
# python echo-http-server.py &
@fukasawah
fukasawah / echo-http-server.py
Last active April 4, 2022 03:10
PythonのHTTP POSTをオウム返しするHTTPServer
#/usr/bin/python
# usage) python echo-http-server.py
from http.server import HTTPServer, BaseHTTPRequestHandler
class EchoHandler(BaseHTTPRequestHandler):
def do_POST(self):
self.send_response(200)
self.send_header('Content-type', 'text/plain; charset=utf-8')
@fukasawah
fukasawah / azure.yaml
Created March 9, 2022 22:25
Azure関連の情報発信している人のFeed URL
- feed: https://blog.azure.moe/feed/
tags:
- Japan
- MVP
- feed: https://jpaztech.github.io/blog/atom.xml
tags:
- Japan
- Microsoft
- feed: https://jpazpaas.github.io/blog/feed.xml
tags:
@fukasawah
fukasawah / min.log
Created March 8, 2022 11:59
result.md
$ for file in vmftest*; do echo $file; grep 'rtt min/avg/max/mdev' "$file" | perl -ple 's/.* = ([^\/]+).*/$1/' ; done
vmftest1-4tqb.japaneast.cloudapp.azure.com.log
0.937
1.979
1.424
0.571
1.672
2.009
vmftest1-6keq.japaneast.cloudapp.azure.com.log
0.628
@fukasawah
fukasawah / Linux-consumption-japan.json
Created January 18, 2022 12:27
Azure FunctionのタイムゾーンとWEBSITE_TIME_ZONEが機能するか検証(2022/01/18)
{
"now": "2022-01-18T04:43:11.5121004+00:00",
"utcNow": "2022-01-18T04:43:11.5121027Z",
"timezone": {
"Id": "Etc/UTC",
"DisplayName": "(UTC+00:00) GMT",
"StandardName": "GMT",
"DaylightName": "GMT",
"BaseUtcOffset": "00:00:00",
"AdjustmentRules": [
@fukasawah
fukasawah / testserver.py
Last active July 16, 2021 03:25
疎通確認用のHTTPサーバ(python3)
'''
Usage) sudo python3 testserver.py 80
'''
import sys
import http.server
class TestHttpRequestHandler(http.server.BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
@fukasawah
fukasawah / lock-and-run.sh
Last active June 30, 2021 03:56
AzureのAppServiceでインスタンス間の排他制御をBlobのLeaseを使って試みるサンプル
#!/bin/sh
set -ue
#
# usage) bash lock-and-run.sh "echo" "hello lock world"
#
### **次の項目は適宜書き換える** ###
@fukasawah
fukasawah / main.php
Created June 7, 2021 16:45
PHPでHS256なJWTを作る
<?php
function encodeBase64Url($value)
{
$value = base64_encode($value);
$value = strtr($value, '+/', '-_'); // https://datatracker.ietf.org/doc/html/rfc4648#section-5
$value = rtrim($value, "="); // without padding, https://datatracker.ietf.org/doc/html/rfc7515#appendix-C
return $value;
}
function generateJwtHS256($payload, $tokenKeyB64)
@fukasawah
fukasawah / ip-check.py
Created May 25, 2021 05:47
Azure IP Check script sample
# ### Usage ###
# mkdir data
# az account list-locations --query "[].name" --output tsv | tr -d "\r" | while read region; do az network list-service-tags --location "$region" > "data/list-service-tags-${region}.json"; done;
# python ip-check.py "data/list-service-tags-japaneast.json" "10.0.0.1"
import sys
import ipaddress
import json