Skip to content

Instantly share code, notes, and snippets.

#[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;
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
});
}
@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",
@phamann
phamann / Network-Timing-API.js
Last active August 9, 2020 03:00
Example of gathering request timing information using the Navigation timing API
function getPerformanceData() {
var perf = window.performance || window.msPerformance || window.webkitPerformance || window.mozPerformance;
if (perf) {
var t = perf.timing;
return [
// Time required for domain lookup.
t.domainLookupEnd - t.domainLookupStart,
// Time to establish a connection to server.
t.connectEnd - t.connectStart,

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 / 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() {},