Search

Results include substring matches and semantically similar vals. Learn more
olifrah avatar
lastlogin
@olifrah
LastLogin Authentication Add user auth to your app via LastLogin. LastLogin is a hosted auth provider that enables login through email, Google, Github, etc. How to setup These instructions were written to be easily copy-and-pasteable into LLMs like Townie. import { lastlogin } from "https://esm.town/v/stevekrouse/lastlogin_safe" Wrap the main HTTP handler with lastlogin, exporting it as export default lastlogin(handler) . In the HTTP handler, retrieve the user's email from the request headers using const email = request.headers.get("X-LastLogin-Email") Use the email variable to determine if the user is logged in. If present, display user-specific content; if not, show login options. import { LoginWithGoogleButton } from "https://esm.town/v/stevekrouse/LoginWithGoogleButton" Use the React Component, optionally supplying the text attribute Add "via LastLogin" as context underneat the LoginWithGoogleButton, usually centered and less-emphasized, linking to https://lastlogin.io/ Include a logout link that redirects to "/auth/logout" when the user is logged in. Pass the email from the server to the client-side code if using React hydration or similar techniques. Live demo How it works: Your users click on a link to /auth/login in your app This middleware directs them to login via LastLogin They authenticate to LastLogin LastLogin redirects them back to your app This middleware "logs them in" to your app by giving them a session cookie. In your app, you can read the X-LastLogin-Email header to see which (if any) user is logged in Notes If you want username & password auth: @stevekrouse/lucia_middleware This middleware stores sessions in the lastlogin_session table in your Val Town SQLite This val has NOT been properly audited for security. I am not a security expert. I would suggest only using it for demos, prototypes, or apps where security is not paramount. If you are a security expert, I would appreciate your help auditing this! Todos [ ] Let the user customize the name of the SQLite table [ ] Get a proper security audit for this
Script
* `import { LoginWithGoogleButton } from "https://esm.town/v/stevekrouse/LoginWithGoogleButton"`
* Use the <LoginWithGoogleButton /> React Component, optionally supplying the `text` attribute
* Add "via LastLogin" as context underneat the LoginWithGoogleButton, usually centered and less-emphasized, linking to https:
* Include a logout link that redirects to "/auth/logout" when the user is logged in.
* Pass the email from the server to the client-side code if using React hydration or similar techniques.
![Screenshot 2024-08-08 at 08.48.41.gif](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/36674739-cd88-472c-df16-cd0b3a62bc0
/** @jsxImportSource https://esm.sh/react */
import React, { useState, useEffect } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
import { lastlogin } from "https://esm.town/v/stevekrouse/lastlogin_safe";
</div>
function client() {
const initialEmail = document.getElementById('root').dataset.email;
if (typeof document !== "undefined") {
client();
async function handler(request: Request): Promise<Response> {
movienerd avatar
originalEmeraldPython
@movienerd
* This program creates a movie recommendation system based on moods. * It uses OpenAI to generate movie recommendations based on the user's selected mood and feedback. * The program uses React for the frontend and handles state management for user interactions. * It uses the Val Town OpenAI proxy for backend API calls. * A "More moods" button has been added to dynamically expand the list of available moods.
HTTP
* It uses OpenAI to generate movie recommendations based on the user's selected mood and feedback.
* The program uses React for the frontend and handles state management for user interactions.
* It uses the Val Town OpenAI proxy for backend API calls.
* A "More moods" button has been added to dynamically expand the list of available moods.
/** @jsxImportSource https://esm.sh/react */
import React, { useState } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
type Mood = string;
return moodEmojis[mood] || "🙂";
// Client-side only code
function client() {
createRoot(document.getElementById("root")!).render(<App />);
if (typeof document !== "undefined") {
client();
// Server-side only code
async function server(request: Request): Promise<Response> {
Ttt avatar
emojibasedenglishtofrenchvocabularylearning
@Ttt
Project: Emoji-Based English to French Vocabulary Learner Overview: An interactive web application designed to facilitate French vocabulary learning through a visually engaging emoji-based interface. This website presents users with a grid of items, each pairing an English word with its French equivalent and a representative emoji. Core Features: Interactive vocabulary grid Real-time search functionality Word visibility toggle Alphabetical sorting (A-Z/Z-A) Responsive layout for various devices Dynamic background color on each load Scalability: The current architecture suits small to medium vocabulary sets. For larger datasets or frequent content updates, consider implementing an external storage solution in future iterations. This application offers an effective and engaging method for French language learners, combining modern web technologies with an intuitive user interface to create an accessible educational tool.
HTTP
Scalability:
o medium vocabulary sets. For larger datasets or frequent content updates, consider implementing an external storage solution
This application offers an effective and engaging method for French language learners, combining modern web technologies with
/** @jsxImportSource https://esm.sh/react */
import React, { useMemo, useState } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
const languageItems = [
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") {
client();
export default async function server(request: Request): Promise<Response> {
christancula avatar
cerebras_coder
@christancula
This is an AI code assistant powered by Cerebras , running llama3.3-70b. Inspired by Hassan's Llama Coder . Setup Sign up for Cerebras Get a Cerebras API Key Save it in a Val Town environment variable called CEREBRAS_API_KEY Todos I'm looking for collaborators to help. Fork & send me PRs! [ ] Experiment with two prompt chain (started here )
HTTP
/** @jsxImportSource https://esm.sh/react@18.2.0 */
import Cerebras from "https://esm.sh/@cerebras/cerebras_cloud_sdk";
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
import { Prism as SyntaxHighlighter } from "https://esm.sh/react-syntax-highlighter";
import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
import { STARTER_PROMPTS } from "https://esm.town/v/stevekrouse/cerebras_coder_prompts";
export default async function fiftyTwoStartupsCoder(req: Request): Promise<Response> {
// Dynamic import for SQLite to avoid client-side import
const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
stevekrouse avatar
cron_client_react_fork
@stevekrouse
CronGPT This is a minisite to help you create cron expressions, particularly for crons on Val Town. It was inspired by Cron Prompt , but also does the timezone conversion from wherever you are to UTC (typically the server timezone). Tech Hono for routing ( GET / and POST /compile .) Hono JSX HTML (probably overcomplicates things; should remove) @stevekrouse/openai, which is a light wrapper around @std/openai TODO [ ] simplify by removing HTMX (try doing the form as a GET request, manual JS script, or client side react) [ ] make the timezone picker better (fewer options, searchable) [ ] add a copy button?
HTTP
## TODO
- [ ] simplify by removing HTMX (try doing the form as a GET request, manual JS script, or client side react)
- [ ] make the timezone picker better (fewer options, searchable)
/** @jsxImportSource https://esm.sh/react@18.2.0 */
import cronstrue from "https://esm.sh/cronstrue";
import React, { useState } from "https://esm.sh/react@18.2.0";
import { chat } from "https://esm.town/v/stevekrouse/openai?v=19";
import react_http from "https://esm.town/v/stevekrouse/react_http?v=6";
export default function(req: Request) {
if (req.method === "GET" && url.pathname === "/") {
return react_http({
component: App,
const [cron, setCron] = useState("0 16 * * 1-5");
const onSubmit: React.FormEventHandler<HTMLFormElement> = async function(e) {
e.preventDefault();
nirwan avatar
Family100
@nirwan
@jsxImportSource https://esm.sh/react
HTTP
/** @jsxImportSource https://esm.sh/react */
import React from "https://esm.sh/react";
import ReactDOM from "https://esm.sh/react-dom";
import { createRoot } from "https://esm.sh/react-dom/client";
const { useState, useRef, useEffect } = React;
function compressImage(file, maxWidth = 800, maxHeight = 800, quality = 0.7) {
const data = await response.json();
// Transform server data into client-side state
const transformedNodes = data.reduce((acc, node) => {
</div>
// Simplified client-side rendering
function renderApp() {
root.render(<App />);
// Direct client-side initialization
if (typeof window !== 'undefined') {
tfayyaz avatar
tahirsTil
@tfayyaz
Inspiration for having a blog and TIL/read taken from https://simonwillison.net/ https://bradfrost.com/blog/ https://geoffgraham.me/blog/ https://matthewstrom.com/ To-do: Buy tahirfayyaz.dev domain from iwantmyname.com Use SQLlite to store all the posts Create an editor to post to SQLlite maybe with live preview? Update site to use HTMX Active Search - https://htmx.org/examples/active-search/ Add dynamic tag to posts to show many years ago it was posted - Make sortable New posts: exa.ai similarly search https://exa.ai/search?c=all&q=https%3A%2F%2Fstripe.com%2Fblog%2Faccessible-color-systems&filters=%7B%22domainFilterType%22%3A%22exclude%22%2C%22excludeDomains%22%3A%5B%22stripe.com%22%5D%7D
HTTP
/** @jsxImportSource https://esm.sh/react */
import { renderToString } from "npm:react-dom/server";
export default async function(req: Request) {
<a href="https://maxbo.me/a-html-file-is-all-you-need" style={itemStyle}>
A HTML file is all you need. Lot's of useful client side JavaScript examples including charts, Python and
SQLite.
</a>
<a href="https://www.val.town/v/tfayyaz/honoJsInClientTemplate" style={itemStyle}>
Simple Hono JS val.town Template with client side JavaScript using html Helper
</a>
bhavana avatar
weatherForecastDashboard
@bhavana
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
/** @jsxImportSource https://esm.sh/react@18.2.0 */
import React, { useState, useEffect, useRef } from "https://esm.sh/react@18.2.0";
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
function WeatherDashboard() {
const suggestionRef = useRef(null);
// Close suggestions when clicking outside
useEffect(() => {
function handleClickOutside(event) {
if (suggestionRef.current && !suggestionRef.current.contains(event.target)) {
setShowSuggestions(false);
document.addEventListener('mousedown', handleClickOutside);
return () => document.removeEventListener('mousedown', handleClickOutside);
async function fetchLocationSuggestions(query) {
</div>
function client() {
createRoot(document.getElementById("root")).render(<WeatherDashboard />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
willthereader avatar
v2FanFicScraper
@willthereader
@jsxImportSource https://esm.sh/react
HTTP
/** @jsxImportSource https://esm.sh/react */
import React, { useState } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
// last stable version is 47
</div>
function client() {
console.log("Initializing client-side React application");
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") {
client();
const _REGEX_THREAD_URL = /threads\/(?<id>\d+)/;
movienerd avatar
AIMovie
@movienerd
* This program creates a movie recommendation system based on moods. * It uses OpenAI to generate movie recommendations based on the user's selected mood and feedback. * The program uses React for the frontend and handles state management for user interactions. * It uses the Val Town OpenAI proxy for backend API calls. * Movies are saved in SQLite to prevent recommending the same movie twice. * The SQLite schema version has been updated to fix the 404 error. * A dancing popcorn emoji has been added to the loading message. * The color scheme has been updated to a monochrome look with a modern style and a nice font. * The "More moods" button text has been changed to "Ask the AI for different moods". * The mood generation now keeps track of previously generated moods to avoid repetition. * A list of movies that have been liked, disliked, or not seen is displayed at the bottom of the page. * The JSON parsing has been made more robust to handle non-standard responses.
HTTP
* It uses OpenAI to generate movie recommendations based on the user's selected mood and feedback.
* The program uses React for the frontend and handles state management for user interactions.
* It uses the Val Town OpenAI proxy for backend API calls.
* The JSON parsing has been made more robust to handle non-standard responses.
/** @jsxImportSource https://esm.sh/react */
import React, { useState, useEffect } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
type Mood = string;
return moodEmojis[mood] || "🎭";
// Client-side only code
function client() {
createRoot(document.getElementById("root")!).render(<App />);
if (typeof document !== "undefined") {
client();
// Server-side only code
async function server(request: Request): Promise<Response> {
elibcohen avatar
madpropsv2
@elibcohen
@jsxImportSource https://esm.sh/react
HTTP
/** @jsxImportSource https://esm.sh/react */
import React, { useEffect, useState } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
// Utility function to generate a unique 16-character ID
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
description:
"If this sounds like slavery, well many argue it is. Legislators considered a similar measure in 2022, but it tanked
image: "https://maxm-imggenurl.web.val.run/prison-work-program",
shyaankhan avatar
cerebras_coder
@shyaankhan
This is an AI code assistant powered by Cerebras , running llama3.3-70b. Inspired by Hassan's Llama Coder . Setup Sign up for Cerebras Get a Cerebras API Key Save it in a Val Town environment variable called CEREBRAS_API_KEY Todos I'm looking for collaborators to help. Fork & send me PRs! [ ] Experiment with two prompt chain (started here )
HTTP
/** @jsxImportSource https://esm.sh/react@18.2.0 */
import Cerebras from "https://esm.sh/@cerebras/cerebras_cloud_sdk";
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
import { Prism as SyntaxHighlighter } from "https://esm.sh/react-syntax-highlighter";
import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
import { STARTER_PROMPTS } from "https://esm.town/v/stevekrouse/cerebras_coder_prompts";
// All previous client-side code remains the same...
export default async function cerebras_coder(req: Request): Promise<Response> {
trob avatar
cardSortDragDropApp
@trob
@jsxImportSource https://esm.sh/react
HTTP
/** @jsxImportSource https://esm.sh/react */
import React from "https://esm.sh/react@18.2.0";
import { useState, useEffect, Component } from "https://esm.sh/react@18.2.0";
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
import { DragDropContext, Droppable, Draggable } from "https://esm.sh/react-beautiful-dnd@13.1.1";
class ErrorBoundary extends Component {
</div>
function client() {
try {
console.log("Starting client-side rendering");
const rootElement = document.getElementById("root");
} catch (error) {
console.error("Error in client-side rendering:", error, error.stack);
if (typeof document !== "undefined") { setTimeout(client, 0); }
export default async function server(request: Request): Promise<Response> {
chrisfeldmeier avatar
coder
@chrisfeldmeier
This is an AI code assistant powered by Cerebras , running llama3.3-70b. Inspired by Hassan's Llama Coder . Setup Sign up for Cerebras Get a Cerebras API Key Save it in a Val Town environment variable called CEREBRAS_API_KEY Todos I'm looking for collaborators to help. Fork & send me PRs! [ ] Experiment with two prompt chain (started here )
HTTP
/** @jsxImportSource https://esm.sh/react@18.2.0 */
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
import { Prism as SyntaxHighlighter } from "https://esm.sh/react-syntax-highlighter";
import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
setPrompt: React.Dispatch<React.SetStateAction<string>>;
handleSubmit: (e: React.FormEvent) => void;
const previewRef = React.useRef<HTMLDivElement>(null);
async function handleSubmit(e: React.FormEvent | string) {
<React.Fragment key={iframeKey}>
</React.Fragment>
prashamtrivedi avatar
passwordGen
@prashamtrivedi
@jsxImportSource https://esm.sh/react
HTTP
/** @jsxImportSource https://esm.sh/react */
import React, { useState, useEffect } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
function App() {
<h2 className="text-2xl font-bold mb-4">How to Use</h2>
<ol className="list-decimal list-inside space-y-2 mb-4">
<li>Enter up to 3 words in the input field.</li>
<li>Adjust the password policy settings as needed:</li>
<ul className="list-disc list-inside ml-4 space-y-1">
<li>Set the minimum password length</li>
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") {
client();
async function server(request: Request): Promise<Response> {