Having the exitng git repo with this structure:
+
|
+-- bin/
|
+-- html/
#!/usr/bin/env bash | |
# Copy this entire thing at the beginning of all your bash scripts, | |
# this will save you a lot of trouble now and in the future. | |
# -e: Fail on errors | |
# -u: Fail on undeclared/unbound variables | |
set -eu | |
# This is the directory where this script is. |
// This example demonstrates a pluggable middleware approach to | |
// recovering from panics in HTTP handlers and sending HTTP 500 | |
// responses to the client when panics happen. | |
// | |
// The middleware allows to use in any handlers without them | |
// being aware of anything special. | |
// | |
// Utilises middleware concepts, see: | |
// - https://github.com/justinas/alice | |
// - https://www.alexedwards.net/blog/making-and-using-middleware |
// This example demonstrates how panics in handlers can be recovered, | |
// and HTTP 500 responses sent to the client when panic happens. | |
// | |
// Since the built-in http.ResponseWriter cannot be reset, any panic | |
// can lead to half-arsed responses in the buffer or worse. | |
// Also, since our panic handler needs to completely replace the response, | |
// we need our own fully buffered ResponseWriter. | |
// | |
// This demo implements such a buffered response writer as HttpBuffer. | |
// |
package main | |
import ( | |
"log" | |
"bufio" | |
"time" | |
"os" | |
"fmt" | |
"io" | |
"net" |
type ApacheLogRecord struct { | |
http.ResponseWriter | |
ip string | |
time time.Time | |
method, uri, protocol string | |
status int | |
responseBytes int64 | |
elapsedTime time.Duration | |
} |
#!/usr/bin/env bash | |
# Installs node.js and azure cli on Centos5 box. | |
# Lots of hacking because standard installation does not work | |
# due to SSL (and other) issues. | |
# Adds nodejs yum repo. | |
# Parameters: none | |
function add_node_repo() { | |
cat <<EOF > /etc/yum.repos.d/nodesource-el.repo |
// See http://ppanyukov.github.io/2017/02/01/golang-with-vsts-repos.html | |
package main | |
import ( | |
"strings" | |
"fmt" | |
"os" | |
"log" | |
"net/http" |
package main | |
import ( | |
"fmt" | |
"net/http" | |
"net/http/httputil" | |
) | |
func handler(w http.ResponseWriter, r *http.Request) { | |
var formatted, err = httputil.DumpRequest(r, true) |
""" | |
Connection adapter for Requests that allows it to talk with raw UNIX sockets. | |
Adapted from requests-unixsocket, which itself was adapted from docker-py. | |
https://github.com/msabramo/requests-unixsocket | |
https://github.com/docker/docker-py/blob/master/docker/unixconn/unixconn.py | |
""" | |
import socket | |
from urllib.parse import unquote, urlparse |
Having the exitng git repo with this structure:
+
|
+-- bin/
|
+-- html/