Skip to content

Instantly share code, notes, and snippets.

@homoluctus
homoluctus / interfaces.ts
Last active July 4, 2021 08:40
Post tweet with Twitter API 1.1
export interface RequestQuery {
[name: string]: any;
}
export interface OAuthSignatureSource {
oauthConsumerKey: string;
oauthToken: string;
oauthNonce: string;
oauthTimestamp: string;
oauthSignatureMethod: string;
@homoluctus
homoluctus / rds_proxy.yml
Created August 16, 2020 22:36
RDS Proxy CloudFormation Template
AWSTemplateFormatVersion: "2010-09-09"
Parameters:
# DB Proxy
ProxyName:
Type: String
ProxyEngineFamily:
Type: String
AllowedValues:
- MYSQL
AWSTemplateFormatVersion: "2010-09-09"
Parameters:
CWLogsExportBucketName:
Description: "S3 buket name for CW Logs backup"
Type: String
CWLogsExportBucketLifecycleStatus:
Description: "Apply lifecycle or not"
Type: String
AllowedValues: ["Disabled", "Enabled"]
@homoluctus
homoluctus / .env
Last active August 12, 2019 06:12
当日の天気を知らせてくれるSlack Botを作ってみた(Python + Selenium + Slack + AWS ECS + Github Actions)
ACCESS_TOKEN=xxxxxxxx
CHANNEL=xxxxxxxx
URL=https://tenki.jp/forecast/3/16/4410/13101/3hours.html
TARGET=forecast-point-3h-today
@homoluctus
homoluctus / check_sha256sum.sh
Created April 13, 2019 06:09
check sha256sum
#!/bin/bash
TEST=`sha256sum $1 | cut -d ' ' -f 1`
if [ $TEST = $2 ]; then
echo "SUCEESS"
else
echo "FAIL"
fi
#!/bin/bash
TYPE=$1
INTERVAL='u1'
COUNT='1000000'
case $TYPE in
"1") docker exec -it r2 ip netns exec attack \
hping3 --icmp -q -i $INTERVAL -c $COUNT 198.51.100.2 ;;
"2") docker exec -it r2 ip netns exec attack \
import sys
from log import set_logger
from time import sleep
from mq import MQConsumer
LOGFILE = '/etc/exabgp/log'
LOGGER = set_logger(LOGFILE)
@homoluctus
homoluctus / demo_python_iptables.py
Created January 6, 2019 07:58
Manipulate iptables using python-iptables
import iptc
import ipaddress
def format_address(address):
"""
Support IPv4 only yet.
Return IPv4 with prefix length (e.g. 192.168.0.1/32)
"""
@homoluctus
homoluctus / demo_client.py
Created January 4, 2019 21:23
Socket I/O Multiplexing
import sys
import socket
from time import sleep
from threading import Thread
SERVER = '127.0.0.1'
PORT = 9999
def client(timeout=0):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
@homoluctus
homoluctus / tcp_client.py
Created October 31, 2017 11:20
simple tcp client with python3.6
# -*- conding: utf-8 -*-
import socket
# address and port is arbitrary
def client(host="127.0.0.1", port=60260):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
sock.connect((host, port))
while True: