virtualPetSimmain.tsx5 matches
16const FOODS = ["🍎", "🍌", "🥕", "🍖", "🍣"];
1718function App() {
19const [pet, setPet] = useState(null);
20const [loading, setLoading] = useState(true);
77}
7879function client() {
80createRoot(document.getElementById("root")).render(<App />);
81}
85}
8687async function server(request: Request): Promise<Response> {
88const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
89const SCHEMA_VERSION = 1;
138}
139140async function getPet() {
141const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
142const SCHEMA_VERSION = 1;
164}
165166async function updatePet(action) {
167const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
168const SCHEMA_VERSION = 1;
migrationsmain.tsx1 match
1import { sqlite as valtown_sqlite } from "https://esm.town/v/std/sqlite";
23export async function migrate(
4sqlite: typeof valtown_sqlite,
5key: string,
KidsCodingDameDinoAdventuremain.tsx3 matches
69};
7071function App() {
72const [grid, setGrid] = useState(initialGrid);
73const [moves, setMoves] = useState([]);
354}
355356function client() {
357createRoot(document.getElementById("root")).render(<App />);
358}
359if (typeof document !== "undefined") { client(); }
360361async function server(request: Request): Promise<Response> {
362const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
363const SCHEMA_VERSION = 1
getWeathermain.tsx1 match
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
23export async function getWeather(location: string): Promise<WeatherResponse> {
4return fetchJSON(`https://wttr.in/${location}?format=j1`);
5}
getWeatherREADME.md1 match
1## Get Weather
23Simple function to get weather data from the free [wttr.in](https://wttr.in/:help) service.
45```ts
sunsetNYCalendarmain.tsx3 matches
2// and creates a simple form to generate a calendar of events occurring before sunset.
34async function server(request: Request): Promise<Response> {
5try {
6const url = new URL(request.url);
79}
8081async function generateSunsetEvents(action: string, minutesBefore: number, endDate: Date) {
82const events = [];
83let currentDate = new Date();
105}
106107async function getSunsetTime(date: Date): Promise<Date> {
108const formattedDate = `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')}`;
109const response = await fetch(`https://api.sunrise-sunset.org/json?lat=40.7128&lng=-74.0060&date=${formattedDate}&formatted=0`);
TopHackerNewsDailyEmailmain.tsx3 matches
27// we create a OpenAI Tool that takes our schema as argument
28const extractContentTool: any = {
29type: "function",
30function: {
31name: "extract_content",
32description: "Extracts the content from the given webpage(s)",
5657// we retrieve the serialized arguments generated by OpenAI
58const result = completion.choices[0].message.tool_calls![0].function.arguments;
59// the serialized arguments are parsed into a valid JavaScript array of objects
60const parsed = schema.parse(JSON.parse(result));
redditSearchmain.tsx4 matches
1516// Use Browserbase (with proxy) to search and scrape Reddit results
17export async function redditSearch({
18query,
19apiKey = Deno.env.get("BROWSERBASE_API_KEY"),
46}
4748function constructSearchUrl(query: string): string {
49const encodedQuery = encodeURIComponent(query).replace(/%20/g, "+");
50return `https://www.reddit.com/search/?q=${encodedQuery}&type=link&t=week`;
51}
5253async function extractPostData(page: any): Promise<Partial<ThreadResult>[]> {
54return page.evaluate(() => {
55const posts = document.querySelectorAll("div[data-testid=\"search-post-unit\"]");
67}
6869async function processPostData(postData: Partial<ThreadResult>[]): Promise<ThreadResult[]> {
70const processedData: ThreadResult[] = [];
71
slackScoutmain.tsx10 matches
15}
1617export default async function(interval: Interval): Promise<void> {
18try {
19await createTable();
3839// Create an SQLite table
40async function createTable(): Promise<void> {
41await sqlite.execute(`
42CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
5051// Fetch Hacker news, Twitter, and Reddit results
52async function fetchHackerNewsResults(topic: string): Promise<Website[]> {
53return hackerNewsSearch({
54query: topic,
58}
5960async function fetchTwitterResults(topic: string): Promise<Website[]> {
61return twitterSearch({
62query: topic,
67}
6869async function fetchRedditResults(topic: string): Promise<Website[]> {
70return redditSearch({ query: topic });
71}
7273function formatSlackMessage(website: Website): string {
74const displayTitle = website.title || website.url;
75return `*<${website.url}|${displayTitle}>*
78}
7980async function sendSlackMessage(message: string): Promise<Response> {
81const slackWebhookUrl = Deno.env.get("SLACK_WEBHOOK_URL");
82if (!slackWebhookUrl) {
104}
105106async function isURLInTable(url: string): Promise<boolean> {
107const result = await sqlite.execute({
108sql: `SELECT 1 FROM ${TABLE_NAME} WHERE url = :url LIMIT 1`,
112}
113114async function addWebsiteToTable(website: Website): Promise<void> {
115await sqlite.execute({
116sql: `INSERT INTO ${TABLE_NAME} (source, url, title, date_published)
120}
121122async function processResults(results: Website[]): Promise<void> {
123for (const website of results) {
124if (!(await isURLInTable(website.url))) {
11const client = new OpenAI({ apiKey: Deno.env.get("OPENAI_API_KEY") });
1213async function main() {
14const stream = client.beta.chat.completions.stream({
15model: "gpt-4o-mini",