Skip to content

Instantly share code, notes, and snippets.

@asvinours
asvinours / aws_unsuscribe.js
Last active October 16, 2022 20:54
Unsuscribe from AWS marketing emails using Playwright
const { chromium } = require('playwright');
if (process.argv.length !== 3) {
console.error('Expected exactly one argument!');
process.exit(1);
}
(async () => {
const browser = await chromium.launch();
const context = await browser.newContext();
@asvinours
asvinours / checkly_stats.py
Created December 19, 2021 22:10
Export Checkly result stats to table format
#!/usr/bin/python3
# Checkly API reference: https://www.checklyhq.com/docs/api
import datetime
import dateutil.parser as dp
import time
import numpy as np
import requests
#!/usr/bin/env bash
set -eEo pipefail
FILTER_VALUE="${1}"
INSTANCE_ATTRIBUTE="${2:-InstanceId}"
aws ec2 describe-instances --filters "Name=tag:Name,Values=$FILTER_VALUE" | jq -r ".Reservations[].Instances[].$INSTANCE_ATTRIBUTE"
#!/usr/bin/env bash
set -eEo pipefail
verify_mfa_arn () {
local MFA_ARN="$1"
if [ -z "$MFA_ARN" ];
then
echo "You need to configure your MFA device for '$AWS_CLI_PROFILE' profile"
read -p "Enter the ARN of your MFA device: " MFA_ARN
@asvinours
asvinours / build.sh
Created April 15, 2018 15:21
build and push to ECR
# The name of our algorithm
algorithm_name=rmars
#set -e # stop if anything fails
account=$(aws sts get-caller-identity --query Account --output text)
# Get the region defined in the current configuration (default to us-west-2 if none defined)
region=$(aws configure get region)
region=${region:-us-west-2}
# DOMContentLoaded
# Defined by the HTML specification:
#
# "The DOMContentLoaded reports the time when the initial HTML document has been completely loaded and parsed,
# without waiting for stylesheets, images, and subframes to finish loading." - MDN.
SELECT
SUM(fcp.density)
FROM
`chrome-ux-report.chrome_ux_report.201710`,
@asvinours
asvinours / README.md
Last active October 6, 2017 21:37
Update storage class of objects on S3 from standard to standard_ia

Update storage class of object on S3

This is intended to be used on Lambda

  • First script can only update the storage class of files smaller than 5GB
  • Second one uses multipart_copy to split files in 10MB parts and copy them one by one
  • Third script tries to do the multipart_copy with a pool of threads. this one is not fully tested as Lambda does not give access to /dev/shm
@asvinours
asvinours / compile.sh
Created September 10, 2017 17:50
Create heif imagefile from jpeg
apt-get update && \
apt-get install -y \
ffmpeg \
scons \
wget \
git \
binutils \
cpp-5 \
language-pack-en-base \
libacl1 \
@asvinours
asvinours / Makefile_consul
Last active August 10, 2017 18:27
Download, verify and create i386 and amd64 deb package for consul
VERSION=0.9.2
NAME=consul
.PHONY: package build download cleanup verify prepare
build: package cleanup
download: prepare
wget -O consul_$(VERSION)_SHA256SUMS https://releases.hashicorp.com/consul/$(VERSION)/consul_$(VERSION)_SHA256SUMS
wget -O consul_$(VERSION)_linux_amd64.zip https://releases.hashicorp.com/consul/$(VERSION)/consul_$(VERSION)_linux_amd64.zip
@asvinours
asvinours / README.md
Last active October 6, 2017 21:38
Scripts for wg/wrk

Usage

These scripts will help get the best from wg/wrk (https://github.com/wg/wrk)

Example:

$ head useragents.lst 
Mozilla/5.0 (PLAYSTATION 3; 3.55)
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0; Xbox; Xbox One)
Mozilla/5.0 (Windows NT 10.0; Win64; x64; Xbox; Xbox One) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586
Mozilla/5.0 (PlayStation 4 1.51) AppleWebKit/536.26 (KHTML, like Gecko)