Search

Results include substring matches and semantically similar vals. Learn more
hen1227 avatar
JokeGenerator
@hen1227
// Fetches a random joke.
HTTP
import { email } from "https://esm.town/v/std/email?v=9";
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",
const setup = randomJoke.setup;
const punchline = randomJoke.punchline;
export default async function(req: Request): Promise<Response> {
return new Response(
JSON.stringify({ setup, punchline }),
talha_husnain avatar
First
@talha_husnain
// Track which players have folded
Script
function generateDeck() {
function parseHand(handStr) {
function shuffleDeck(deck) {
function generateAllHands(deck) {
function getHandRanks(cards) {
function countOccurrences(arr) {
function isFlush(cards) {
function isStraight(ranks) {
function evaluateHand(cards) {
function precomputeOpponentHands(vpipArray, deck, heroHand) {
stiha avatar
hnFollowPollJob
@stiha
An interactive, runnable TypeScript val by stiha
Script
import { hackerNewsAuthors } from "https://esm.town/v/stiha/hackerNewsAuthors";
import { hnLatestPosts } from "https://esm.town/v/stevekrouse/hnLatestPosts?v=18";
export async function hnFollowPollJob({ lastRunAt }) {
let posts = await hnLatestPosts({
authors: hackerNewsAuthors,
augustohp avatar
BalanceBrightData
@augustohp
An interactive, runnable TypeScript val by augustohp
Script
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
export default async function fetchBrightDataBalance(
token: string,
): Promise<number> {
iamseeley avatar
aquamarineTurtle
@iamseeley
📄 hello, resume Creating, customizing, and hosting resumes can get complicated and time-consuming. This project aims to simplify that process and maybe make it a little more enjoyable. Follow the steps in your resumeConfig to get started . Happy job hunting! 💼✨ Thanks to @nbbaier for the great feedback and resumeValidator !
HTTP
import { helloResume } from 'https://esm.town/v/iamseeley/helloResume';
import { resumeConfig } from 'https://esm.town/v/iamseeley/pinkBear';
export default async function resumeHandler(req: Request): Promise<Response> {
if (req.method === 'GET') {
try {
neverstew avatar
superchargedQueryParams
@neverstew
⚡ Supercharge your query params Tired of the old x=y query param limitations? Ever wished you could say x>y or x!=y as well? Now you can! Parse query params with superchargedQueryParams and you get an array of operations for each parameter instead: import { superchargeQueryParams } from "https://esm.town/v/neverstew/superchargeQueryParams"; console.log(superchargeQueryParams(new URL("https://example.com?a=b&c>d&e!=f&e>=g"))) // {"a":[{"eq":"b"}],"c":[{"gt":"d"}],"e":[{"ne":"f"},{"gte":"g"}]}
Script
export type ParsedQuery<T extends object = {}> = Record<keyof T, ParamOperation>;
const pairPattern = /([a-zA-Z0-9_-]+)([=!<>]=?|[<>])(.+)/;
export function superchargedQueryParams(url: URL): ParsedQuery {
return decodeURIComponent(url.search)
.slice(1)
stevekrouse avatar
lucia_sqlite
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
import { generateId, Scrypt } from "npm:lucia";
export async function createTables(userTable: string, sessionTable: string) {
return sqlite.batch([
FOREIGN KEY (user_id) REFERENCES ${userTable}(id)
async function safeExecute({ userTable, sessionTable, query, error }: {
userTable: string;
throw e;
export async function createUser({ userTable, sessionTable, username, password }: {
userTable: string;
return userId;
export async function getUser(
{ userTable, sessionTable, username },
return Object.fromEntries(zip(columns, rows[0])) as any;
export async function verifyPassword(hashed_password: string, password: string): Promise<boolean> {
return new Scrypt().verify(hashed_password, password);
Pritesh avatar
coherentRedCanidae
@Pritesh
Hello!!! Feel free to mess around with this val and make it your own :). Just click on "Fork" in the top right. You can change the phrases that show up as you click no, you can change the firstImg and secondImg, maybe even add more images. And you can also change the colors and any of the text on the screen! Have fun with it and hopefully your crush says yes hehe.
HTTP
"Please don't do this to me, I'm fragile",
function App() {
const [noClicks, setNoClicks] = useState(0);
</div>
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(
Olafam avatar
linkInBioTemplate
@Olafam
@jsxImportSource https://esm.sh/react
HTTP
/** @jsxImportSource https://esm.sh/react */
import { renderToString } from "npm:react-dom/server";
export default async function(req: Request) {
return new Response(
renderToString(
wilt avatar
emojify
@wilt
An interactive, runnable TypeScript val by wilt
Script
export async function emojify(input: string): Promise<string> {
const { emojify } = await import("npm:emojify-lyrics");
return emojify(input);
robik avatar
quote_of_the_day
@robik
An interactive, runnable TypeScript val by robik
Cron
import { email } from "https://esm.town/v/std/email?v=9";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
export async function quote_of_the_day() {
const [qod] = await fetchJSON(
"https://zenquotes.io/api/today",
creatorbyt avatar
test
@creatorbyt
// Fetches a random joke.
Cron
// ... imports ...
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",
dhvanil avatar
val_7zpl8w4v8d
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export default async function handler(req) {
try {
const result = await (async () => {
function findLowestThreeDigitFibonacci() {
let a = 0, b = 1;
let lowestThreeDigitFibonacci = 0;
pomdtr avatar
testBasicAuth
@pomdtr
An interactive, runnable TypeScript val by pomdtr
HTTP
import { basicAuth } from "https://esm.town/v/pomdtr/basicAuth";
import { verifyToken } from "https://esm.town/v/pomdtr/verifyToken";
function handler(req: Request) {
return new Response("You are authenticated!");
export default basicAuth(handler, {
lukas avatar
feedGenerator
@lukas
// All of this is heavily based on RobPC's feed generator sample
Script
feed: SkeletonFeedPost[];
cursor?: string;
export async function feedGenerator({ feed, serviceDID, publisherDID, hostname }: {
serviceDID?: string;
publisherDID: string;
return q.map<string>((i) => i.toString());
return [q.toString()];
return async function (req: express.Request, res: express.Response) {
const serviceDid = serviceDID ?? `did:web:${hostname}`;
const didCache = new resolver.MemoryCache();