Skip to content

Instantly share code, notes, and snippets.

async autoScroll(page: Page) {
await page.evaluate(async () => {
await new Promise((resolve, reject) => {
let totalHeight = 0;
const distance = 500;
const timer = setInterval(() => {
const scrollHeight = document.body.scrollHeight;
window.scrollBy(0, distance);
totalHeight += distance;
async renderPageToHtml(page: Page): Promise<string> {
const iframes = await page.$$("iframe");
for (const iframe of iframes) {
const frame = await iframe.contentFrame();
if (!frame) continue;
const context = await frame.executionContext();
const res = await context.evaluate(() => {
const el = document.querySelector("*");
if (el) return el.outerHTML;
});
image: amaysim/serverless:1.71.1
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
DOCKER_DRIVER: overlay
services:
- docker:19.03.5-dind
.deploy:
stage: Deployment
only:
- master
script:
- export CHANGES=$(git diff-tree --no-commit-id --compact-summary --name-only -r $CI_COMMIT_SHORT_SHA | grep -oE "^\\w+" | sort | uniq)
- export MATCH=$(echo "$CHANGES" | grep -e "^$CURRENT_PROJECT")
- |
if [[ ! -z "$MATCH" ]]
then
image: amaysim/serverless:1.71.1
services:
- docker:19.03.5-dind
stages:
- Deploy
deploy_aws_lambda:
stage: Deploy
image: amaysim/serverless:1.71.1
stages:
- Deploy
deploy_aws_lambda:
stage: Deploy
script:
- apk add --no-cache curl python3 py3-pip
- curl -Ls https://cli.doppler.com/install.sh | sh
image: amaysim/serverless:1.71.1
stages:
- Deploy
deploy_aws_lambda:
stage: Deploy
script:
- apk add --no-cache curl # Install packages for Alpine linux
- curl -Ls https://cli.doppler.com/install.sh | sh # Install Doppler
image: amaysim/serverless:1.71.1
stages:
- Deploy
deploy_aws_lambda:
stage: Deploy
script:
- sls deploy
import boto3
import json
client = boto3.client('events')
lambda_client = boto3.client('lambda')
def add_schedule():
rule = client.put_rule(
Name="MyRuleId",
ScheduleExpression="rate(2 minutes)",
lambda_client = boto3.client('lambda')
lambda_client.add_permission(
FunctionName="MyLambdaFunctionARN",
StatementId="IUseTheSameHereAsTheRuleIdButYouDoAsYouPlease",
Action="lambda:InvokeFunction",
Principal="events.amazonaws.com",
SourceArn=rule["RuleArn"]
)