※個人の見解です!!
- コード自体の情報量が多い
- ドキュメントの自動生成が楽(少ないドキュメンテーション作業で質の高いドキュメントが作れる)
- エディタ/IDEの自動補完をより強力にすることができる
- 実行するまでもなく様々なことがコンパイル時に検査される
- 実行速度が速い(言語が多い)
| # coding: utf-8 | |
| # only works on 1.9+ | |
| # base idea is from: | |
| # - http://stackoverflow.com/questions/2583472/regex-to-validate-json | |
| # - http://www.slideshare.net/takesako/shibuyapm16-regexpjsonvalidator | |
| module JsonMatcher | |
| NUMBER = /-? (?= [1-9]|0(?!\d) ) \d+ (\.\d+)? ([eE] [+-]? \d+)?/x | |
| BOOLEAN = /true | false | null/x |
| # This command helps you to create pyenv virtualenv and activate that after creation. | |
| # NOTE: I checked this works on zsh | |
| vec() { | |
| PWD=`pwd` | |
| DNAME=`basename $PWD` | |
| pyenv virtualenv 3.7.3 $DNAME | |
| pyenv local $DNAME | |
| } |
| import bottle | |
| from wsgiref import simple_server | |
| b = bottle.Bottle() | |
| def test(): | |
| path = bottle.request.path | |
| urlargs = bottle.request.url_args | |
| query_string = bottle.request.query_string | |
| url = bottle.request.url | |
| return 'your path = %s, urlargs=%s, qs=%s, url=%s' % (path, urlargs, query_string, url) |
| #!/bin/sh | |
| curl https://bootstrap.pypa.io/ez_setup.py -o /tmp/ez_setup.py | |
| # install easy_install | |
| python /tmp/ez_setup.py | |
| # install pip | |
| easy_install pip |
| # -*- coding: utf-8 -*- | |
| # orelang: http://qiita.com/shuetsu@github/items/ac21e597265d6bb906dc | |
| # dependency: click | |
| import os | |
| import os.path | |
| import sys | |
| import json | |
| import click |
| #!/usr/bin/python | |
| # -*- coding: utf-8 -*- | |
| # | |
| # requirements: pip install mongoengine simplejson bottle | |
| import mongoengine | |
| import string | |
| from bottle import ( | |
| route, run, HTTPResponse, request | |
| ) | |
| import simplejson |
| import re | |
| import base64 | |
| import hashlib | |
| import os.path | |
| import gevent.fileobject as gfo | |
| def _read_file(filepath): | |
| fh = open(filepath, 'rb') | |
| gfh = gfo.FileObject(fh, 'rb') | |
| ret = gfh.read() |
| #!/usr/bin/python | |
| # -*- coding: utf-8 -*- | |
| import time | |
| import math | |
| __all__ = ('MongoCounterError', 'MongoCounter') | |
| class MongoCounterError(Exception): | |
| pass |