Skip to content

Instantly share code, notes, and snippets.

s3_resource = boto3.resource('s3')
s3_object = s3_resource.Object(bucket_name=bucket_name, key=object_key)
bodylines = get_object_bodylines(s3_object, offset)
resp = s3_object.get(Range=f'bytes={offset}-')
body: botocore.response.StreamingBody = resp['Body']
MINIMUN_REMAINING_TIME_MS = 10000
csv_reader = csv.DictReader(bodylines.iter_lines(), fieldnames=fieldnames)
for row in csv_reader:
## process and do work
if context.get_remaining_time_in_millis() < MINIMUN_REMAINING_TIME_MS:
fieldnames = fieldnames or csv_reader.fieldnames
break
mediainformer.click
import numpy as np
def plot_confusion_matrix(cm,
target_names,
title='Confusion matrix',
cmap=None,
normalize=True,
figsize=(8, 6)):
"""
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",
"version": "1.0.5",
"title": "Swagger Petstore",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"email": "apiteam@swagger.io"
},
import { Botkit } from "botkit";
module.exports = function (controller: Botkit) {
controller.on("app_mention", async (bot, message) => {
await bot.reply(message, "I am mentioned.");
});
};
{
"compilerOptions": {
"lib": ["es2019"],
"module": "commonjs",
"target": "es2019",
"moduleResolution": "node",
"types": [
"node"
],
"typeRoots": [
// lambda.js
'use strict'
const awsServerlessExpress = require('aws-serverless-express')
const controller = require('.')
const server = awsServerlessExpress.createServer(controller.webserver)
exports.handler = (event, context) => { awsServerlessExpress.proxy(server, event, context) }
module.exports = function (controller) {
controller.on("app_mention", async (bot, message) => {
await bot.reply(message, "I am mentioned.");
});
};
// Load Environment variables from dotenv
require('dotenv').config();
const express = require("express");
const bodyParser = require("body-parser");
// Import Botkit's core features
const { Botkit } = require("botkit");
// Import a platform-specific adapter for slack.
const { SlackAdapter, SlackEventMiddleware } = require('botbuilder-adapter-slack');