What crap is happening today then?

Nerdy stuff 🤓

Monday

Cloudflare (Who I love more than life lately)

Cloudflare dropped workers.dev over the weekend and they’re amazing, 100k requests a day on free tier is just crazy and unlike other cloud providers you’re running code at the edge by default instantly, here’s somthing I whipped up in 5 mins

addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request))
})

async function handleRequest(request) {
  let location = await lookupIP(request.headers.get("CF-Connecting-IP"))
  return new Response('Hello person at : ' + location, {status: 200})
}

async function lookupIP(ip){
  const response = await fetch("http://ip-api.com/json/" + ip);
  const { headers } = response;
  const body = await response.json();
  if(body.status == "success") 
    return body.regionName + ", " + body.city + ", " + body.zip + "\nOn ISP : " + body.isp;
  return "No data :(";
}
What’s great about these workers compared to other cloud providers serverless offerings is you’re only timed while your code is running (you get 10ms which is a lot in web computing time) when that fetch("http://ip-api.com/json/" + ip); call is made you’re not being timed, then when it comes back and you keep working the timer starts again (I’m gonna try making some more complicated stuff and come back to this)

Netlify (Where this site is hosted)

Netlify has this awsome feature, when you create a pull request on github it makes a preview of the site with the changes, which is great for testing production sites but also good for saaaaaay testing blog post rendering when you’re using the shitty github file editor as an editor…. (note: find a damn online markdown editor)

Netlify deploy image

Also the stuff I’ve setup for this site is kinda cool, ima do a full post on making a whole site like this with proper CDN’d image hosting for £0 soon

Note

I’m writing this in the editor in github, I probably need to come up with a web based markdown editor

Also I’ve made this a weekly thing but it’s called daily I’m gonna split each post in to days or it’ll end up spammy