This file contains 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
// tm is the trust manager, code to instantiate this is skipped for brevity | |
// let's create our own OKHttpClient and configure it to use our custom SSLSocketFactory | |
val okHTTPClient = OkHttpClient.Builder().sslSocketFactory(TLSSocketFactory(), tm).build() | |
// Tell the builder to use our own OK HTTP client | |
appSyncBuilder.okHttpClient(okHTTPClient) | |
appSyncClient = appSyncBuilder.build() |
This file contains 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 logging | |
import boto3 | |
from botocore.exceptions import ClientError | |
def upload_file(file_name, bucket, object_name=None): | |
"""Upload a file to an S3 bucket | |
:param file_name: File to upload | |
:param bucket: Bucket to upload to | |
:param object_name: S3 object name. If not specified then file_name is used |
This file contains 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
function asyncWorker(callback) { | |
setTimeout(callback, 2000); | |
} | |
function main() { | |
callback = () => { | |
console.debug('callback !'); | |
} |
This file contains 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
function asyncWorker() { | |
return new Promise( (resolve, reject) => { | |
setTimeout(resolve, 2000); | |
}); | |
} | |
function main() { | |
callback = () => { |
This file contains 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
async function asyncWorker() { | |
return new Promise( (resolve, reject) => { | |
setTimeout(resolve, 2000); | |
}); | |
} | |
async function main() { | |
console.debug('Started'); |
This file contains 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
function updatePlayCount(your_object) { | |
return new Promise((resolve, reject) => { | |
const LAST_PLAYED_TIME = Math.round(new Date() / 1000); | |
var params = { | |
TableName: "your_table", | |
Key: { | |
"cognitoid": your_object.userId, |
This file contains 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 ec2 = require('@aws-cdk/aws-ec2'); | |
import cdk = require('@aws-cdk/core'); | |
import { Fn, Tag, Resource } from '@aws-cdk/core'; | |
import { AmazonLinuxImage, UserData, InstanceType } from '@aws-cdk/aws-ec2'; | |
import { Role, ServicePrincipal, ManagedPolicy, CfnInstanceProfile } from '@aws-cdk/aws-iam' | |
/** | |
* Create my own Ec2 resource and Ec2 props as these are not yet defined in CDK | |
* These classes abstract low level details from CloudFormation |
This file contains 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
{ | |
"demo-global-table": [ | |
{ | |
"PutRequest": { | |
"Item": { | |
"id": {"S": "0123456789"}, | |
"firstname": {"S": "Jeff"}, | |
"lastname": {"S": "Barr"} | |
} | |
} |
This file contains 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 boto3 | |
s3 = boto3.resource('s3') | |
for bucket in s3.buckets.all(): | |
print(bucket.name) |