Skip to content

Instantly share code, notes, and snippets.

View Phenomite's full-sized avatar

Phenomite Phenomite

  • New Zealand
View GitHub Profile
@Phenomite
Phenomite / Cucumber report generator - addScreenshots function.js
Last active August 4, 2020 16:34
Cucumber Report JSON Generator - Subfolder recurse for screenshots (fix for Issue#1)
function addScreenshots() {
/* Credits: https://gist.github.com/kethinov/6658166#gistcomment-3178557 */
/* Prepend the given path segment */
const prependPathSegment = pathSegment => location => path.join(pathSegment, location);
/* fs.readdir but with relative paths */
const readdirPreserveRelativePath = location => fs.readdirSync(location).map(prependPathSegment(location));
@Phenomite
Phenomite / cy.exist conditional testing.js
Created May 1, 2020 01:20
cy.exist function to allow existence checking conditional testing
// Anti-pattern conditional testing with Cypress
// Uses jQuery functionality to determine existence
// Add to your support folder
Cypress.Commands.add("exist", (selector) => {
cy.get('body').should('exist').then(($body) => {
return new Cypress.Promise((resolve, reject) => {
if ($body.find(selector).length > 0) {
console.log("cy.exist() - Matching element found in DOM!");
resolve(true);
@Phenomite
Phenomite / cloudflare-whitelist-webserver.sh
Created April 22, 2021 08:35
Webserver Config - Whitelist non-WARP Cloudflare Ranges and block all other traffic to Port 80/443
########################
# CloudFlare Ranges Only
#
# Active non-WARP ranges as at: 7th May 2021
# Latest list: for v in v4 v6;do curl "https://www.cloudflare.com/ips-$v";done
########################
# Allow access to http (dport 80)
iptables -A INPUT -s 173.245.48.0/20 -p tcp --dport http -j ACCEPT
iptables -A INPUT -s 103.21.244.0/22 -p tcp --dport http -j ACCEPT