Search

Results include substring matches and semantically similar vals. Learn more
stevekrouse avatar
cron
@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 HTMX (probably overcomplicates things; should remove) @stevekrouse/openai, which is a light wrapper around @std/openai I'm finding HTMX a bit overpowered for this, so I have two experimental forks without it: Vanilla client-side JavaScript: @stevekrouse/cron_client_side_script_fork Client-side ReactJS (no SSR): @stevekrouse/cron_client_react_fork I think (2) Client-side React without any SSR is the simplest architecture. Maybe will move to that.
HTTP
* HTMX (probably overcomplicates things; should remove)
* @stevekrouse/openai, which is a light wrapper around @std/openai
I'm finding HTMX a bit overpowered for this, so I have two experimental forks without it:
/** @jsxImportSource npm:hono@3/jsx */
import { chat } from "https://esm.town/v/stevekrouse/openai";
import cronstrue from "npm:cronstrue";
return c.html(<Cron cron={cron} timezone={timezone} />);
function Cron({ cron, timezone }) {
let translation;
arshayp avatar
euphoricGreenSnake
@arshayp
// Fetches a random joke.
Script
import { email } from "https://esm.town/v/std/email?v=9";
// Fetches a random joke.
function fetchRandomJoke() {
const SAMPLE_JOKE = {
"setup": "What do you call a group of disorganized cats?",
]/ ... imports ...
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",
briannafountain avatar
imaginativeLimeOcelot
@briannafountain
An interactive, runnable TypeScript val by briannafountain
Script
function fetchRandomJoke() {
const SAMPLE_JOKE = {
"setup": "What do you call a group of disorganized cats?",
stevekrouse avatar
dateme_faq
@stevekrouse
@jsxImportSource npm:hono@3/jsx
Script
import Layout from "https://esm.town/v/stevekrouse/dateme_layout";
let linkClass = "text-sky-600 hover:text-sky-500";
export default function FAQ(c) {
return c.html(
<Layout activeTab={new URL(c.req.url).pathname}>
dhvanil avatar
val_CMNAhvMXEq
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export default async function handler(req) {
try {
const result = await (async () => {
function isPrime(num) {
if (num <= 1) return false;
return true;
function findLowestThreeDigitPrime() {
for (let num = 100; num < 1000; num++) {
Apache0ne avatar
oneshotdemoprompted
@Apache0ne
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
this.drawCards();
function GameSimulator() {
const [player, setPlayer] = useState(new Creature(20, 5, 3, Rarity.Rare, ElementType.Fire));
</div>
function App() {
return <GameSimulator />;
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
return new Response(
stevekrouse avatar
sqlite_admin_table
@stevekrouse
@jsxImportSource https://esm.sh/hono@3.9.2/jsx
Script
import { sqlite } from "https://esm.town/v/std/sqlite";
import { css } from "https://esm.town/v/stevekrouse/sqlite_admin_css";
export async function sqlite_admin_table(name: string) {
if (!name.match(/^[A-Za-z_][A-Za-z0-9_]*$/)) return <>Invalid table name</>;
let data = await sqlite.execute(`SELECT * FROM ${name}`);
benni avatar
ikeaSecondChanceOffers
@benni
An interactive, runnable TypeScript val by benni
Cron
import { blob } from "https://esm.town/v/std/blob";
import { email } from "https://esm.town/v/std/email";
export default async function(interval: Interval) {
const locale = "de/de";
const stores = [117, 187, 226];
stevedylandev avatar
fetchPinatsPosts
@stevedylandev
An interactive, runnable TypeScript val by stevedylandev
Script
let endDate = Math.floor(currentDate.getTime() / 1000);
let startDate = Math.floor(currentDate.setDate(currentDate.getDate() - 7) / 1000);
export async function fetchPinataPosts() {
try {
const soRes = await fetch(
stevekrouse avatar
cron2
@stevekrouse
@jsxImportSource npm:hono@3/jsx
HTTP
/** @jsxImportSource npm:hono@3/jsx */
import { chat } from "https://esm.town/v/stevekrouse/openai";
import cronstrue from "npm:cronstrue";
// convert a timezone string like America/New_York to "EST"
function shortenTimezoneString(timeZone: string) {
const string = new Date().toLocaleString("en-US", { timeZone, timeZoneName: "short" });
return (tzDate.getTime() - utcDate.getTime()) / (60 * 60 * 1000);
export async function compile(description: string, timezone: string) {
const { content } = await chat([
guillermodoghel avatar
leaderboardApp
@guillermodoghel
@jsxImportSource https://esm.sh/react
HTTP
import { createRoot } from "https://esm.sh/react-dom/client";
function App() {
const [page, setPage] = useState("home");
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
async function server(request: Request): Promise<Response> {
return new Response(
tmcw avatar
httpMockingExample
@tmcw
HTTP Val Mocking example This is an example of mocking an HTTP val. Let's say that you're developing a val that responds to a POST request. That's tricky to debug and develop in the Browser preview tab, which just shows a GET request. But you can do it, because with web-standard Request & Response objects, requests and responses are values, and we can create those values ourselves.
HTTP
* with a body, which is a JSON object with a name
* member.
export const httpHandler = async function(req: Request): Promise<Response> {
if (req.method !== "POST") return new Response("Bad request: only POST allowed", { status: 400 });
const body = await req.json();
webandapktesting avatar
selflessBlackEarthworm
@webandapktesting
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
function App() {
const [isLogin, setIsLogin] = useState(true);
gap: '10px'
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
dhvanil avatar
web_arkk46ZTkl
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_arkk46ZTkl(req) {
return new Response(`<!DOCTYPE html>
<html>
Itumeleng_Randy_Malau avatar
CommuniZENDesign
@Itumeleng_Randy_Malau
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
icon: "🌱",
function CommuniZEN() {
const [activeSection, setActiveSection] = useState("dashboard");
// Client-side rendering
function client() {
createRoot(document.getElementById("root")).render(<CommuniZEN />);
// Server-side rendering
export default async function server(request: Request): Promise<Response> {
return new Response(