Skip to content

Instantly share code, notes, and snippets.

@joshenders
joshenders / rules.patch
Created November 25, 2016 23:32
Patch for varnish-3.0.2-0ubuntu0.1 to enable debug symbols
--- rules 2016-11-25 23:23:25.924313744 +0000
+++ rules.new 2016-11-25 23:23:17.788331016 +0000
@@ -15,7 +15,7 @@
DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
# Set local state dir for FHS
-LOCAL_CONFIGURE_FLAGS = --localstatedir=/var/lib
+LOCAL_CONFIGURE_FLAGS = --localstatedir=/var/lib --enable-debugging-symbols
ifneq ($(filter $(DEB_HOST_ARCH),$(DISABLE_JEMALLOC_ARCH_LIST)),)
@joshenders
joshenders / control.patch
Created November 3, 2016 07:11
varnish-3.0.2-1ubuntu0.1 debian/control patch
--- debian/control 2012-06-18 18:59:16.000000000 +0000
+++ debian/control 2016-11-03 07:10:00.536388796 +0000
@@ -36,13 +36,6 @@
* URL rewriting
* Graceful handling of "dead" backends
-Package: varnish-doc
-Architecture: all
-Section: doc
-Depends: ${misc:Depends}, libjs-jquery, libjs-underscore
@joshenders
joshenders / reload-vcl.patch
Last active December 11, 2016 10:34
reload-vcl patch for config discards and safe stop
--- reload-vcl 2011-10-29 13:24:10.000000000 +0000
+++ /usr/share/varnish/reload-vcl 2016-12-11 09:51:08.696300339 +0000
@@ -1,9 +1,13 @@
#!/bin/sh
-
+#
# reload-varnish: Script to reload varnishd from VCL defined in
# /etc/default/varnish.
#
# Stig Sandbeck Mathisen <[email protected]>
@joshenders
joshenders / cache_gzip.c.patch
Last active November 3, 2016 06:52
Ticket #1220: Temporary gzip issue: Invalid Gzip data: incorrect header check
--- a/bin/varnishd/cache_gzip.c
+++ b/bin/varnishd/cache_gzip.c
@@ -646,9 +646,6 @@
bytes -= w;
VGZ_Ibuf(vg, st->ptr + st->len, w);
st->len += w;
- sp->obj->len += w;
- if (sp->wrk->do_stream)
- RES_StreamPoll(sp);
@joshenders
joshenders / varnishncsa.c.patch
Last active October 28, 2016 08:10
Varnish 3.0.3 (9e6a70f) Time to Last Byte varnishncsa patch
diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c
index ff07ed5..3af1367 100644
--- a/bin/varnishncsa/varnishncsa.c
+++ b/bin/varnishncsa/varnishncsa.c
@@ -98,6 +98,7 @@ static struct logline {
struct tm df_t; /* %t, Date and time */
char *df_u; /* %u, Remote user */
char *df_ttfb; /* Time to first byte */
+ char *df_ttlb; /* Time to last byte */
const char *df_hitmiss; /* Whether this is a hit or miss */
@joshenders
joshenders / certchain.sh
Last active August 26, 2021 18:19
Simple Bash function to visualize PKI chain-of-trust
function certchain() {
# Usage: certchain
# Display PKI chain-of-trust for a given domain
# GistID: https://gist.github.com/joshenders/cda916797665de69ebcd
if [[ "$#" -ne 1 ]]; then
echo "Usage: ${FUNCNAME} <ip|domain[:port]>"
return 1
fi
local host_port="$1"
@joshenders
joshenders / ylint.sh
Created December 14, 2015 11:10
YAML syntax checker
function ylint() {
if [[ "$#" -ne 1 ]]; then
echo "Usage: ${FUNCNAME} <infile>"
return 1
fi
ruby -e "require 'yaml'; YAML.load_file('$1')"
}
@joshenders
joshenders / mitmproxy.md
Last active July 23, 2023 14:49
mitmproxy configuration for iPad

Successful mitmproxy-3.7 setup tested on OS X 10.13.6 and iPhone X running 12.1.4

Enable IP forwarding and disable ICMP redirects to keep the iPad sending traffic to the proxy

sudo sysctl -w net.inet.ip.forwarding=1
sudo sysctl -w net.inet.ip.redirect=0

net.inet.ip.forwarding
Enable IP forwarding between interfaces

@joshenders
joshenders / smokeping.sh
Last active July 26, 2022 18:43
Poor man's smokeping for OS X
#!/bin/bash
# https://gist.github.com/joshenders/52cb78bedaea6787faac
# This script uses the BSD variants of commands and is intended to
# be run on an unmodified installation of OSX.
pmset noidle &
now=$(date +%s)
duration=$((86400*3)) # 3days
jenders@jenders-mba threadedfractals :) $ make
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 -c -o utils.o utils.c
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 pngify.c utils.o -o pngify -lz
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 resample.c utils.o -o resample
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 render.c utils.o -o render -lm
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 palette.c utils.o -o palette -lm
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 -c -o circularlist.o circularlist.c
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 -c -o loader.o loader.c
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 -c -o mapper.o mapper.c
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 threaded.c circularlist.o loader.o mapper.o utils.o -o threaded -lm -lpthread -ldl