Skip to content

Instantly share code, notes, and snippets.

import os
import json
import boto3
def lambda_handler(event, context):
if event:
messages_to_reprocess = []
batch_failure_response = {}
for record in event["Records"]:
try:
import os
import json
import boto3
def lambda_handler(event, context):
region_name = os.environ['AWS_REGION']
if event:
sqs = boto3.resource('sqs', region_name=region_name)
queue_name = event['Records'][0]['eventSourceARN'].split(':')[-1]
queue = sqs.get_queue_by_name(QueueName=queue_name)
import os
import json
import boto3
def lambda_handler(event, context):
region_name = os.environ['AWS_REGION']
if event:
sqs = boto3.client('sqs', region_name=region_name)
queue_name = event['Records'][0]['eventSourceARN'].split(':')[-1]
queue_url = sqs.get_queue_url(
@bgdnlp
bgdnlp / cognito-test.py
Last active October 11, 2024 16:44
Sign up and log in to Cognito, check tokens, then call an API. Details: https://www.neant.ro/aws/working-with-cognito-and-api-gateway-in-python.html
#!/usr/bin/env python3
# Demonstrates the use of Python to work with Cognito.
# Create a new a user, log in, check tokens and call an API.
# The purpose was to learn about Cognito. Security has been
# circumvented in the interest of keeping it simple.
# Notably, the authentication procedure uses the most insecure
# method. This code is not intended for use in production.
#
# https://www.neant.ro/aws/working-with-cognito-and-api-gateway-in-python.html
@bennettscience
bennettscience / PyRSS2Gen.py
Last active January 19, 2023 10:08
InstagramRSS - Follow your favorite public accounts from RSS feeds.
"""PyRSS2Gen - A Python library for generating RSS 2.0 feeds."""
""" Distributed under the BSD license here."""
__name__ = "PyRSS2Gen"
__version__ = (1, 1, 0)
__author__ = "Andrew Dalke <[email protected]>"
_generator_name = __name__ + "-" + ".".join(map(str, __version__))
import datetime
disabled_rules: # rule identifiers to exclude from running
- line_length
- function_body_length
- cyclomatic_complexity
- multiple_closures_with_trailing_closure
- xctfail_message
# Swift 3 rules that do not make sense for Swift 2.3
- implicit_getter
enum EnumType:Any {
case none
case firstType(value:String)
case secondTypeA(value1:String, value2:Int)
case secondTypeB(value1:String, value2:Int)
}
func checkEnumType(type:EnumType) {
switch type {
@nagataka
nagataka / PrestoJDBC.java
Created April 12, 2017 06:53
Connect to Presto on EMR via JDBC
import java.net.URI;
import java.net.URISyntaxException;
import java.sql.*;
public class PrestoJDBC {
// JDBC driver name and database URL
static final String JDBC_DRIVER = "com.facebook.presto.jdbc.PrestoDriver";
//static final String JDBC_DRIVER = "com.teradata.presto.jdbc42.Driver";
static final String DB_URL = "jdbc:presto://ec2-xx-xx-xxx-xxx.ap-northeast-1.compute.amazonaws.com:8889/hive/default";