Skip to content

Instantly share code, notes, and snippets.

View yusukemurayama's full-sized avatar

Yusuke Murayama yusukemurayama

View GitHub Profile
# coding: utf-8
import os
import logging
import re
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
logger.addHandler(ch)
@yusukemurayama
yusukemurayama / print_4xx_report.php
Last active January 7, 2016 04:13
PHPを使って、CloudWatch Logsからデータを取得します。
<?php
require 'aws/aws-autoloader.php';
class LogReport {
const LOG_GROUP_NAME = 'LOG_GROUP_NAME';
const FILTER_PATTERN = '[ip, dummy1, uid, timestamp, request, status_code = 4*, bytes, referer, user_agent]';
const PATH_PATTERN = '/"(?:GET|POST|HEAD) ([^ ]+) [^ ]+" \d{3}/';
const AWS_PROFILE = 'dummy_account';
const AWS_VERSION = 'latest';
const AWS_REGION = 'ap-northeast-1';
<?php
// https://github.com/ChristianRiesen/base32 を利用しました。
require_once 'Base32.php';
use Base32\Base32;
class Totp {
/**
* コンストラクタ
*
# coding: utf-8
import sys
import argparse
def sample1():
"""
ハイフンがある引数を取る場合
引数の例)
# coding: utf-8
import abc
class NoAbstractBase(object):
def method1(self):
pass
def method2(self):
pass
# coding: utf-8
from contextlib import contextmanager
from datetime import datetime
from sqlalchemy import (
create_engine, Column, ForeignKey, Integer, Float, String,
Date, DateTime
)
from sqlalchemy.ext.declarative import declarative_base, declared_attr
from sqlalchemy.orm import sessionmaker, reconstructor, relationship
# coding: utf-8
class BaseModelMixin(object):
def save(self, exclude_fields=None, *args, **kwds):
if not exclude_fields:
# exclude_fieldsがない場合は、親のsaveメソッドをそのまま呼んで返します。
return super().save(*args, **kwds)
if 'update_fields' in kwds:
raise Exception('exclude_fieldsはupdate_fieldsと同時に指定することはできません。')