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
| # Given a string, split the string into two substrings at every possible point. | |
| # The rightmost substring is a suffix. The beginning of the string is the prefix. | |
| # Determine the lengths of the common prefix between each suffix and the original string. | |
| # Sum and return the lengths of the common prefixes. Return an array where each element i is the sum for string i. | |
| # Complete the 'commonPrefix' function below. | |
| # The function is expected to return an INTEGER_ARRAY. | |
| # The function accepts STRING_ARRAY inputs as parameter. | |
| # Let's break this problem down in several stages to make it easier to solve: |
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
| apiVersion: kyverno.io/v1 | |
| kind: ClusterPolicy | |
| metadata: | |
| name: service-no-type-load-balancer-enforce-extention | |
| spec: | |
| validationFailureAction: enforce | |
| background: false | |
| rules: | |
| - name: default | |
| match: |
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
| // Run with ts-node script.ts --no-cache | |
| /* eslint-disable @typescript-eslint/no-non-null-assertion */ | |
| /* eslint-disable no-console */ | |
| import { | |
| ChangeBatch, | |
| ChangeResourceRecordSetsCommand, | |
| DeleteHostedZoneCommand, | |
| ListHostedZonesCommand, | |
| ListResourceRecordSetsCommand, |
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
| (require :cl) | |
| (defun calc-pi (n) | |
| (let ((in-circle 0)) | |
| (loop for i from 1 to n do | |
| (let ((x (random 1.0)) | |
| (y (random 1.0))) | |
| (when (< (+ (* x x) (* y y)) 1) | |
| (incf in-circle)))) | |
| (* 4 (/ in-circle n)))) |
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
| class FrozenDict(dict): | |
| def __setitem__(self, key, value): | |
| raise TypeError("This dictionary is frozen. You cannot add or modify items.") | |
| def __hash__(self): | |
| items = tuple(self.items()) | |
| return hash(items) | |
| my_dict = {"a": 1, "b": 2, "c": 3} | |
| my_frozen_dict = FrozenDict(my_dict) |
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 { defaultProvider } from '@aws-sdk/credential-provider-node'; | |
| import { Client } from '@opensearch-project/opensearch'; | |
| // tslint:disable-next-line:no-var-requires | |
| const createAwsOpensearchConnector = require('aws-opensearch-connector'); | |
| export async function getEsClient(node: string = `https://${process.env.elasticsearch}`) { | |
| const es = new Client({ | |
| ...createAwsOpensearchConnector({ | |
| credentials: await defaultProvider()(), |
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 { Sha256 } from '@aws-crypto/sha256-browser'; | |
| import { defaultProvider } from '@aws-sdk/credential-provider-node'; | |
| import { NodeHttpHandler } from '@aws-sdk/node-http-handler'; | |
| import { HttpRequest } from '@aws-sdk/protocol-http'; | |
| import { SignatureV4 } from '@aws-sdk/signature-v4'; | |
| // import { region } from './http-agent'; use an aws region string | |
| // import { getEnv } from './utils'; just calls process.env or returns default | |
| export async function indexDocumentonAwsES(body, index, type, id, domain) { | |
| const request = new HttpRequest({ |
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 { Sha256 } from '@aws-crypto/sha256-browser'; | |
| import { defaultProvider } from '@aws-sdk/credential-provider-node'; | |
| import { NodeHttpHandler } from '@aws-sdk/node-http-handler'; | |
| import { HttpRequest } from '@aws-sdk/protocol-http'; | |
| import { SignatureV4 } from '@aws-sdk/signature-v4'; | |
| import { CdkCustomResourceEvent, CdkCustomResourceHandler } from 'aws-lambda'; | |
| export async function signRequest(request: HttpRequest, region = 'eu-west-1') { | |
| const signer = new SignatureV4({ | |
| credentials: defaultProvider(), |
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 logging | |
| import os | |
| import requests | |
| import unittest | |
| from unittest.mock import patch | |
| import requests_mock | |
| def send_slack_message(message, slack_url): | |
| slack_response = requests.post( |
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 { SynthUtils } from '@aws-cdk/assert'; | |
| import * as cdk from 'aws-cdk-lib'; | |
| import { Stack, StageSynthesisOptions } from 'aws-cdk-lib'; | |
| import { Template } from 'aws-cdk-lib/assertions'; | |
| import { InfrastructureStack } from '../../src/lib/infrastructure-stack'; | |
| type Options = StageSynthesisOptions & { | |
| /** | |
| * Ignore Assets | |
| */ |