4import process from "node:process";
5
6export async function hnValTown({ lastRunAt }: Interval) {
7 // Edit to update time frame
8 const twoMonthsAgo = new Date();
1import emojis from "npm:emojilib" with { type: "json" };
2
3function emojiToString([k, v]: [string, string[]]) {
4 return `${k} ${v.join(", ")}`;
5}
18const openai = new OpenAI();
19
20async function getEmbedding(emoji: string): Promise<number[]> {
21 const result = await openai.embeddings.create({
22 input: emoji,
34
35// Calculate cosine similarity between two vectors
36function cosineSimilarity(vecA: number[], vecB: number[]): number {
37 const dotProduct = vecA.reduce((sum, a, i) => sum + a * vecB[i], 0);
38 const magnitudeA = Math.sqrt(vecA.reduce((sum, a) => sum + a * a, 0));
46
47// Find nearest neighbors for a given emoji
48function findNearestNeighbors(
49 targetEmbedding: number[],
50 allEmbeddings: EmojiEmbedding[],
3import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
4
5function App() {
6 const [jobs, setJobs] = useState([]);
7 const [messages, setMessages] = useState([]);
220}
221
222function client() {
223 createRoot(document.getElementById("root")).render(<App />);
224}
225if (typeof document !== "undefined") { client(); }
226
227export default async function server(request: Request): Promise<Response> {
228 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
229 const KEY = "jobBoardChatApp";
13];
14
15function App() {
16 const [noClicks, setNoClicks] = useState(0);
17 const [isValentine, setIsValentine] = useState(false);
98}
99
100function client() {
101 createRoot(document.getElementById("root")).render(<App />);
102}
103if (typeof document !== "undefined") { client(); }
104
105export default async function server(request: Request): Promise<Response> {
106 return new Response(
107 `
10}
11
12function Tooltip({ children, content }: TooltipProps) {
13 const [isVisible, setIsVisible] = useState(false);
14 const tooltipRef = useRef<HTMLDivElement>(null);
49}
50
51function formatBytes(bytes: number, decimals = 2) {
52 if (bytes === 0) return "0 Bytes";
53 const k = 1024;
58}
59
60function copyToClipboard(text: string) {
61 navigator.clipboard.writeText(text).then(() => {
62 console.log("Text copied to clipboard");
66}
67
68function ActionMenu({ blob, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
69 const [isOpen, setIsOpen] = useState(false);
70 const menuRef = useRef(null);
73
74 useEffect(() => {
75 function handleClickOutside(event) {
76 if (menuRef.current && !menuRef.current.contains(event.target)) {
77 event.stopPropagation();
155}
156
157function BlobItem({ blob, onSelect, isSelected, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
158 const [isLoading, setIsLoading] = useState(false);
159 const decodedKey = decodeURIComponent(blob.key);
216}
217
218function App({ initialEmail, initialProfile, sourceURL }) {
219 const encodeKey = (key: string) => encodeURIComponent(key);
220 const decodeKey = (key: string) => decodeURIComponent(key);
6// Existing code remains the same...
7
8export default async function server(request: Request): Promise<Response> {
9 try {
10 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
199
200// Rest of the client-side code remains unchanged
201function Dashboard({ user }) {
202 // Existing dashboard code...
203
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function WeatherDashboard() {
6 const [location, setLocation] = useState({ latitude: 40.7128, longitude: -74.0060 }); // Default to NYC
7 const [weather, setWeather] = useState(null);
9
10 useEffect(() => {
11 async function fetchWeather() {
12 try {
13 const response = await fetch(
26 }, [location]);
27
28 function getWeatherDescription(code) {
29 const descriptions = {
30 0: "Clear sky ☀️",
56 }
57
58 function handleLocationChange(e) {
59 const [lat, lon] = e.target.value.split(',').map(parseFloat);
60 setLocation({ latitude: lat, longitude: lon });
140};
141
142function client() {
143 createRoot(document.getElementById("root")).render(<WeatherDashboard />);
144}
145if (typeof document !== "undefined") { client(); }
146
147export default async function server(request: Request): Promise<Response> {
148 return new Response(`
149 <html>
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function SeoAnalyzer() {
6 const [url, setUrl] = useState('');
7 const [seoResults, setSeoResults] = useState(null);
61}
62
63function client() {
64 createRoot(document.getElementById("root")).render(<SeoAnalyzer />);
65}
66if (typeof document !== "undefined") { client(); }
67
68export default async function server(request: Request): Promise<Response> {
69 if (request.method === 'POST' && new URL(request.url).pathname === '/analyze') {
70 const { url } = await request.json();
3import React, { useState } from "https://esm.sh/react@18.2.0";
4
5function WebsiteRanker() {
6 const [url, setUrl] = useState("");
7 const [ranking, setRanking] = useState(null);
97}
98
99function client() {
100 createRoot(document.getElementById("root")).render(<WebsiteRanker />);
101}
102if (typeof document !== "undefined") { client(); }
103
104export default async function server(request: Request): Promise<Response> {
105 if (request.method === "POST" && new URL(request.url).pathname === "/rank") {
106 try {
9const thisURL = parseProject(import.meta.url).links.self.project;
10
11function StatusRow({ rows }) {
12 return (
13 <div className="w-full flex flex-col space-y-2">
31}
32
33function StatusSection({ url, rows }) {
34 const sectionRows = rows.filter(row => row[0] === url);
35 const percentUp = Math.round((sectionRows.filter(row => row[1]).length / sectionRows.length) * 100);
47}
48
49export default async function(req: Request): Promise<Response> {
50 const { rows } = await sqlite.execute(
51 "select url, ok, duration, timestamp from uptime order by timestamp desc limit 200",