プログラムが複雑になる一番の理由は条件分岐 (if 文など) です。
条件分岐がなければ、一本道で読み下していけばいいのでバグが入り込む余地は大変少なくなります。
ということで、
- 条件分岐を書かなくていいように書く
- 条件分岐を書くなら、わかりやすく局所化して書く
| import os | |
| import requests | |
| import time | |
| from concurrent.futures import ThreadPoolExecutor | |
| from constants import ( | |
| BLACKLISTED_PROXY_PATH, | |
| MAX_WORKERS, | |
| WORKING_PROXY_PATH, | |
| ) |
| AWSTemplateFormatVersion: "2010-09-09" | |
| Description: > | |
| Launch a static website backed by an S3 bucket and served via https through cloudfront. | |
| Assumes you have the following available already | |
| * An address in mind (e.g. blog.example.com) | |
| * An existing Route53 Hosted Zone for the domain | |
| * A validated AWS ACM certificate arn for the desired web address which must be in eu-west-1 | |
| Parameters: | |
| HostedZoneID: | |
| Description: > |
| { | |
| "presets": [ | |
| [ | |
| "env", | |
| { | |
| "modules": false, | |
| "targets": { | |
| "browsers": "> 1%", | |
| "uglify": true | |
| }, |
| /** | |
| * Axios Request Wrapper | |
| * --------------------- | |
| * | |
| * @author Sheharyar Naseer (@sheharyarn) | |
| * @license MIT | |
| * | |
| */ | |
| import axios from 'axios' |
| #!/bin/sh | |
| ## EC2 automation login tool | |
| # | |
| # Original: http://m.igrs.jp/blog/2013/03/14/ec2-ssh/ | |
| # https://gist.github.com/migrs/5157665 | |
| # https://gist.github.com/MichinobuMaeda/5545875 | |
| # | |
| # Changed by mo-ya (2013-07-06) | |
| # |
| # vim: ft=yaml | |
| # Elastic Load Balancer and Security Group configuration for the app | |
| # | |
| # - Allow anyone to connect to port 443 and office traffic to connect to | |
| # port 22 | |
| # - Ensure all traffic is encrypted by configuring load balancer to listen on | |
| # 443 and direct traffic to port 443 on app servers | |
| # - Enable cookie-based session stickiness | |
| # - Use /status for health check | |
| # - Enable backend authentication policy by providing public key for cert |
基礎知識
読み物系
| console.log("got here"); | |
| var page = require('webpage').create(); | |
| page.onConsoleMessage = function(msg) { | |
| console.log(msg); | |
| }; | |
| page.open("http://facebook.com", function(status) { | |
| if ( status === "success" ) { |