Skip to content

Instantly share code, notes, and snippets.

View taizo's full-sized avatar
🎌
Working from home

Taizo Ito taizo

🎌
Working from home
  • HENNGE K.K.
  • Tokyo, Japan
View GitHub Profile
@taizo
taizo / awc-ecs-access-to-aws-efs.md
Created June 7, 2018 09:14 — forked from duluca/awc-ecs-access-to-aws-efs.md
Step-by-step Instructions to Setup an AWS ECS Cluster

Configuring AWS ECS to have access to AWS EFS

If you would like to persist data from your ECS containers, i.e. hosting databases like MySQL or MongoDB with Docker, you need to ensure that you can mount the data directory of the database in the container to volume that's not going to dissappear when your container or worse yet, the EC2 instance that hosts your containers, is restarted or scaled up or down for any reason.

Don't know how to create your own AWS ECS Cluster? Go here!

New Cluster

Sadly the EC2 provisioning process doesn't allow you to configure EFS during the initial config. After your create your cluster, follow the guide below.

New Task Definition for Web App

If you're using an Alpine-based Node server like duluca/minimal-node-web-server follow this guide:

@taizo
taizo / manageFlaskSession.py
Created June 21, 2017 04:13 — forked from aescalana/manageFlaskSession.py
Decode and Encode Flask's session cookie. Great for testing purposes; only the secret key is needed
#!/usr/bin/env python
from flask.sessions import SecureCookieSessionInterface
from itsdangerous import URLSafeTimedSerializer
class SimpleSecureCookieSessionInterface(SecureCookieSessionInterface):
# Override method
# Take secret_key instead of an instance of a Flask app
def get_signing_serializer(self, secret_key):
if not secret_key:
return None
@taizo
taizo / jQuery.footerFixed.js
Created March 24, 2017 01:39 — forked from ginlime/jQuery.footerFixed.js
jQuery version of footerFixed.js
/*--------------------------------------------------------------------------*
*
* jQuery.footerFixed.js
*
* MIT-style license.
*
* ported by @ginlime
* https://gist.github.com/ginlime
*
* original written by:
@taizo
taizo / file0.txt
Created March 23, 2017 08:44 — forked from saitara/file0.txt
AWSで全てのリージョンから無駄リソースを抽出するワンライナー ref: http://qiita.com/saitara/items/a1e3422042a2ec2fb8d7
for region in `aws ec2 describe-regions --query 'Regions[].RegionName' --output text`;do aws ec2 describe-volumes --region ${region} --filters Name=attachment.status,Values=detached;done
#!/bin/bash
# Invoke this script with a relative '.app' path, for example:
# codesign-electron.sh "darwin-x64/Electron.app"
# 1. Run the following command to get a list of identities:
# security find-identity
# 2. Now set the value of the identity variable below to the identity you want to use:
identity="Developer ID Application: ... (...)"
@taizo
taizo / sendfile.py
Created August 10, 2016 04:56 — forked from lizhiwei/sendfile.py
response to a range request with python Flask framework
from flask import Response, request
from werkzeug.datastructures import Headers
from time import time
from re import findall
def send_file(musicFile , cachetimout, stream=True):
headers = Headers()
headers.add('Content-Disposition', 'attachment', filename=musicFile.filename)
@taizo
taizo / send_file_partial.py
Created August 9, 2016 09:37 — forked from lizhiwei/send_file_partial.py
HTTP 206 (Partial Content) For Flask
import mimetypes
import os
import re
from flask import request, send_file, Response
@app.after_request
def after_request(response):
response.headers.add('Accept-Ranges', 'bytes')
return response
@taizo
taizo / trac2down.py
Created July 28, 2016 10:07 — forked from sgk/trac2down.py
Trac Wiki to Markdown converter
#!/usr/bin/python
# vim:set fileencoding=utf-8 sw=2 ai:
import sqlite3
import datetime
import re
SQL = '''
select
name, version, time, author, text
@taizo
taizo / Dockerfile:devpi-server
Last active July 26, 2016 05:01
Dockerfile:devpi-server
# build: docker build -t devpi-server .
# run: docker run -d -p 18080:18080 --name devpi-server-run devpi-server
FROM ubuntu
EXPOSE 18080
ENV DEBIAN_FRONTEND noninteractive
VOLUME ["/var/cache/devpi"]
RUN apt-get update && \
apt-get install --no-install-recommends -y python3-pip && \
pip3 install -U pip devpi-server
@taizo
taizo / aws_usage.py
Created July 13, 2016 03:41 — forked from rcoup/aws_usage.py
A script to query the Amazon Web Services (S3/EC2/etc) usage reports programmatically.
#!/usr/bin/env python
"""
A script to query the Amazon Web Services usage reports programmatically.
Ideally this wouldn't exist, and Amazon would provide an API we can use
instead, but hey - that's life.
Basically takes your AWS account username and password, logs into the
website as you, and grabs the data out. Always gets the 'All Usage Types'