Skip to content

Instantly share code, notes, and snippets.

View javaadpatel's full-sized avatar

Javaad Patel javaadpatel

View GitHub Profile
@javaadpatel
javaadpatel / author.css
Created August 6, 2021 21:38
Author Card CSS
.firstinfo, .badgescard {
display: flex;
justify-content: center;
align-items: center;
}
.author_card {
position: relative;
animation: animatop 0.9s cubic-bezier(0.425, 1.14, 0.47, 1.125) forwards;
}
@javaadpatel
javaadpatel / google-analytics-response.json
Created August 5, 2020 15:45
Google Analytics Response
[
[
"/continuous-monitoring-using-flood-element-and-azure-devops/",
"46"
],
[
"/securing-traefik-dashboard-with-azure-ad/",
"80"
],
...
@javaadpatel
javaadpatel / google-analytics.js
Created August 5, 2020 15:44
Google Analytics Netlify Function
/**
* Retrieves unique page views from Google Analytics
* @param {*} pagePath the path to filter from results
*/
async function getUniquePageViews(pagePath) {
const defaults = {
'auth': jwt,
'ids': 'ga:' + process.env.GA_VIEW_ID,
}
await jwt.authorize()
@javaadpatel
javaadpatel / google-auth.js
Last active August 5, 2020 15:43
Google Analytics Netlify Function
//create jwt object
const jwt = new google.auth.JWT(process.env.GA_CLIENT_EMAIL, null, process.env.GA_PRIVATE_KEY, 'https://www.googleapis.com/auth/analytics.readonly');
//authorize using jwt object
await jwt.authorize()
@javaadpatel
javaadpatel / floodrunner_puppeteer_amazon_cart.js
Last active July 30, 2020 19:27
Puppeteer script that navigates to amazon and adds Nyan cat hoodie to cart
/**
* @name Amazon shopping cart flow
*
* @desc Searches for a "nyan cat pullover" on amazon.com and then adds it to user's cart
*/
const puppeteer = require('puppeteer')
try {
(async () => {
// # 1
@javaadpatel
javaadpatel / azure-pipeline.yml
Last active April 26, 2020 06:53
Azure Pipeline to execute Flood Element tests (repository: https://github.com/javaadpatel/Medium_FloodElement_AzureDevops)
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
variables:
NODE_ENV: "Production"
MAX_RETRIES: 3
trigger:
@javaadpatel
javaadpatel / package.json
Created April 26, 2020 06:40
Flood Element Npm command for executing tests (repository: https://github.com/javaadpatel/Medium_FloodElement_AzureDevops)
{
...
"scripts": {
"start": "node index.js",
"pipeline": "node index.js if [ $? -ne 0 ] then exit 1 fi",
...
},
...
}
const winston = require('./helpers/winston');
const fileCleanup = require("./helpers/file-helper");
const testHelpers = require("./helpers/element-test-helper");
//remove all old results and logs
winston.info(`--- Cleaning up all old files ---`);
fileCleanup();
// register tests to run
const floodTests = [
import { step, TestSettings, Until, By, Device } from "@flood/element";
import * as assert from "assert";
export const settings: TestSettings = {
device: Device.iPadLandscape,
userAgent:
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
clearCache: true,
disableCache: true,
clearCookies: true,
@javaadpatel
javaadpatel / traefik-dashboard-rule.yml
Created March 28, 2020 09:32
Traefik dashboard routing and authentication middleware configuration (repository: https://github.com/javaadpatel/Medium_Securing_Traefik_Dashboard)
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: traefik-dashboard
spec:
entryPoints:
- web
- websecure
routes:
- match: Host(`traefik.YOURDOMAIN.com`)