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",
twitterSearchmain.tsx2 matches
11}
1213function formatTweetText(text: string): string {
14// Remove any URLs from the text
15text = text.replace(/https?:\/\/\S+/g, "");
32}
3334export async function twitterSearch({
35query,
36maxResults = 4,
ForestryFinancialModelmain.tsx3 matches
21);
2223function App() {
24const [landSize, setLandSize] = useState(1000);
25const [sections, setSections] = useState(5);
124}
125126function client() {
127createRoot(document.getElementById("root")).render(<App />);
128}
132}
133134export default async function server(request: Request): Promise<Response> {
135return new Response(`
136<!DOCTYPE html>
hackerNewsSearchmain.tsx8 matches
9}
1011export async function hackerNewsSearch({
12query = "Artificial Intelligence",
13pages = 3,
101}
102103async function scrapePageThreads(page) {
104const scrollToBottom = async () => {
105await page.evaluate(async () => {
122await scrollToBottom();
123124return page.evaluate(async (dateConverterFunctionString) => {
125const convertDateInBrowser = async (relativeDate) => {
126try {
127// Reconstruct the date converter function from its string representation
128const dateConverterFunction = eval(`(${dateConverterFunctionString})`);
129const result = await dateConverterFunction({ relativeDate });
130131// Check if the result is a Response object (from a potential fetch call)
172// Return the array of thread data
173return threads;
174}, convertRelativeDateToString.toString()); // Pass the string representation of the original function
175}
176177async function goToNextPage(page, currentPage) {
178// Scroll to the bottom of the page
179await page.evaluate(async () => {