Skip to content

Instantly share code, notes, and snippets.

View index.ts
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
});
}
View main.rs
#[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 Aug 11, 2020
Compute@Edge NEL example report
View cae_nel_report.json
{
"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",
View keybase.md

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@phamann
phamann / index.js
Created Mar 20, 2017
Delete all services within a Fastly acconut
View index.js
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'
}
View dummy.csv
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 Aug 29, 2015
Simple ServiceWorker for Guardian hackday
View worker.js
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 Oct 25, 2013
RequireJS example
View Gruntfile.js
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",
View Lessons.md

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 Jun 13, 2013
Require.js for ben
View routerExtend.js
//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() {},