This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Cloud Function: DeleteInstance | |
| google-api-python-client==1.7.8 | |
| Environment Variable | |
| AUTO_TOKEN: a value which is set in Stackdriver Notification WebHook | |
| """ | |
| import json | |
| import os |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from random import randint | |
| from enum import Enum | |
| class Card(Enum): | |
| Rock = 0 | |
| Paper = 1 | |
| Scissors = 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| alert("hoge"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| import aiohttp | |
| import async_timeout | |
| from aiohttp import ClientError | |
| async def _fetch(session, url, coro): | |
| """HTTPリソースからデータを取得しコルーチンを呼び出す |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # put service-account-key to ./credentials.json | |
| # docker build -t image/gsutil:0.1 . | |
| # docker run --rm -it image/gsutil:0.1 ls gs://your_backet | |
| FROM alpine:3.7 | |
| RUN apk update && apk add python \ | |
| && wget https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-180.0.0-linux-x86_64.tar.gz \ | |
| && tar zxvf google-cloud-sdk-180.0.0-linux-x86_64.tar.gz \ | |
| && ./google-cloud-sdk/install.sh \ | |
| && google-cloud-sdk/bin/gcloud config set component_manager/disable_update_check true | |
| COPY credentials.json ./credentials.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import unittest | |
| import json | |
| from mock import Mock, patch | |
| from google.appengine.ext import testbed | |
| class FetchTestCase(unittest.TestCase): | |
| def setUp(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import abc | |
| def get_from_nested(dic, keys=None, default=None): | |
| """ | |
| >>> get_from_nested({'hoge': {'fuga': 1}}, keys=['hoge'], default=[]) | |
| {'fuga': 1} | |
| >>> get_from_nested({'hoge': {'fuga': 1}}, keys=['hoge', 'fuga'], default=[]) | |
| 1 | |
| >>> get_from_nested({'hoge': {'fuga': 1}}, keys=['hoge', 'fuga', 'yeah'], default=[]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [SECTION1] | |
| name=value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # [http://docs.ansible.com/ansible/latest/guide_gce.html](http://docs.ansible.com/ansible/latest/guide_gce.html) | |
| # [gce - create or terminate GCE instances](http://docs.ansible.com/ansible/latest/gce_module.html) | |
| # [AnsibleでGCEサーバーをセットアップする](https://blog.1q77.com/2014/07/ansible-gce/) | |
| --- | |
| - name: Create instance | |
| hosts: localhost | |
| connection: local | |
| gather_facts: no | |
| vars: | |
| # GCE管理者に加えてService Account User権限も必要? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM ubuntu:16.04 | |
| LABEL maintainer "rhoboro <rhoboro@gmail.com>" | |
| ENV HOME /root | |
| WORKDIR $HOME | |
| RUN apt-get update -y \ | |
| && apt-get upgrade -y \ | |
| && apt-get install -y -q python2.7-mysqldb zip build-essential make curl python-dev wget libmysqlclient-dev python-configparser \ | |
| && wget https://bootstrap.pypa.io/get-pip.py \ | |
| && python get-pip.py | |
| # mysql-serverを入れる際にrootパスワードを聞かれるのを回避する |