Skip to content

Instantly share code, notes, and snippets.

import { Request, Response, Fastly } from "@fastly/as-compute";
const HTTPBIN_BACKEND = "httpbin";
function badRequest(): Response {
return new Response(String.UTF8.encode("Bad request"), {
status: 400
});
}
#[macro_use]
extern crate lazy_static;
use fastly::http::{Method, StatusCode};
use fastly::{
Body, Error, PendingRequest, Request, RequestBuilderExt, RequestExt, Response, ResponseExt,
};
use regex::Regex;
use std::convert::From;
@phamann
phamann / cae_nel_report.json
Created August 11, 2020 12:23
Compute@Edge NEL example report
{
"timestamp": 1597148043,
"client": {
"client_ip": "",
"client_user_agent": "Chrome 84.0.4147",
"client_asn": 5089,
"client_asname": "virgin media limited",
"client_city": "haringey",
"client_country_code": "GB",
"client_continent_code": "EU",

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@phamann
phamann / index.js
Created March 20, 2017 15:27
Delete all services within a Fastly acconut
require('dotenv').config();
const fetch = require('node-fetch');
const API = 'https://api.fastly.com';
const TOKEN = process.env.FASTLY_API_TOKEN;
const OPTIONS = {
headers: {
'Fastly-Key': TOKEN,
'Accept': 'application/json'
}
id first_name last_name email gender ip_address
1 Jerry Simpson jsimpson0@vimeo.com Male 65.216.136.96
@phamann
phamann / worker.js
Last active August 29, 2015 14:03
Simple ServiceWorker for Guardian hackday
console.log("Worker startup");
this.oninstall = function(event) {
console.log('Worker install');
event.waitUntil(
caches.create('static').then(function(cache) {
return cache.add(
//Templates
@phamann
phamann / Gruntfile.js
Created October 25, 2013 07:52
RequireJS example
requirejs: {
options: {
baseUrl: "common/app/assets/javascripts",
paths: {
"bean": "components/bean/bean",
"bonzo": "components/bonzo/src/bonzo",
"domReady": "components/domready/ready",
"EventEmitter": "components/eventEmitter/EventEmitter",
"qwery": "components/qwery/mobile/qwery-mobile",
"reqwest": "components/reqwest/src/reqwest",

Lesson's learnt building the Guardian

Below is a collection of my favourite responses I gathered from Guardian engineers when asked the question: What have you learnt starting from scratch and building a mobile-first next generation web platform for the Guardian?

Daithi O Crualaoich

  • Work with great people.
  • Deploy like crazy. This means the team has to control the infrastructure as well as code.
  • Design is not a service. Designers have to sit in the team.
  • Infrastructure is intrinsically unreliable. Discard and replace is the robust strategy.
  • Use your CDN for HTML too.
  • Don't always do as you are told.
@phamann
phamann / routerExtend.js
Created June 13, 2013 16:38
Require.js for ben
//You are using underscores extend so you need include it :)
define(['underscore'], function(_) {
//This could be some kind of utilities modules
//Define the extend method
var extend = function() {
_.extend(Backbone.Router.prototype, Backbone.Events, {
before: function() {},
after: function() {},