Skip to content

Instantly share code, notes, and snippets.

View ngraf's full-sized avatar

ngraf

  • Leipzig, Germany
View GitHub Profile
@ngraf
ngraf / gist:c745478a02b9b8741a7d
Last active December 14, 2015 15:50
emergency brake description
API PULL2
@ngraf
ngraf / kubectl-context-switch.sh
Last active August 7, 2023 11:01
A script to switch kubectl context easily. For example by creating this file in "/usr/local/bin/context" you can switch context easily by executing "context" in console on any place.
#!/usr/bin/env bash
CONTEXTS=`kubectl config get-contexts -o name | sort`
# Save current IFS
SAVEIFS=$IFS
# Change IFS to new line.
IFS=$'\n'
CONTEXTS=($CONTEXTS)
# Restore IFS
@ngraf
ngraf / selenium-proxy-configuration.pac
Last active May 25, 2021 12:32
Selenium Blackhole Proxy
/**
* @return {string}
*/
function FindProxyForURL(url, host)
{
'use strict';
var url2 = url.substring(url.indexOf("//")+2); // removing http*://
var urlMatch;
if(url2.indexOf("/") != -1) {
@ngraf
ngraf / Browsermob.js
Last active June 17, 2020 15:35
Proof of Concept: BrowserMobProxy helper for CodeceptJS - DRAFT v0.1
const assert = require('assert');
const Proxy = require('browsermob-proxy').Proxy;
const fs = require('fs');
const event = require('codeceptjs').event;
const output = require('codeceptjs').output;
const container = require('codeceptjs').container;
class Browsermob extends Helper {
constructor(config)
@ngraf
ngraf / ElasticReporter.js
Last active July 7, 2022 13:00
A plugin for CodeceptJS to send data to Elasticsearch
const { event } = require('codeceptjs');
let httpOrHttps
// Trigger report to Elasticsearch when hook "event.test.after" is fired
module.exports = (config) => {
checkConfig(config)
httpOrHttps = config.protocol === 'https' ? require('https') : require('http')
event.dispatcher.on(event.test.after, async (test) => {
@ngraf
ngraf / PlaywrightNetwork.js
Last active February 4, 2024 03:15
CodeceptJS helper for test/block/mock network traffic with Playwright
const assert = require('assert');
/**
* Helps you test network traffic with Playwright.
*
* - mockTraffic
* - blockTraffic
* - startRecordingTraffic
* - seeTraffic
* - dontSeeTraffic
@ngraf
ngraf / ElasticReporter.js
Last active October 24, 2023 09:39
A plugin for CodeceptJS to send test results to an Elasticsearch index
const { event } = require("codeceptjs");
let httpOrHttps;
// Trigger report to Elasticsearch when hook "event.test.after" is fired
module.exports = (config) => {
checkConfig(config);
httpOrHttps =
config.protocol === "https" ? require("https") : require("http");
event.dispatcher.on(event.test.after, async (test) => {