Skip to content

Instantly share code, notes, and snippets.

🎯
Making impact

Mark McDonnell Integralist

🎯
Making impact
Block or report user

Report or block Integralist

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Integralist
Integralist / Golang http.Request.Context.go
Created Sep 9, 2019
[Golang http.Request.Context] #go #golang #http #request #context
View Golang http.Request.Context.go
package main
import (
"context"
"fmt"
"net/http"
)
const beepboop = "whatever"
@Integralist
Integralist / Curl Redirect Output and Grep.bash
Created Sep 9, 2019
[Curl Redirect Output and Grep] #curl #redirect #stdout #grep
View Curl Redirect Output and Grep.bash
curl -svo /dev/null -H 'Fastly-Debug:1' https://www.buzzfeednews.com/article/johnpaczkowski/apple-arcade-iphone-pro-appletv 2>&1 | sort | grep -iE '^< ((cache|surrogate)-control|surrogate-key|cache|fastly)'
@Integralist
Integralist / Safe Tech Terminology
Created Sep 9, 2019
[Safe Tech Terminology] #safe #terminology #tech
View Safe Tech Terminology
- Blacklist/Whitelist > Blocklist/Allowlist
- Master/Slave > Primary/Replica
@Integralist
Integralist / Example System Contract for Caching Behaviours.md
Last active Aug 20, 2019
[Example System Contract for Caching Behaviours] #system #contract #architecture #design #interface #SLA #fastly #cdn
View Example System Contract for Caching Behaviours.md

Caching

  • Cache-Control: used if provided, otherwise default will be set.
  • Surrogate-Control: augmented if provided, otherwise default will be set.

Augmentation

Perimeter will augment the provided Surrogate-Control by appending stale-while-revalidate and stale-if-error directives if they are not defined.

See also "Extensions" section below.

@Integralist
Integralist / embed interface into struct (real example).go
Last active Aug 19, 2019
[Go embedding interface types] #go #golang #interface #struct #field #type #assertion #embed #override #template #pattern
View embed interface into struct (real example).go
// Package middleware provides wrapper functions around the http.Handler
// interface, allowing for an incoming HTTP request to be modified or analysed.
package middleware
import (
"fmt"
"net/http"
"time"
)
@Integralist
Integralist / Golang Read HTTP Response Body TWICE.go
Created Aug 13, 2019
[Golang Read HTTP Response Body TWICE!] #go #golang #http #response #body #read
View Golang Read HTTP Response Body TWICE.go
// ReadBody reads the provided http.Response#Body and resets it to a type that
// would result in a additional read of the body to not trigger an error.
//
// this is to side-step the default behaviour, which for attempting to read a
// response body twice, is to error with: `http: read on closed response body`.
//
// the reason we have to do this is because when
// httputil.ReverseProxy#ModifyResponse returns an error, the internal
// implementation calls `r.Body.Close()` automatically before calling
// httputil.ReverseProxy#ErrorHandler.
@Integralist
Integralist / golang avoid promoted field in literal struct error.go
Last active Aug 13, 2019
[golang avoid promoted field in literal struct error] #go #golang #struct #promoted #field #error
View golang avoid promoted field in literal struct error.go
package main
import (
"fmt"
)
type A struct {
enabled bool
}
@Integralist
Integralist / fastly default vcl - no custom vcl.vcl
Last active Sep 9, 2019
[fastly default vcl, no custom vcl] #fastly #varnish #vcl
View fastly default vcl - no custom vcl.vcl
pragma optional_param geoip_opt_in true;
pragma optional_param default_ssl_check_cert 1;
pragma optional_param max_backends 5;
pragma optional_param customer_id "...";
C!
W!
# Backends
sub vcl_recv {
#--FASTLY RECV BEGIN
if (req.restarts == 0) {
@Integralist
Integralist / ffmpeg crop video.bash
Last active Aug 5, 2019
[ffmpeg crop video] #ffmpeg #crop #video
View ffmpeg crop video.bash
ffmpeg -i 2019-hack-week-vol1.mp4 -ss 00:05:36 -t 00:11:18 -async 1 cut.mp4
# note: -t represents the duration you want the new video crop to last for
@Integralist
Integralist / Go Access Underlying Slice Array.go
Last active Jul 30, 2019
[Go Access Underlying Slice Array] #go #golang #slice #array #unsafe #reflect #header
View Go Access Underlying Slice Array.go
package main
import (
"fmt"
"reflect"
"unsafe"
)
func main() {
// define a slice
You can’t perform that action at this time.