Skip to content

Instantly share code, notes, and snippets.

View neilstuartcraig's full-sized avatar

Neil Craig neilstuartcraig

View GitHub Profile
@neilstuartcraig
neilstuartcraig / node-https-post-example.js
Last active February 17, 2017 14:35
nodejs core https POST example - not working code!
// NOTE: This isn't working code, I rehashed it as an example from one of my projects
import https from "https";
const requestOptions =
{
// See https://nodejs.org/api/http.html#http_http_request_options_callback
};
const req = https.request(requestOptions, (res) =>
@neilstuartcraig
neilstuartcraig / nginx vary header length patch
Created September 10, 2015 20:52
nginx vary header length patch
--- a/src/http/ngx_http_cache.h 2015-06-05 15:10:36.000000000 +0100
+++ b/src/http/ngx_http_cache.h 2015-06-05 15:16:21.000000000 +0100
@@ -25,7 +25,7 @@
#define NGX_HTTP_CACHE_KEY_LEN 16
#define NGX_HTTP_CACHE_ETAG_LEN 42
-#define NGX_HTTP_CACHE_VARY_LEN 42
+#define NGX_HTTP_CACHE_VARY_LEN 4096
#define NGX_HTTP_CACHE_VERSION 3
@neilstuartcraig
neilstuartcraig / LetsEncrypt-HPKP-Jul-2017
Last active July 19, 2017 20:18
HPKP header for Let's Encrypt active & backup certs listed at https://letsencrypt.org/certificates/ - generated by https://hpkpcalc.github.io/calculator.html
Public-Key-Pins: pin-sha256="YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg="; pin-sha256="sRHdihwgkaib1P1gxX8HFszlD+7/gTfNvuAybgLPNis="; max-age=31536000
@neilstuartcraig
neilstuartcraig / tdp-push-config-draft-1
Created July 20, 2017 12:53
TDP push config draft 1
# H2 push
# Needed on all pages:
push / {
/assets/css/reset.css?v=1
/assets/images/twitter.svg
/assets/images/github.svg
/assets/css/generics.css?v=1
/assets/css/main-header.css?v=1
/assets/css/main-footer.css?v=1
}
@neilstuartcraig
neilstuartcraig / gcs-fuse-mount-as-user
Last active September 5, 2017 20:01 — forked from anonymous/gcs-fuse-mount-as-user
FSTab mount GCS bucket as specific user (www-data)
<GCS BUCKET NAME (NO gs:// prefix)> <MOUNT POINT> gcsfuse ro,uid=33,gid=33,noatime,async,_netdev,noexec,user,implicit_dirs,allow_other 0 0
Example:
GCS Bucket name: a-test-bkt
Mount point: /mnt/atb
a-test-bucket /mnt/atb gcsfuse ro,uid=33,gid=33,noatime,async,_netdev,noexec,user,implicit_dirs,allow_other 0 0
NOTES:
implicit_dirs is the --implicit-dirs option which is required to allow the FS to show dirs - see https://github.com/googlecloudplatform/gcsfuse/blob/master/docs/semantics.md#implicit-directories
@neilstuartcraig
neilstuartcraig / medium-hwsbwptti-stats.md
Last active October 12, 2017 13:30
Medium article: How we deliver BBC Web Pages to the Internet - stats for "Our audience" section
Metric Num requests/month Peak requests/sec
Num web pages 40,000,000,000 50,000
Num web page assets 400,000,000,000 600,000
Country         h1 time   h2 time   % reduction  
Argentina     4.78   3.57   34.0%        
New Zealand   5.19   4.05   28.2%        
Japan 4.70 3.73 26.2%
China (Beijing) 5.40 4.64 16.5%
South Africa 4.19 3.80 10.2%
United Kingdom 0.94 0.92 2.7%
Latest versions on Pixel 2, Monday 4th December 2017
------------------------------------------------------------------------
Chrome Canary (65):
User Agent: Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 Build/OPD1.170816.025) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3284.0 Mobile Safari/537.36
Client ciphersuites: 0x4a4a:0x1301:0x1302:0x1303:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA:AES256-SHA:0x000a
Client Curves: 0x8a8a:X25519:prime256v1:secp384r1
Chrome Dev (64):
User Agent: Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 Build/OPD1.170816.025) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3281.0 Mobile Safari/537.36
@neilstuartcraig
neilstuartcraig / gist:d4fd833c51f2a54c2f9e36ab5b25f9cf
Created April 17, 2018 18:58
Email address format - template to request corrections as per RFC 2822
Hello
I’d be grateful if you could forward this email to your technical folk for their consideration please:
I just used your website contact form and I noticed that the email address validation doesn’t allow “+" in the “locally interpreted string” (the part of the email address before the “@"). A “+" (along with a number of other characters) is a valid character in this part of the address (as per the relevant standard, RFC 2822: https://tools.ietf.org/html/rfc2822#section-3.2.4). If you’re unfamiliar with the email address format/spec, this blog post does a good job of explaining it: https://haacked.com/archive/2007/08/21/i-knew-how-to-validate-an-email-address-until-i.aspx/.
Like many others, I use a specific “+ alias” for each account I sign up for, this allows me to filter any resulting spam and more importantly, means that it is more difficult for malicious people and unwanted advertisers to link two or more leaked sets of account details of mine together (see https://fieldguide.gizmodo.com/how-to-us
@neilstuartcraig
neilstuartcraig / tls1-blog-global.md
Last active November 20, 2018 12:37
TLS usage on www.bbc.co.uk and www.bbc.com, 10-13 Nov 2018
TLS Version Number of requests Percentage
TLSv1.2 2,002,516,373 97.96%
TLSv1.1 4,529,764 0.22%
TLSv1.0 37,160,210 1.82%