Search
hackerNewsDigest
@mihai
Hacker News Digest Fork this val to get an email like this in your inbox!
Cron
# Hacker News Digest
Fork this val to get an email like this in your inbox!
<img width="400px" src="https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/2661d748-d7a7-4d1e-85a4-f60fae262000/public" />
// This cron emails Hacker News stories from its API every 3 days.
async function fetchStories(type: string, count: number) {
const response = await fetch(`https://hacker-news.firebaseio.com/v0/${type}stories.json`);
const storyIds = await response.json();
const stories = await Promise.all(
storyIds.slice(0, count).map(async (id: number) => {
const storyResponse = await fetch(`https://hacker-news.firebaseio.com/v0/item/${id}.json`);
arena
@caizoryan
An interactive, runnable TypeScript val by caizoryan
HTTP
function rot13(message) {
return message.replace(
/[a-z]/gi,
letter => String.fromCharCode(letter.charCodeAt(0) + (letter.toLowerCase() <= "m" ? 13 : -13)),
const decodeHTML = function(str) {
var map = {
quot: "\"",
amp: "&",
lt: "<",
gt: ">",
val_ILKOorzhdB
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_ILKOorzhdB(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const checkAnomalies = () => {
const patterns = [
{ name: 'Pattern A', expected: true, actual: false },
{ name: 'Pattern B', expected: true, actual: true },
{ name: 'Pattern C', expected: false, actual: true }
const anomalies = patterns.filter(pattern => pattern.expected !== pattern.actual);
bsky
@stevekrouse
Showing my BlueSky posts using their public API
HTTP
Showing my BlueSky posts using their public API
/** @jsxImportSource npm:hono/jsx */
type Feed = {
feed: { post: { uri: string; author: { displayName: string; avatar: string }; record: { text: string } } }[];
export default async function(req: Request): Promise<Response> {
const url =
"https://public.api.bsky.app/xrpc/app.bsky.feed.getAuthorFeed?actor=stevekrouse.com&filter=posts_no_replies";
const data: Feed = await fetch(url).then((r) => r.json());
return new Response(
(<html>
fcReady
@dbee
An interactive, runnable TypeScript val by dbee
Script
import fcsdk from "https://esm.sh/@farcaster/frame-sdk@0.0.26";
setTimeout(async () => {
await fcsdk.actions.ready();
}, 500);
val_cVoOy5yJOH
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_cVoOy5yJOH(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
// Conway's Game of Life implementation with ASCII art
class GameOfLife {
constructor(size = 10) {
this.size = size;
this.grid = Array(size).fill().map(() =>
Array(size).fill().map(() => Math.random() < 0.3)
rattyAmberLeopard
@git
An interactive, runnable TypeScript val by git
HTTP
export default async function(req: Request): Promise<Response> {
const url = new URL(req.url);
const passedUrl = url.searchParams.get("url");
const passedSvg = url.searchParams.get("svg");
return new Response(
/* html */ `<html>
<head>
<script
src="https://cdn.jsdelivr.net/npm/@electric-sql/pglite@0.2.0/dist/index.js"
type="module"
hn
@maxm
// This approach injects a notification indicator with a counter into the top toolbar
HTTP
// This approach injects a notification indicator with a counter into the top toolbar
// of the Hacker News proxy for logged-in users. It modifies the HTML response
// to include the notification count in an orange box with rounded corners.
const { httpEndpoint, name } = extractValInfo(import.meta.url);
// Initialize the SQLite table
await sqlite.execute(`
CREATE TABLE IF NOT EXISTS user_cookie_${name} (
id INTEGER PRIMARY KEY CHECK (id = 1),
cookie_value TEXT
function createErrorPage(title: string, message: string): string {
valle_tmp_84405148150117935901731145572002
@janpaul123
// This val will respond to any request with an HTML "Hello, world!" message
HTTP
// This val will respond to any request with an HTML "Hello, world!" message
export default async function(req: Request): Promise<Response> {
return new Response("<h1>Hello, world!</h1>", { headers: { "Content-Type": "text/html" } });
brilliantCoralCockroach
@dmaretskyi
An interactive, runnable TypeScript val by dmaretskyi
HTTP
export default async function(req: Request): Promise<Response> {
return Response.json({ ok: true });
valle_tmp_3001062978969282023029581766561558
@janpaul123
// This HTTP val will return HTML with a comment form and display all previous comments.
HTTP
// This HTTP val will return HTML with a comment form and display all previous comments.
// Comments are saved in blob storage and will be displayed to all users.
const key = "comments";
export default async function main(req: Request): Promise<Response> {
if (req.method === "POST") {
// Handle comment submission
const formData = await req.formData();
const comment = formData.get("comment")?.toString();
if (comment) {
// Get current comments
redFerret
@maxm
An interactive, runnable TypeScript val by maxm
HTTP
export default async function (req: Request): Promise<Response> {
return Response.json({ ok: true })
simpleSurf
@cjpais
An interactive, runnable TypeScript val by cjpais
RPC (deprecated)
export const simpleSurf = (async () => {
// fetch these from the surfline page
const spotIds = [
"5842041f4e65fad6a770883f",
"5842041f4e65fad6a77088b4",
"5842041f4e65fad6a77088af",
"5842041f4e65fad6a770888b",
"5842041f4e65fad6a7708b32",
const spots = spotIds.join(",");
const surfForecast = await fetch(
val_WzWC3no9LW
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_WzWC3no9LW(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const checkAnomalies = () => {
const expectedPatterns = [1, 2, 3, 4, 5]; // Example expected patterns
const actualPatterns = [1, 2, 3, 4, 6]; // Example actual patterns with an anomaly
const anomalies = actualPatterns.filter((pattern, index) => pattern !== expectedPatterns[index]);
return anomalies.length > 0 ? anomalies : 'No anomalies detected';
return checkAnomalies();
googleProxy
@omgwtfbrblolttyl
An interactive, runnable TypeScript val by omgwtfbrblolttyl
Script
export const googleProxy = async (req: express.Request, res: express.Response) => {
const axios = await import("axios");
const reqKey = req.header("key");
const proxyKey = process.env["googleProxyKey"];
if (reqKey !== proxyKey) {
return res.status(401).end();
const actualKey = process.env["googleAPIKey"];
const rewritten = req.originalUrl.replace(
`key=${proxyKey}`,
`key=${actualKey}`,