Skip to content

Instantly share code, notes, and snippets.

View jdeathe's full-sized avatar
💭
Taking a break from development projects to focus other things

James Deathe jdeathe

💭
Taking a break from development projects to focus other things
View GitHub Profile
@jdeathe
jdeathe / javascript-loader-demo.html
Last active May 15, 2017 01:49
JavaScript Loader
<!DOCTYPE html>
<html>
<head>
<title>JavaScriptLoader</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.8.23/themes/base/jquery-ui.css" type="text/css" media="all" />
<style type="text/css">
body.jsLoaded .hidden {display: none;}
</style>
</head>
@jdeathe
jdeathe / containerised-tinyproxy-demo.sh
Last active November 14, 2016 10:37
Demonstration of usage of jdeathe/centos-ssh as a local proxy server. Could be used to tunnel a mobile device over hosts VPN for example.
# - Create an SSH container on localhost exposing the default port 22.
# - If you have a default SSH public key (i.e. ~/.ssh/id_rsa.pub) use that
# but if not the Vagrant insecure public key will be used.
# - Assumes that the docker bridge network is on 172.17.0.1/24
# - Assumes that the host network is 192.168.1.1/24
# - Connect client's (browser/mobile phone) to {host-public-ip-address}:8888 (or localhost:8888 from host).
docker pull jdeathe/centos-ssh:centos-7-2.1.2
eval "sudo -E $(
# From local checkout : clone repo
git clone git@github.com:jdeathe/centos-ssh-apache-php.git \
&& cd centos-ssh-apache-php
# Checkout release branch
git checkout centos-6
# Use --help for usage.
# Use --info to view command that will be run
# Note: -i | install, -u | uninstall
@jdeathe
jdeathe / make-local-cert.sh
Last active July 29, 2023 21:30
Generate a Root CA + Intermediate CA for local (internal) use on Mac OSX using cfssl and add the intermediate certificate to your keychain so it can be trusted by your local browser.
#!/usr/bin/env bash
# REF: https://github.com/cloudflare/cfssl
# Change working directory
cd -- "$(
dirname "${0}"
)" || exit 1
readonly CA_ROOT_CERT_KEY="ca-root"
@jdeathe
jdeathe / Cloud-Init_MetadataRouter.php
Last active September 25, 2016 23:20
Mock a Cloud-Init metadata service for cloud-config testing with VirtualBox Guest VM
<?php
date_default_timezone_set(
'UTC'
);
// Mock Cloud-Init metadata service for cloud-config
// From VirtualBox host machine run:
// env METADATA_INSTANCE_ID="iid-5cd832f4bc69" sudo -E php -S 0.0.0.0:80 Cloud-Init_MetadataRouter.php
@jdeathe
jdeathe / containerised-local-dnsmasq.sh
Last active September 29, 2016 14:36
DNS cache / forwarder with catchall for .local and .localdoman addresses using docker and dnsmasq
# - Create an DNS container on localhost exposing the default tcp + udp port 53.
# - Disable the SSH features and process - using local docker.
# - Create a loopback alias with on 192.168.127.1/24 to allow routing between
# host and containers.
# - http://www.thekelleys.org.uk/dnsmasq/doc.html
# - http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html
LOOPBACK_ALIAS="192.168.127.1/24"
LOOPBACK_ALIAS_IP="${LOOPBACK_ALIAS%%/*}"
@jdeathe
jdeathe / howto-grep-tail-output.md
Last active April 20, 2024 08:43
How to Grep the Output of tail

How to grep the output of tail

When following a log file with the tail command you are typically looking for a specific pattern. If the log output is verbous it can be difficult to catch the lines your interested in. For example a PHP log file might contain many PHP Notice: entries but your only interested in lines containing PHP Fatal error:. To grep the output of tail simply tell the grep command to red from stdin and pipe the output from tail to grep as follows.

tail -f {path/to/log/file} | grep 'PHP Fatal error:' -
@jdeathe
jdeathe / containerised-squid-proxy.sh
Last active May 21, 2017 14:37
Local Squid Proxy (Experimental)
#
# WARNING! This configures a Man-In-The-Middle proxy that decrypts HTTPS traffic.
#
# - Requires Local DNS: https://gist.github.com/jdeathe/252578a3217ab9782fed10c3b3816d30
# - Disable the SSH features and process - using local docker.
# - https://docs.docker.com/engine/userguide/networking/
# - http://www.squid-cache.org/Versions/v3/3.3/cfgman/http_port.html
# - http://www.squid-cache.org/Versions/v3/3.3/cfgman/ssl_bump.html
# - http://www.squid-cache.org/Versions/v3/3.3/cfgman/refresh_pattern.html
# - https://www.openssl.org/docs/manmaster/ssl/SSL_CTX_set_options.html
@jdeathe
jdeathe / traefik.app-1.local.toml
Created October 25, 2016 22:53
Traefik configuration example for load balanced containers with front-end https://app-1.local
################################################################
# Global configuration
################################################################
# Timeout in seconds.
# Duration to give active requests a chance to finish during hot-reloads
#
# Optional
# Default: 10
#
@jdeathe
jdeathe / rules.app-1.local.toml
Created October 25, 2016 22:55
Traefik (front-end/backend) rules configuration example for load balanced containers with front-end https://app-1.local
[backends]
[backends.http-pool-1]
[backends.http-pool-1.circuitbreaker]
expression = "NetworkErrorRatio() > 0.5"
[backends.http-pool-1.maxconn]
amount = 10240
extractorfunc = "request.host"
[backends.http-pool-1.LoadBalancer]
method = "drr"