Skip to content

Instantly share code, notes, and snippets.

Yusuke Murayama yusukemurayama

Block or report user

Report or block yusukemurayama

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View common_models.py
# 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と同時に指定することはできません。')
View sqlalchemy_samples.py
# 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
View abc_samples.py
# coding: utf-8
import abc
class NoAbstractBase(object):
def method1(self):
pass
def method2(self):
pass
View argparse_samples.py
# coding: utf-8
import sys
import argparse
def sample1():
"""
ハイフンがある引数を取る場合
引数の例)
View totp.php
<?php
// https://github.com/ChristianRiesen/base32 を利用しました。
require_once 'Base32.php';
use Base32\Base32;
class Totp {
/**
* コンストラクタ
*
View jquery.disable_links.js
@yusukemurayama
yusukemurayama / print_4xx_report.php
Last active Jan 7, 2016
PHPを使って、CloudWatch Logsからデータを取得します。
View print_4xx_report.php
<?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';
View report_4xxlogs.py
# 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)
You can’t perform that action at this time.