- 😄
:smile:
- 😆
:laughing:
- 😊
:blush:
- 😃
:smiley:
- 😀
:grinning:
- 😏
:smirk:
- 😍
:heart_eyes:
- 😘
:kissing_heart:
- 😚
:kissing_closed_eyes:
- 😳
:flushed:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Include the sa module, needs installing first (npm install sentiment-analysis) | |
const sentimentAnalysis = require('sentiment-analysis'); | |
/** | |
* Gets the sentiment of a sentence | |
* using the sentiment-analysis module | |
* formats it, and prints to console | |
*/ | |
function displaySentiment(inputText, sentimentScore){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"tla":"ABR", | |
"name":"Abbey Road" | |
}, | |
{ | |
"tla":"ACT", | |
"name":"Acton Town" | |
}, | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
async fetch(request, env) { | |
// Extract username and repo from the URL path | |
const url = new URL(request.url); | |
const pathSegments = url.pathname.split('/').filter(Boolean); | |
if (pathSegments.length !== 2) { | |
return new Response('URL must be in the format /{username}/{repo}', { status: 400 }); | |
} | |
const [username, repo] = pathSegments; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Cloudflare Worker script for displaying UK food products | |
* Fetches given item from Tesco.com using search endpoint | |
* Optionally resizes to specified dimensions | |
* Implements caches recently requested images | |
* Swaers a little bit when an error happens | |
*/ | |
addEventListener('fetch', event => { | |
event.respondWith(handleRequest(event.request, event)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Access control headers */ | |
const headers = { | |
'Access-Control-Allow-Origin': '*', | |
'Access-Control-Allow-Methods': 'GET, PUT, POST, OPTIONS', | |
'Access-Control-Allow-Headers': 'Content-Type', | |
'content-type': 'application/json;charset=UTF-8', | |
} | |
/* Listen for incoming requests, and call handler */ | |
addEventListener('fetch', event => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addEventListener('fetch', event => { | |
event.respondWith(handleRequest(event.request)) | |
}) | |
async function handleRequest(request) { | |
const { pathname } = new URL(request.url); | |
const username = pathname.split('/')[1]; | |
if (!username) { | |
return new Response( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Fetch all comments on a given GitHub discussion | |
* A simple REST API, built for Cloudflare Workers | |
* Code licensed under MIT, (C) Alicia Sykes 2024 | |
*/ | |
addEventListener('fetch', event => { | |
event.respondWith(handleRequest(event.request)) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A REST API for fetching the repsponse from | |
* a custom GPT assistant via the OpenAI API | |
* Deployed as a simple Cloudflare Worker | |
* Licensed under MIT (C) Alicia Sykes 2024 | |
*/ | |
(() => { | |
addEventListener("fetch", (event) => { | |
event.respondWith(handleRequest(event.request)); |