13must contain your board server API key.
1415To use, create an HTTP val, then import the `proxy` function from this script and call it like this:
1617```ts
14let colorIndex: number
1516export function setup() {
17console.log("setup")
18// variables
77}
7879function hexagon(x, y, r, c) {
80let hx = (i) => x + sin((i * 2 * PI) / 6) * (i < 0 ? 0 : r)
81let hy = (i) => y + cos((i * 2 * PI) / 6) * (i < 0 ? 0 : r)
201}
202203function drawBorder(border, strokeW = 0) {
204strokeWeight(0)
205rect(0, 0, border, height)
216}
217218export function draw() {}
219220export function keyPressed() {
221if (key == "i") {
222saveCanvas("p5js-" + new Date().getTime(), "png")
226}
227}
228// export function touchEnded() {
229// saveCanvas("p5js-" + new Date().getTime(), "png");
230// }
exampleP5sketchmain.tsx4 matches
5export default sketch(import.meta.url, title)
67export function setup() {
8// console.log("setup", window.innerWidth, window.innerHeight);
9// createCanvas(window.innerWidth, window.innerHeight);
11}
1213export function draw() {
14background(0)
15if (mouseIsPressed) {
21}
2223export function keyPressed() {
24if (key == "i") {
25saveCanvas("p5js-" + new Date().getTime(), "png")
29}
30}
31// export function touchEnded() {
32// saveCanvas("p5js-" + new Date().getTime(), "png");
33// }
redditSearchmain.tsx6 matches
15}
1617async function redditSearch({
18query,
19}: RedditSearchOptions): Promise<ThreadResult[]> {
32}
3334function constructSearchUrl(query: string): string {
35const encodedQuery = encodeURIComponent(query);
36return `https://www.reddit.com/search.json?q=${encodedQuery}&sort=new&t=week&limit=25`;
37}
3839async function processPostData(posts: any[]): Promise<ThreadResult[]> {
40const processedData: ThreadResult[] = [];
4157}
5859function App() {
60const [query, setQuery] = useState("");
61const [results, setResults] = useState<ThreadResult[]>([]);
99}
100101function client() {
102createRoot(document.getElementById("root")).render(<App />);
103}
107}
108109export default async function server(request: Request): Promise<Response> {
110return new Response(`
111<html>
4const ADMIN_PASSWORD = Deno.env.get("ADMIN_PASSWORD") || "defaultpassword"; // Set this in your Val Town environment variables
56async function initializeDatabase() {
7await sqlite.execute(`
8CREATE TABLE IF NOT EXISTS ${KEY}_emails (
14}
1516async function addEmail(email: string) {
17await sqlite.execute(`INSERT OR IGNORE INTO ${KEY}_emails (email) VALUES (?)`, [email]);
18}
1920async function getEmails() {
21const result = await sqlite.execute(`SELECT * FROM ${KEY}_emails ORDER BY timestamp DESC`);
22return result.rows;
23}
2425export default async function server(request: Request): Promise<Response> {
26await initializeDatabase();
27const url = new URL(request.url);
290<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.9.1/gsap.min.js"></script>
291<script>
292document.getElementById('email-form').addEventListener('submit', async function(e) {
293e.preventDefault();
294const email = document.getElementById('email').value;
reMarkableXNYTCrosswordmain.tsx2 matches
3import request from "npm:request";
45export default async function(interval: Interval) {
6// Cookies and Tokens -> use `mitmweb` to navigate to NYTimes.com to grab cookie. Repeat for my.remarkable.com
763},
64})
65.then(function(response) {
66var rmMetadata = { "parent": rmFolderGuid, "file_name": puzzleFriendlyName };
67
9091// Main App Component
92function App() {
93const [synth, setSynth] = useState(null);
94const [analyser, setAnalyser] = useState(null);
207}
208209function client() {
210createRoot(document.getElementById("root")).render(<App />);
211}
213if (typeof document !== "undefined") { client(); }
214215export default async function server(request: Request): Promise<Response> {
216const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
217const SCHEMA_VERSION = 2
ssr_react_minimain.tsx1 match
3536export const hydrate = (importMetaURL: string) =>
37async function(req: Request): Promise<Response> {
38const { author, name } = extractValInfo(importMetaURL);
39const valURL = `https://www.val.town/v/${author}/${name}`;
assistantHarlequinKangaroomain.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))) {
liquidOrangeFowlmain.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))) {