Search

Results include substring matches and semantically similar vals. Learn more
janpaul123 avatar
valle_tmp_065083194034399444924236047421617
@janpaul123
// Initialize sample stories and store them in blob storage
HTTP
// Initialize sample stories and store them in blob storage
const SAMPLE_STORIES_KEY = "hn_sample_stories";
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {
iamseeley avatar
pyodideDataVis
@iamseeley
An interactive, runnable TypeScript val by iamseeley
HTTP
<div id="plotContainer"></div>
<script>
async function main() {
let pyodide = await loadPyodide();
await pyodide.loadPackage('numpy');
janpaul123 avatar
valle_tmp_3607258085523705726507190480068266
@janpaul123
// Initialize sample stories and store them in blob storage
HTTP
// Initialize sample stories and store them in blob storage
const SAMPLE_STORIES_KEY = "hn_sample_stories";
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {
tkneisly avatar
SupabaseAuthExample
@tkneisly
An interactive, runnable TypeScript val by tkneisly
HTTP
export default async function server(request: Request): Promise<Response> {
const SUPABASE_URL = Deno.env.get("SUPABASE_URL");
const SUPABASE_KEY = Deno.env.get("SUPABASE_KEY");
yawnxyz avatar
counter
@yawnxyz
// Export app.fetch for Val Town, otherwise export app โ€” this is only for hono apps
HTTP
let lastSavedText = ''; // Track the last saved text
function populateTextAreaFromHash() {
const hash = window.location.hash.slice(1); // Remove the '#' character
updateCounts();
async function updateCounts() {
const encoder = new TextEncoder();
}, 10000); // 10 seconds
async function tokenize() {
const response = await fetch('/tokenize', {
// button.click(); // This will trigger the event listener we added above
function adjustTextareaHeight() {
inputText.style.height = 'auto';
window.addEventListener('hashchange', populateTextAreaFromHash);
// Add the history functions:
async function updateHistoryList() {
const history = await db.history.reverse().limit(50).toArray();
return c.json({ error: error.message }, 500);
function replaceEmojisWithCodePoints(text) {
console.log("Replacing emojis with code points:", text);
return `[U+${codePoint}]`;
function getTiktokenSegments(encoder, inputText) {
try {
osasbaba avatar
delicateMaroonMandrill
@osasbaba
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
"Alina pleaaase???",
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(
maemoon avatar
labLoginUpdateStatus
@maemoon
An interactive, runnable TypeScript val by maemoon
HTTP
import * as bcrypt from "https://deno.land/x/bcrypt@v0.4.1/mod.ts";
import { sqlite } from "https://esm.town/v/std/sqlite";
export default async function(req: Request): Promise<Response> {
const TABLE_NAME = "lab_login_users_with_times";
const body = await req.json();
dhvanil avatar
val_Bew6MWpbJS
@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 lowestThreeDigit = 0;
paulkinlan avatar
emailSummaryHandler
@paulkinlan
Email Summary Service This val is an email handler replies to emails it recieves with an LLM-generated summary. To use, forward an email to paulkinlan.emailSummaryHandler@valtown.email Blog post: https://paul.kinlan.me/projects/email-summary-service/
Email
import { extractValInfo } from "https://esm.town/v/stevekrouse/extractValInfo";
import { OpenAI } from "npm:openai";
function stripHtmlBackticks(html: string): string {
return html.replace(/^```html\n?/, "").replace(/\n?```$/, "");
export default async function(e: Email) {
const openai = new OpenAI();
console.log(`from: ${e.from} to: ${e.to} subject: ${e.subject}, cc: ${e.cc}, bcc: ${e.bcc}`);
from = to;
const summary = await openai.chat.completions.create({
messages: [
tr3ntg avatar
makeCallOnEmail
@tr3ntg
Make Phone Call with Twilio Upon Email Receipt Backstory I bought a Bluetooth temperature monitor to monitor the temp in one of my rooms. I made sure to purchase one that sends alerts for temperatures that are out of a given range. Unfortunately, those notifications canโ€™t be set to override Focus modes or when your phone is on Silent. But the app does allow you to add any email address for an alert. So, a Val Town Email handler + Twilio, and Iโ€™ve got myself an unmissable alert for if that room ever gets too hot or cold. ๐Ÿ”ฅ๐ŸงŠ How to Use Fork this Val, fill in your environment tokens (including phone number) and watch a call come through when you email the Val! Caveats This will call you on EVERY email. This works for my use case as the email is only registered with my temperature monitoring device. (You'll need to keep your emailing Val private, or add on some sort of verification to prevent errant emails and calls.)
Email
export default async function(e: Email) {
try {
const Twilio = (await import("https://esm.sh/twilio@4")).default;
pomdtr avatar
listVals
@pomdtr
An interactive, runnable TypeScript val by pomdtr
Script
import { fetch } from "https://esm.town/v/std/fetch";
export async function listVals(req: Request) {
if (req.method == "GET") {
return Response.json({
stevekrouse avatar
valOutput
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
export async function valOutput(req: Request) {
const url = new URL(req.url);
const pattern = /^\/([^\/]+)\/([^@]+)(?:@([^\.]+))?$/;
yawnxyz avatar
selectHtml
@yawnxyz
SelectHtml is a Deno-based HTML scraper that integrates AI with Cheerio and Pug. This tool allows you to fetch, clean, and manipulate HTML content from URLs, using the Cheerio library to select and clean the HTML elements, and html2pug to convert HTML into Pug templates. Deprecated; use htmlTo instead, as that one supports more formats: https://www.val.town/v/yawnxyz/htmlTo
Script
import { JSDOM } from 'npm:jsdom';
// Function to fetch HTML from a URL and remove <style> and <script> tags
export async function fetchHtml(url, removeSelectors = "style, script, link, noscript, frame, iframe, comment") {
try {
return null;
// Function to use Cheerio to select text from the html, and attempts to clean it a bit
export function selectHtml(html, selector = "h1", removeSelectors = "style, script, link, noscript, frame, iframe, comment")
const $ = cheerio.load(html); // Load the cleaned HTML into Cheerio
return res.replace(/\s+/g, ' ').trim();
// Function to convert HTML to Pug using html2pug
export function convertHtmlToPug(html, options = { tabs: true }) {
const pug = html2pug(html, options);
includeMetaData?: 'basic' | 'extended';
export function convertHtmlToMarkdown(htmlStr: string, options?: ConversionOptions): string {
const dom = new JSDOM(htmlStr);
siygle avatar
resumeDetails
@siygle
๐Ÿ’ผ Thomas Seeley's resume in the JSON Resume standard
HTTP
export default async function handler(req: Request): Promise<Response> {
const resumeDetails = {
"basics": {
"highlights": [
"Developed a straightforward request lifecycle, handling both static and dynamic content efficiently",
d a flexible plugin system, enhancing extensibility and allowing for custom functionality in generated websites",
"Implemented efficient caching techniques, including in-memory content caching and static file path caching, to boo
"Designed a flexible content source system, allowing for intuitive content organization based on directory structur
jbwinters avatar
RefiComparison
@jbwinters
* This app creates a comprehensive mortgage refinance offer comparison tool. * It calculates monthly payments, total interest paid, and displays charts for visual comparison. * It uses React for the frontend, Chart.js for data visualization, and Val Town's blob storage for data persistence.
HTTP
totalInterest: number;
function App() {
const [offers, setOffers] = useState<Offer[]>([]);
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
client();
async function server(request: Request): Promise<Response> {
const { blob } = await import("https://esm.town/v/std/blob");
โ€ฆ
176
โ€ฆ
Next