Skip to content

Instantly share code, notes, and snippets.

View Lewiscowles1986's full-sized avatar
🤓

Lewis Cowles Lewiscowles1986

🤓
View GitHub Profile
@Lewiscowles1986
Lewiscowles1986 / fullstory-org-code-js-input-helper.part.html
Created December 26, 2019 12:50
FullStory Org Code JS Input Helper
<script type="text/javascript">
(function() {
/*
* Helper to extract FullStory Org code from URL when used in a HTML input element
*/
const SCHEME_INDICATOR = '://';
const URL_PATH_SEPARATOR = '/';
const FULLSTORY_DOMAIN_INDICATOR = 'app.fullstory.com';
document.querySelector('#fullstory_org_code').addEventListener('input', function(event) {
@Lewiscowles1986
Lewiscowles1986 / .bashrc
Created November 9, 2019 21:36
vscode-as-editor
export EDITOR="code --wait"
# export EDITOR="codium --wait"
# export EDITOR="atom --wait"
# export EDITOR="nano --wait"
# export EDITOR="vi --wait"
# export EDITOR="sublime --wait"
@Lewiscowles1986
Lewiscowles1986 / README.md
Last active March 26, 2019 18:47
Replay against system to test stability

Utility to replay HTTP requests on a service

This utility helps replay a statistically significant number of HTTP requests against a service (serially) which are enough to give significance to two-decimal places.

Usage

replay-http {url} [{headers_path} {payload_path} {http_method}]

Parameters

@Lewiscowles1986
Lewiscowles1986 / README.md
Last active March 7, 2019 07:01
Lazy load from an intelligent place

Lazy Loading (the smart way)

  1. Not all times when we have a Team will we want a list of User's or, approvers
  2. When we select UserApprover entries we want it to be per-team where deleted is False
  3. When we select FinancialApprover entries we want it to be per-team where deleted is False
  4. We may wish to select both UserApprover and FinancialApprover entries for a Team

Data model (simplified)

image

@Lewiscowles1986
Lewiscowles1986 / login.js
Created December 1, 2018 08:28
Sitespeed.io preScript for logging in using username+password before running tests.
module.exports = {
run(context) {
return context.runWithDriver((driver) => {
return driver.get(context.options.loginUrl)
.then(() => {
const webdriver = context.webdriver;
const until = webdriver.until;
const By = webdriver.By;
const userName = context.options.username || 'admin';
@Lewiscowles1986
Lewiscowles1986 / README.md
Last active November 24, 2018 18:28
Get IP of running docker container

Get docker container IP address by name

Installation

mkdir -p $HOME/bin
wget -O ~/bin/docker-container-ip https://gist.github.com/Lewiscowles1986/2c80f1e510152b461eae5c501a00a195/raw/6b60245035ee63a025db20e287f89d74db08b356/docker-network-ip
chmod +x ~/bin/docker-container-ip
@Lewiscowles1986
Lewiscowles1986 / scroll-position-hide-fb.js
Created October 23, 2018 18:57
Hide / show element depending on scroll position
(function(target, threshold, elem) {
listener = () => {
if (target.scrollY > threshold) {
elem.style.opacity = 1;
} else {
elem.style.opacity = 0;
}
};
target.addEventListener(
'scroll',
@Lewiscowles1986
Lewiscowles1986 / count-lines
Created October 7, 2018 14:57
Count lines in files
#!/bin/python
"""
This utility allows you to count the number of lines in files
by default just .py files, but accepts command-line arguments.
This utility does miss files and folders beginning with '.'
so don't use them!
usage: {script} {path} [extensions] [exclude]
@Lewiscowles1986
Lewiscowles1986 / index.php
Last active September 23, 2018 17:22
WordPress media Taxonomies
<?php
/*
Plugin Name: CODESIGN2 Media Taxonomy Modifications
Plugin URI: http://www.codesign2.co.uk
Description: We think it's a real shame that media can be a little unweildy, and not make much sense; on larger sites it's debilitating, so we made this plugin. Enjoy
Author: CODESIGN2
Version: 1.3.6
Author URI: http://www.codesign2.co.uk/
*/
@Lewiscowles1986
Lewiscowles1986 / grub.cfg
Last active May 14, 2020 16:28
multiboot USB Linux goodness
# This grub.cfg file was created by Lance http://www.pendrivelinux.com
# Suggested Entries and the suggestor, if available, will also be noted.
set timeout=10
set default=0
set gfxpayload=keep
submenu "Ubuntu" {
menuentry "Ubuntu Desktop ISO" {
set isofile=/ubuntu.iso