val_town_by_example_tocmain.tsx3 matches
15};
1617function todo(title: string) {
18return {
19title: `${title}`,
96const blobKey = "val_town_by_example_toc.json";
9798export default async function refreshToc() {
99const toc: Toc = [];
100for (const item of dataset) {
128}
129130export async function readToc(): Promise<Toc> {
131try {
132return await blob.getJSON(blobKey);
2import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=5";
34export async function aqi(interval: Interval) {
5const location = "halandri 15234, greece"; // <-- change to place, city, or zip code
6const data = await easyAQI({ location });
smallestMissingNatmain.tsx1 match
1var smallestMissingNat = function(arr) {
2var mask = Array(arr.length).fill(false);
3for (var i=0; i < arr.length; i++) {
validateHTMLandCSSmain.tsx3 matches
8};
910function validateHTML(html: string): ValidationResult {
11const errors: ValidationResult['errors'] = [];
12const lines = html.split('\n');
57}
5859function validateCSS(css: string): ValidationResult {
60const errors: ValidationResult['errors'] = [];
61const lines = css.split('\n');
102}
103104export function validateHTMLAndCSS(code: string): ValidationResult {
105const htmlErrors = validateHTML(code);
106const cssErrors = validateCSS(code);
counterTownmain.tsx6 matches
4import { Hono } from "npm:hono";
56function setupTable() {
7return sqlite.execute(`create table if not exists counter_town (
8time timestamp default current_timestamp,
21// TODO - we should probably not expose this to our users
22// this rewrite removes that and stores the url underneath
23function removeCustomDomainRewriter(req) {
24const servedFor = req.headers.get("x-served-for");
25return req.url.replace("saascustomdomains.val.run", servedFor);
26}
2728function countRequest(req: Request) {
29console.log(req);
30return sqlite.execute({
41}
4243export function counterTownMiddleware(handler) {
44return async function(req: Request) {
45// don't await this so it doesn't add to the timing
46countRequest(req).catch(e => console.error(e));
125126// zipped execute
127async function execute(sql) {
128const results = await sqlite.execute(sql);
129return results.rows.map(row =>
slack_cleanermain.tsx12 matches
1export function slackHTMLToMarkdown(html) {
2removeAbsolutePositioning();
39let markdown = "";
1011function convertMessage(messageElement) {
12function safeGetAttribute(selector, attribute) {
13const element = messageElement.querySelector(selector);
14return element ? element.getAttribute(attribute) : "";
28let messageMarkdown = "";
2930function processNode(node) {
31if (node.nodeType === Node.TEXT_NODE) {
32return node.textContent;
122// -----
123124function postProcessMarkdown(markdown) {
125// Split the markdown into lines
126let lines = markdown.split("\n");
155}
156157function parseTimestamp(ariaLabel) {
158const now = new Date();
159const months = [
203}
204205function removeAbsolutePositioning() {
206// Get all elements on the page
207var allElements = document.getElementsByTagName("*");
333import { marked } from "https://cdn.jsdelivr.net/npm/marked/lib/marked.esm.js";
334335window.convertToMarkdown = function() {
336const htmlInput = document.getElementById("htmlInput").innerHTML;
337const markdown = slackHTMLToMarkdown(htmlInput);
341}
342
343function copyToClipboard(selector, { html }) {
344const target = document.querySelector(selector);
345352}
353354function copyMarkdownAndHTMLToClipboard() {
355const mdTarget = document.querySelector('#markdownOutput');
356const htmlTarget = document.querySelector('#renderedMarkdown');
364}
365
366async function pasteFromClipboard() {
367const clipboardItems = await navigator.clipboard.read();
368for (const clipboardItem of clipboardItems) {
407`;
408409export default async function(req: Request) {
410return new Response(html, {
411headers: {
placemarkGlobeMonitormain.tsx2 matches
1import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
23async function fetchPluginData(pluginId) {
4const response = await fetch(`https://www.figma.com/api/plugins/${pluginId}/versions`);
5if (!response.ok) {
10}
1112export default async function(interval: Interval) {
13try {
14const microPlugin = await fetchPluginData("1349001943025285729");
twitterAlertmain.tsx1 match
1import { email } from "https://esm.town/v/std/email";
23// Hypothetical API functions (these would need to be implemented or replaced with actual APIs)
4import { searchGoogle, searchLinkedIn, searchX } from "https://esm.town/v/mwsz/searchApis";
5
HttpResponsemain.tsx4 matches
1export function internalServerError(err: unknown, body: string = "An unknown error has occurred.") {
2console.error("Internal Server Error", String(err));
38}
910export function badRequest(body: string = null) {
11return new Response(body, {
12status: 400,
15}
1617export function forbidden(body: string = null) {
18return new Response(body, {
19status: 401,
22}
2324export function success(body: string = null) {
25return new Response(body, {
26status: 200,
1function extractCredentials(authorization) {
2const parts = authorization.split(" ");
3if (parts[0] != "Basic") {
11export type ServeHandler = (req: Request) => Response | Promise<Response>
1213export function basicAuth(next: ServeHandler, params: {
14verifyUser: (username: string, password: string) => boolean | Promise<boolean>;
15}): ServeHandler {