Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/$2?q=function&page=10&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=function

Returns an array of strings in format "username" or "username/projectName"

Found 24460 results for "function"(1916ms)

html-experimentstownie-analog-clock.ts3 matches

@chadparker•Updated 8 hours ago
1export default async function(req: Request) {
2 const html = `<!DOCTYPE html>
3<html lang="en">
161
162 <script>
163 function updateClock() {
164 const now = new Date();
165 const hours = now.getHours() % 12;
187
188 // Add minute markers
189 function createMinuteMarkers() {
190 const clockFace = document.querySelector('.clock-face');
191 for (let i = 0; i < 60; i++) {

websocketserver.js9 matches

@jeetz•Updated 9 hours ago
1(function(g) {
2 const PORT = 8000;
3
4 function WebSocketHandler(opt) {
5 this.opt = opt || {};
6 this.isBrowser = typeof window !== "undefined";
13 }
14
15 WebSocketHandler.prototype._notifyStatus = function() {
16 this.opt.onStatusChange && this.opt.onStatusChange({
17 connected: this.connected,
20 };
21
22 WebSocketHandler.prototype.connect = function() {
23 if (!this.isBrowser) return;
24
31 };
32
33 WebSocketHandler.prototype._connectRealWS = function() {
34 const self = this;
35 this.ws = new WebSocket(`ws://localhost:${this.PORT}`);
70 };
71
72 WebSocketHandler.prototype._startFallback = function() {
73 if (!this.simulated) {
74 this.simulated = true;
79 };
80
81 WebSocketHandler.prototype._scheduleReconnect = function() {
82 const self = this;
83 if (this.reconnectTimer) return;
90 };
91
92 WebSocketHandler.prototype.send = function(msg) {
93 if (this.connected && !this.simulated && this.ws && this.ws.readyState === WebSocket.OPEN) {
94 this.ws.send(msg);
103
104 // Server-side code (for Deno)
105 if (typeof Deno !== "undefined" && typeof Deno.serve === "function") {
106 Deno.serve({ port: PORT }, (req) => {
107 if (req.headers.get("upgrade") !== "websocket") {

todo-app-conversionTodoChat.tsx1 match

@diegoivo•Updated 10 hours ago
10}
11
12export default function TodoChat({ todo, user, onUpdateTodo, onClose }: TodoChatProps) {
13 const [message, setMessage] = useState("");
14 const [loading, setLoading] = useState(false);

todo-app-conversionindex.ts16 matches

@diegoivo•Updated 10 hours ago
31app.get("/shared/*", c => serveFile(c.req.path, import.meta.url));
32
33// Helper function to hash password (simple hash for demo)
34async function hashPassword(password: string): Promise<string> {
35 const encoder = new TextEncoder();
36 const data = encoder.encode(password + "conversion_salt");
40}
41
42// Helper function to get user's todos key
43function getUserTodosKey(email: string): string {
44 return `todos:${email}`;
45}
46
47// Helper function to get user's auth key
48function getUserAuthKey(email: string): string {
49 return `auth:${email}`;
50}
51
52// Helper function to get user's todos
53async function getUserTodos(email: string): Promise<Todo[]> {
54 const key = getUserTodosKey(email);
55 const todos = await blob.getJSON(key);
57}
58
59// Helper function to save user's todos
60async function saveUserTodos(email: string, todos: Todo[]): Promise<void> {
61 const key = getUserTodosKey(email);
62 await blob.setJSON(key, todos);
63}
64
65// Helper function to get user from email/password auth
66async function getEmailUser(email: string): Promise<User | null> {
67 const key = getUserAuthKey(email);
68 const userData = await blob.getJSON(key);
70}
71
72// Helper function to verify password
73async function verifyPassword(email: string, password: string): Promise<boolean> {
74 const key = getUserAuthKey(email);
75 const userData = await blob.getJSON(key);
79}
80
81// Helper function to get current user
82async function getCurrentUser(c: any): Promise<User | null> {
83 // Check LastLogin first
84 const lastLoginEmail = c.req.header("X-LastLogin-Email");

todo-app-conversionApp.tsx1 match

@diegoivo•Updated 10 hours ago
18}
19
20export default function App() {
21 const [user, setUser] = useState<User | null>(null);
22 const [todos, setTodos] = useState<Todo[]>([]);

todo-app-conversionTodoApp.tsx1 match

@diegoivo•Updated 10 hours ago
9}
10
11export default function TodoApp({ user, initialTodos }: TodoAppProps) {
12 const [todos, setTodos] = useState<Todo[]>(initialTodos);
13 const [newTodoTitle, setNewTodoTitle] = useState("");

todo-app-conversionLandingPage.tsx1 match

@diegoivo•Updated 10 hours ago
2import React from "https://esm.sh/react@18.2.0?deps=react@18.2.0";
3
4export default function LandingPage() {
5 return (
6 <div className="min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100">

todo-app-conversionLoginPage.tsx1 match

@diegoivo•Updated 10 hours ago
8}
9
10export default function LoginPage({ onLogin }: LoginPageProps) {
11 const [isSignup, setIsSignup] = useState(false);
12 const [email, setEmail] = useState("");

todo-appTodoList.tsx1 match

@diegoivo•Updated 10 hours ago
10}
11
12export default function TodoList({ todos, onUpdate, onDelete, loading }: TodoListProps) {
13 const [filter, setFilter] = useState<'all' | 'active' | 'completed'>('all');
14 const [categoryFilter, setCategoryFilter] = useState<Todo['category'] | 'all'>('all');

eink-frameREADME.md1 match

@michaelwschultz•Updated 10 hours ago
5#### Python code for display available at https://github.com/michaelwschultz/eink-frame
6
7## Functioning Hardware
8
9| News | NASA Photo of the Day |

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblk•Updated 1 month ago
Simple functional CSS library for Val Town
lost1991
import { OpenAI } from "https://esm.town/v/std/openai"; export default async function(req: Request): Promise<Response> { if (req.method === "OPTIONS") { return new Response(null, { headers: { "Access-Control-Allow-Origin": "*",
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.