This file contains hidden or 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
# update your app settings.py with RedisSubscriber: | |
WS4REDIS_SUBSCRIBER = 'your_app.your_module.subscriber.RedisSubscriber' |
This file contains hidden or 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
""" | |
to set up auth token first authorize jenkins as an slack app and install | |
https://wiki.jenkins.io/display/JENKINS/Slack+Plugin | |
Afterwards, use https://plugins.jenkins.io/credentials-binding, which is most likely available in your jenkins install | |
and use the instructions from there to share credentials with job. Accessing credentials in python requires: os.environ['xxx'] | |
""" | |
import os | |
import requests | |
import json |
This file contains hidden or 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
curl --data '{"tag_name": "'$TAG'","target_commitish": "'$PRODUCTION'","name": "'$TAG'","body": "","draft": false,"prerelease": false}' https://api.github.com/repos/:owner/:repository/releases?access_token=:your_access_token |
This file contains hidden or 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
# remove duplicate files: JPGs when RAW is present | |
from pathlib import Path | |
import os | |
class ProcessFiles(object): | |
""" | |
Walks over current dir and subdirectories searching for JPG and RAW (PEF) files. | |
Prints out a list of duplicates. |
This file contains hidden or 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
// inspired by: https://derikwhittaker.blog/2018/02/20/using-manual-mocks-to-test-the-aws-sdk-with-jest/ | |
let AWS = { | |
// This here is to allow/prevent runtime errors if you are using | |
// AWS.config to do some runtime configuration of the library. | |
// If you do not need any runtime configuration you can omit this. | |
config: { | |
setPromisesDependency: (arg) => {}, | |
update: (arg) => {}, | |
}, |
This file contains hidden or 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
# use filter, Luke | |
# the idea is to use a filter function that will return True for the records to keep. | |
# Usage: just use before the last function at end of your ETL job script. Update frame and update next function frame with "filtered". | |
def filter_function(dynamicRecord): | |
if dynamicRecord.merchant_id == "merchant_id" and dynamicRecord.merchant_ref_number == "merchant_ref_number": | |
return False | |
else: | |
return True | |
filtered = Filter.apply(frame = dropnullfields3, f = filter_function, transformation_ctx = "filtered") |
This file contains hidden or 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
# error handling | |
# redirect logs so can be found in instance -> actions -> instance settings -> Get System log | |
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1 | |
# trap errors. Shutdown restarts machine in an hour and prevents further commands, | |
# so instances won't finish booting and won't report to ECS | |
function my_trap() | |
{ | |
echo "Sorry, there was an error at line $1 $2" && shutdown -h +60 | |
} | |
trap 'my_trap $${LINENO} $$? ' ERR |
This file contains hidden or 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 { Context } from "aws-lambda"; | |
const context: Context = { | |
callbackWaitsForEmptyEventLoop: false, | |
functionName: "", | |
functionVersion: "string", | |
invokedFunctionArn: "string", | |
memoryLimitInMB: 1, | |
awsRequestId: "string", | |
logGroupName: "string", |
This file contains hidden or 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
""" | |
Generate zone records file (terraform) from zone dump. | |
To get zone dump: | |
aws route53 list-resource-record-sets --hosted-zone-id ZONE ID > records.json | |
Example usage: | |
ZONE_FILE=records.json TERRAFORM_DIR=zone_name python generate_zone_records_from_json.py | |
Based on: | |
https://mrkaran.dev/posts/terraform-route53-import/ |
This file contains hidden or 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
def compare(a, b): | |
if a == b: | |
return True | |
else: | |
return False |