Skip to content

Instantly share code, notes, and snippets.

View glennslaven's full-sized avatar

Glenn Slaven glennslaven

View GitHub Profile
@glennslaven
glennslaven / enforce_https.vcl
Created August 14, 2015 01:09
Enforce https using vcl
sub vcl_recv {
//Use req.proto instead of req.http.X-Forwarded-Proto if your varnish server isn't behind a load balancer
if ( req.http.X-Forwarded-Proto !~ "(?i)https") {
//The 750 number is arbitrary, you just need a unique number to check for in the vcl_synth sub
return (synth(750, ""));
}
}
sub vcl_synth {
if (resp.status == 750) {
@glennslaven
glennslaven / alternateorigin.vcl
Created November 12, 2015 08:07
VCL for using alternate origins
sub vcl_recv {
if (req.url ~ "/images") {
set req.http.section-origin = "myimages";
#If the url on the other server is different you may need to modify the req.url property
set req.http.host = "myimages.hostname.com";
}
}
@glennslaven
glennslaven / section.config.json
Last active November 12, 2015 08:09
section.config.json with alertnate origins
{
"proxychain": [
{
"name": "varnish",
"image": "varnish"
}
],
"environments": {
"Production": {
"hostname": "www.mysite.com",
apiVersion: v1
kind: Namespace
metadata:
name: keepalive-test
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
namespace: keepalive-test
name: origin1
@glennslaven
glennslaven / gist:9cf7721f9f608a9da5fcdf9e9c06b8b6
Last active September 10, 2018 09:45
Terraform ns1 output
ns1_record.endpointgroup - *terraform.NodeApplyableResource
provider.ns1 - *terraform.NodeApplyableProvider
2018/09/10 09:41:22 [DEBUG] resource ns1_record.endpointgroup using provider provider.ns1
2018-09-10T09:41:22.890Z [DEBUG] plugin: starting plugin: path=/app/.terraform/plugins/linux_amd64/terraform-provider-ns1_v1.0.0_x4 args=[/app/.terraform/plugins/linux_amd64/terraform-provider-ns1_v1.0.0_x4]
2018-09-10T09:41:22.891Z [DEBUG] plugin: waiting for RPC address: path=/app/.terraform/plugins/linux_amd64/terraform-provider-ns1_v1.0.0_x4
2018-09-10T09:41:22.899Z [DEBUG] plugin.terraform-provider-ns1_v1.0.0_x4: 2018/09/10 09:41:22 [DEBUG] plugin: plugin address: unix /tmp/plugin029243236
2018-09-10T09:41:22.902Z [DEBUG] plugin.terraform-provider-ns1_v1.0.0_x4: 2018/09/10 09:41:22 [INFO] NS1 Client configured for Endpoint: https://api.nsone.net/v1/
ns1_record.endpointgroup: Creating...
answers.#: "" => "2"
static_resources:
listeners:
- name: main
address:
socket_address:
address: 0.0.0.0
port_value: 80
filter_chains:
- filters:
- name: envoy.http_connection_manager
>> checking code style
mkdir -p /go/bin
curl -s -L https://github.com/dominikh/go-tools/releases/download/2019.1/staticcheck_linux_amd64 > /go/bin/staticcheck
>> running staticcheck
chmod +x /go/bin/staticcheck
GO111MODULE=on go list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
go: finding github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973
go: finding github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf
go: finding github.com/prometheus/client_golang v0.9.0
go: finding github.com/konsorten/go-windows-terminal-sequences v1.0.1
function dumpvar(data)
-- cache of tables already printed, to avoid infinite recursive loops
local tablecache = {}
local buffer = ""
local padder = " "
local function _dumpvar(d, depth)
local t = type(d)
local str = tostring(d)
if (t == "table") then
@glennslaven
glennslaven / Dockerfile
Last active July 25, 2019 21:13
Demo prometheus exporter error with varnish 4.0
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get --assume-yes --no-install-recommends install apt-transport-https ca-certificates curl
RUN curl https://packagecloud.io/install/repositories/varnishcache/varnish40/script.deb.sh | bash
RUN apt-get --assume-yes --no-install-recommends install varnish=4.0.5-1~xenial
ENV prometheus_varnish_exporter_version=1.5
RUN curl --remote-name --location https://github.com/jonnenauha/prometheus_varnish_exporter/releases/download/$prometheus_varnish_exporter_version/prometheus_varnish_exporter-$prometheus_varnish_exporter_version.linux-amd64.tar.gz
@glennslaven
glennslaven / index.ts
Last active May 30, 2024 00:42
upload-file supabase function
import pdf from "npm:pdf-parse/lib/pdf-parse.js";
Deno.serve(async (req) => {
try {
const reqFormData = await req.formData();
if (!reqFormData.has("file")) {
throw new Error("Missing required 'file' property from request data.");
}