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
class Pojazd: | |
def __init__(self, predkosc: int, kolor: str) -> None: | |
self.predkosc: int = predkosc | |
self.kolor: str = kolor | |
def jedz(self) -> None: | |
print("Pojazd jedzie.") | |
def zatrzymaj(self) -> None: | |
print("Pojazd zatrzymuje się.") |
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
def test_model_form_contact_fields(): | |
form = ModelContactForm() | |
assert len(form.fields) == 4 | |
assert "email" in form.fields | |
assert "first_name" in form.fields | |
assert "last_name" in form.fields | |
assert "message" in form.fields |
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
def compare(a, b): | |
if a == b: | |
return True | |
else: | |
return False |
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
""" | |
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 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 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 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 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 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 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 |
NewerOlder