Skip to content

Instantly share code, notes, and snippets.

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
View javascript-loader-demo.html
<!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 Nov 14, 2016
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.
View containerised-tinyproxy-demo.sh
# - 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 $(
View apache-php-ssl-3-nodes-1-host-shared-access-log.sh
# 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 Aug 7, 2021
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.
View make-local-cert.sh
#!/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 Sep 25, 2016
Mock a Cloud-Init metadata service for cloud-config testing with VirtualBox Guest VM
View Cloud-Init_MetadataRouter.php
<?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 Sep 29, 2016
DNS cache / forwarder with catchall for .local and .localdoman addresses using docker and dnsmasq
View containerised-local-dnsmasq.sh
# - 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 Oct 2, 2016
How to Grep the Output of tail
View howto-grep-tail-output.md

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
Local Squid Proxy (Experimental)
View containerised-squid-proxy.sh
#
# 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 Oct 25, 2016
Traefik configuration example for load balanced containers with front-end https://app-1.local
View traefik.app-1.local.toml
################################################################
# 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 Oct 25, 2016
Traefik (front-end/backend) rules configuration example for load balanced containers with front-end https://app-1.local
View rules.app-1.local.toml
[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"