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/image-url.jpg%20%22Optional%20title%22?q=function&page=26&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 18856 results for "function"(515ms)

testtownieindex.tsx6 matches

@charmaineโ€ขUpdated 1 day ago
10
11// Main App component
12function App() {
13 return (
14 <BrowserRouter>
29
30// Home page component
31function Home() {
32 const [posts, setPosts] = React.useState<PostWithTags[]>([]);
33 const [loading, setLoading] = React.useState(true);
35
36 React.useEffect(() => {
37 async function fetchPosts() {
38 try {
39 const response = await fetch('/api/posts');
74
75// Single post page component
76function Post() {
77 const { slug } = useParams<{ slug: string }>();
78 const [post, setPost] = React.useState<PostWithTags | null>(null);
82
83 React.useEffect(() => {
84 async function fetchPost() {
85 if (!slug) return;
86
139
140// 404 Not Found component
141function NotFound() {
142 return (
143 <div className="text-center py-12">

testtowniequeries.ts5 matches

@charmaineโ€ขUpdated 1 day ago
6 * Get all published blog posts
7 */
8export async function getAllPosts(): Promise<PostWithTags[]> {
9 const result = await sqlite.execute(`
10 SELECT
58 * Get a single blog post by slug
59 */
60export async function getPostBySlug(slug: string): Promise<PostWithTags | null> {
61 const result = await sqlite.execute(`
62 SELECT
112 * Get all tags
113 */
114export async function getAllTags(): Promise<Tag[]> {
115 const result = await sqlite.execute(`
116 SELECT id, name, slug
129 * Create a new blog post
130 */
131export async function createPost(post: Omit<Post, 'id'>): Promise<number> {
132 const result = await sqlite.execute(`
133 INSERT INTO ${POSTS_TABLE} (
153 * Update an existing blog post
154 */
155export async function updatePost(id: number, post: Partial<Post>): Promise<boolean> {
156 const fields: string[] = [];
157 const values: any[] = [];

testtowniemigrations.ts2 matches

@charmaineโ€ขUpdated 1 day ago
9 * Create all necessary tables for the blog
10 */
11export async function createTables() {
12 // Create posts table
13 await sqlite.execute(`
59 * Create a sample blog post
60 */
61async function createSamplePost() {
62 const now = Date.now();
63

testtownieREADME.md1 match

@charmaineโ€ขUpdated 1 day ago
17โ”‚ โ”œโ”€โ”€ database/
18โ”‚ โ”‚ โ”œโ”€โ”€ migrations.ts # Schema definitions
19โ”‚ โ”‚ โ””โ”€โ”€ queries.ts # DB query functions
20โ”‚ โ”œโ”€โ”€ routes/ # Route modules
21โ”‚ โ”‚ โ”œโ”€โ”€ posts.ts # Blog post routes

emailsstd.tsx1 match

@valdottownโ€ขUpdated 1 day ago
2import { AttachmentData, email } from "https://esm.town/v/std/email?v=13";
3
4export default async function(e: Email) {
5 let attachments: AttachmentData[] = [];
6 for (const f of e.attachments) {

emailsvaldottown.tsx1 match

@valdottownโ€ขUpdated 1 day ago
2import { AttachmentData, email } from "https://esm.town/v/std/email?v=13";
3
4export default async function(e: Email) {
5 let attachments: AttachmentData[] = [];
6 for (const f of e.attachments) {

untitled-885README.md15 matches

@sakil20โ€ขUpdated 1 day ago
168 'Anatomy & Physiology': [
169 { question: 'What is the largest organ in the human body?', options: ['Skin', 'Brain', 'Heart', 'Lungs'], correct: 'Skin', explanation: 'The skin is the largest organ in the human body, covering the entire surface of the body.' },
170 { question: 'What is the function of the liver?', options: ['To filter waste from the blood', 'To produce bile', 'To store glycogen', 'All of the above'], correct: 'All of the above', explanation: 'The liver has many functions, including filtering waste from the blood, producing bile, and storing glycogen.' },
171 { question: 'What is the function of the kidneys?', options: ['To filter waste from the blood', 'To produce urine', 'To regulate blood pressure', 'All of the above'], correct: 'All of the above', explanation: 'The kidneys have many functions, including filtering waste from the blood, producing urine, and regulating blood pressure.' },
172 { question: 'What is the function of the lungs?', options: ['To bring oxygen into the body', 'To remove carbon dioxide from the body', 'To regulate body temperature', 'All of the above'], correct: 'All of the above', explanation: 'The lungs have many functions, including bringing oxygen into the body, removing carbon dioxide from the body, and regulating body temperature.' },
173 { question: 'What is the function of the brain?', options: ['To control the body\'s movements', 'To regulate the body\'s functions', 'To process information', 'All of the above'], correct: 'All of the above', explanation: 'The brain has many functions, including controlling the body\'s movements, regulating the body\'s functions, and processing information.' },
174 ],
175 'Biochemistry': [
176 { question: 'What is the main function of enzymes in the body?', options: ['To produce energy', 'To synthesize proteins', 'To catalyze chemical reactions', 'To store genetic information'], correct: 'To catalyze chemical reactions', explanation: 'Enzymes are biological molecules that catalyze chemical reactions in the body, allowing for the breakdown and synthesis of molecules.' },
177 { question: 'What is the difference between a saturated and an unsaturated fatty acid?', options: ['A saturated fatty acid has no double bonds, while an unsaturated fatty acid has one or more double bonds', 'A saturated fatty acid has one or more double bonds, while an unsaturated fatty acid has no double bonds', 'A saturated fatty acid is found only in animal products, while an unsaturated fatty acid is found only in plant products', 'A saturated fatty acid is found only in plant products, while an unsaturated fatty acid is found only in animal products'], correct: 'A saturated fatty acid has no double bonds, while an unsaturated fatty acid has one or more double bonds', explanation: 'Saturated fatty acids have no double bonds between the carbon atoms, while unsaturated fatty acids have one or more double bonds.' },
178 { question: 'What is the function of carbohydrates in the body?', options: ['To provide energy', 'To build and repair tissues', 'To regulate body functions', 'All of the above'], correct: 'All of the above', explanation: 'Carbohydrates have many functions in the body, including providing energy, building and repairing tissues, and regulating body functions.' },
179 { question: 'What is the function of proteins in the body?', options: ['To provide energy', 'To build and repair tissues', 'To regulate body functions', 'All of the above'], correct: 'All of the above', explanation: 'Proteins have many functions in the body, including providing energy, building and repairing tissues, and regulating body functions.' },
180 { question: 'What is the function of nucleic acids in the body?', options: ['To store genetic information', 'To synthesize proteins', 'To regulate body functions', 'All of the above'], correct: 'All of the above', explanation: 'Nucleic acids have many functions in the body, including storing genetic information, synthesizing proteins, and regulating body functions.' },
181 ],
182 'Nutrition & Dietetics': [
192 var interval;
193 var score = 0;
194 $(document).ready(function() {
195 $('.dropdown-item[data-subject]').click(function() {
196 subject = $(this).data('subject');
197 generateQuestion();
198 });
199 $('#submit-btn').click(function() {
200 checkAnswer();
201 });
202 });
203 function generateQuestion() {
204 if(subject == '') {
205 $('#modal-results-text').text('Please select a subject');
216 startTimer();
217 }
218 function startTimer() {
219 clearInterval(interval);
220 timer = 60;
221 interval = setInterval(function() {
222 timer--;
223 $('#timer').text('Time remaining: ' + timer + ' seconds');
228 }, 1000);
229 }
230 function checkAnswer() {
231 clearInterval(interval);
232 var userAnswer = $('input[name="option"]:checked').val();
luciaMagicLinkStarter

luciaMagicLinkStartermagic-links.ts4 matches

@stevekrouseโ€ขUpdated 1 day ago
7
8// Hash a token using sha256
9function hashToken(token: string): string {
10 return encodeHexLowerCase(sha256(new TextEncoder().encode(token)));
11}
12
13// Create a magic link token for the given email
14export async function createMagicLinkToken(userEmail: string): Promise<string> {
15 const token = generateSessionToken();
16 const tokenHash = hashToken(token);
27
28// Send a magic link email
29export async function sendMagicLinkEmail(url: string, userEmail: string, token: string): Promise<boolean> {
30 try {
31 const magicLink = `${url}/auth/magic-link/${token}`;
55
56// Validate a magic link token and create a session
57export async function validateMagicLinkToken(token: string): Promise<{ valid: boolean; userId?: number }> {
58 const now = Math.floor(Date.now() / 1000);
59 const tokenHash = hashToken(token);
luciaMagicLinkStarter

luciaMagicLinkStarterApp.tsx1 match

@stevekrouseโ€ขUpdated 1 day ago
16}
17
18export function App({ initialData }: { initialData: InitialData }) {
19 const [user, setUser] = useState<User | null>(initialData.user);
20 const [error, setError] = useState<string | null>(initialData.error);

untitled-7683README.md1 match

@Aibโ€ขUpdated 1 day ago
1# untitled-7683// Full A-to-Z structure of a basic MuCute-style Minecraft PE client (simplified) // This mock is for learning purposes and replicates core client relay functions // You must have native MuCuteRelay library ready (compiled from: https://github.com/OpenMITM/MuCuteRelay)
2
3// Directory structure: // - app // - src/main/java/com/example/mucuteclient/MainActivity.java // - src/main/jniLibs/armeabi-v7a/libmucuterelay.so // - res/layout/activity_main.xml // - AndroidManifest.xml // - build.gradle

getFileEmail4 file matches

@shouserโ€ขUpdated 2 weeks ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblkโ€ขUpdated 2 weeks ago
Simple functional CSS library for Val Town
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",