1# Notehub
2
3A set of helper functions for interacting with the Notehub API
4
5Requires `NOTEHUB_CLIENT_ID` and `NOTEHUB_CLIENT_SECRET` [environment variables](https://www.val.town/settings/environment-variables) to be configured.
1export function sleep(milliseconds = 3000) {
2 return new Promise(resolve => setTimeout(resolve, milliseconds));
3}
1export function sleep(milliseconds = 3000) {
2 return new Promise(resolve => setTimeout(resolve, milliseconds));
3}
1/** round with abitrary decimal precision */
2export function round(number: number, precision = 5) {
3 return Math.round(number * Math.pow(10, precision)) / Math.pow(10, precision);
4}
4import { currency } from "https://esm.town/v/stevekrouse/currency";
5
6export async function btcPriceAlert() {
7 const lastBtcPrice: number = await blob.getJSON("lastBtcPrice");
8
5// Sends an email with all the open PRs that have not had any activity
6// for specified period of days
7// Set up this function to run every day (or any interval)
8export async function staleGithubPRsEmail() {
9 // Set up a secret named githubRepos with all the repos you want to analyze (comma separated)
10 let repos = Deno.env.get("githubRepos")?.split(",").filter((r) => r.trim()) ?? [];
3import { readmeToHtmlResponse } from "https://esm.town/v/pomdtr/readme";
4
5async function createScreenshot(code: string) {
6 const apiUrl = "https://sourcecodeshots.com/api/image";
7 const resp = await fetch(apiUrl, {
19}
20
21export default async function(req: Request) {
22 const url = new URL(req.url);
23 const [author, file] = url.pathname.slice(1).split("/");
1// View at https://andreterron-htmlExample.web.val.run?name=Andre
2export default async function(req: Request): Promise<Response> {
3 const query = new URL(req.url).searchParams;
4
2Gets information about a specific val.
3
4To access private vals, pass your API token as a secret to the function. Read more about [authentication](https://docs.val.town/api/authentication) to understand how to generate a token and save it as a secret.
3import { hnLatestPosts } from "https://esm.town/v/stevekrouse/hnLatestPosts?v=18";
4
5export default async function({ lastRunAt }) {
6 let posts = await hnLatestPosts({
7 query: "AI, LLM",
A helper function to build a file's email
Simple functional CSS library for Val Town
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",