TIL about the yield from syntax introduced in >=Python-3.3
In [6]: def f1(p):
...: yield f'{p}1'
...: yield f'{p}2'
...:
...:
In [7]: def f2(): | param ( | |
| [ValidateNotNullOrEmpty()] | |
| [string] $ScriptPath, | |
| [ValidateNotNullOrEmpty()] | |
| [string] $TaskName | |
| # Pass in as many arguments as you want.... | |
| ) | |
| # Setup error handling. | |
| Trap |
| #!/bin/bash | |
| set -exo pipefail | |
| HOST=http://download.huzheng.org/dict.org/ | |
| if [ -z "$STARDICT_DATA_DIR" ] | |
| then | |
| echo >&2 "Error: STARDICT_DATA_DIR not set!" | |
| exit 1 |
| --- | |
| AWSTemplateFormatVersion: 2010-09-09 | |
| Description: | | |
| testing dynamic references | |
| https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html | |
| Parameters: | |
| AMIParameterName: | |
| #Type: 'AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>' | |
| Type: String |
| --- | |
| AWSTemplateFormatVersion: 2010-09-09 | |
| Description: Testing something | |
| Resources: | |
| R1: | |
| Type: Custom::StringReplacement | |
| Properties: | |
| ServiceToken: !ImportValue cfn-helpers:Replace | |
| Find: '-test' |
| import time | |
| def RateLimited(maxPerSecond): | |
| minInterval = 1.0 / float(maxPerSecond) | |
| def decorate(func): | |
| lastTimeCalled = [0.0] | |
| def rateLimitedFunction(*args,**kargs): | |
| elapsed = time.clock() - lastTimeCalled[0] | |
| leftToWait = minInterval - elapsed | |
| if leftToWait>0: |
TIL about the yield from syntax introduced in >=Python-3.3
In [6]: def f1(p):
...: yield f'{p}1'
...: yield f'{p}2'
...:
...:
In [7]: def f2(): | """ | |
| Simple test for checking if an EC2 instance or ECS task can access an | |
| ElasticSearch domain. This was mainly lifted from the AWS documentation: | |
| https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-request-signing.html#es-request-signing-python | |
| To use this, first the requisite libraries must be available: | |
| $ pip install -U \ | |
| boto3 \ | |
| elasticsearch \ | |
| requests \ |
| #!/bin/sh | |
| # NOTE: | |
| # Make sure that the value of Name, Type, TTL are the same with your DNS Record Set | |
| HOSTED_ZONE_ID=<YOUR_HOSTED_ZONE_ID> | |
| RESOURCE_VALUE=<YOUR_DNS_RESOURCE_VALUE-ex:IP or dns> | |
| DNS_NAME=<YOUR_DNS_NAME-ex: subdomain.domain.com> | |
| RECORD_TYPE=<DNS_RECORD_TYPE-ex: A, CNAME> | |
| TTL=<TTL_VALUE> |
| # module list (generated by listmodules.py) | |
| # | |
| # timestamp='20160226T200954Z' | |
| # sys.version='2.7.10 (default, Dec 8 2015, 18:25:23) \n[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)]' | |
| # sys.platform='linux2' | |
| # platform='Linux-4.1.13-19.31.amzn1.x86_64-x86_64-with-glibc2.2.5' | |
| # | |
| BaseHTTPServer | |
| Bastion | |
| CDROM |